Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/attackManager.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** Attack Manager */ | /** Attack Manager */ | ||||
m.AttackManager = function(Config) | m.AttackManager = function(Config) | ||||
{ | { | ||||
this.Config = Config; | this.Config = Config; | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | m.AttackManager.prototype.checkEvents = function(gameState, events) | ||||
let targetPlayer; | let targetPlayer; | ||||
for (let evt of events.AttackRequest) | for (let evt of events.AttackRequest) | ||||
{ | { | ||||
if (evt.source === PlayerID || !gameState.isPlayerAlly(evt.source) || !gameState.isPlayerEnemy(evt.player)) | if (evt.source === PlayerID || !gameState.isPlayerAlly(evt.source) || !gameState.isPlayerEnemy(evt.player)) | ||||
continue; | continue; | ||||
targetPlayer = evt.player; | targetPlayer = evt.player; | ||||
let available = 0; | let available = 0; | ||||
for (let attackType in this.upcomingAttacks) | for (let attackType in this.upcomingAttacks) | ||||
{ | { | ||||
Stan: Here as well. | |||||
for (let attack of this.upcomingAttacks[attackType]) | for (let attack of this.upcomingAttacks[attackType]) | ||||
{ | { | ||||
if (attack.state === "completing") | if (attack.state === "completing") | ||||
{ | { | ||||
if (attack.targetPlayer === targetPlayer) | if (attack.targetPlayer === targetPlayer) | ||||
available += attack.unitCollection.length; | available += attack.unitCollection.length; | ||||
else if (attack.targetPlayer !== undefined && attack.targetPlayer !== targetPlayer) | else if (attack.targetPlayer !== undefined && attack.targetPlayer !== targetPlayer) | ||||
other = attack.targetPlayer; | other = attack.targetPlayer; | ||||
▲ Show 20 Lines • Show All 722 Lines • ▼ Show 20 Lines | for (let dataAttack of data.startedAttacks[key]) | ||||
let attack = new m.AttackPlan(gameState, this.Config, dataAttack.properties.name); | let attack = new m.AttackPlan(gameState, this.Config, dataAttack.properties.name); | ||||
attack.Deserialize(gameState, dataAttack); | attack.Deserialize(gameState, dataAttack); | ||||
attack.init(gameState); | attack.init(gameState); | ||||
this.startedAttacks[key].push(attack); | this.startedAttacks[key].push(attack); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator
Here as well.