Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/attackManager.js
Show First 20 Lines • Show All 550 Lines • ▼ Show 20 Lines | PETRA.AttackManager.prototype.getEnemyPlayer = function(gameState, attack) | ||||||||||
} | } | ||||||||||
if (attack.targetPlayer === undefined) | if (attack.targetPlayer === undefined) | ||||||||||
this.currentEnemyPlayer = enemyPlayer; | this.currentEnemyPlayer = enemyPlayer; | ||||||||||
return enemyPlayer; | return enemyPlayer; | ||||||||||
}; | }; | ||||||||||
/** | /** | ||||||||||
* Target the player with the most advanced wonder. | * Target the player with the most advanced wonder. | ||||||||||
* TODO currently the first built wonder is kept, should chek on the minimum wonderDuration left instead. | * TODO currently the first built wonder is kept, should check on the minimum wonderDuration left instead. | ||||||||||
*/ | */ | ||||||||||
PETRA.AttackManager.prototype.getWonderEnemyPlayer = function(gameState, attack) | PETRA.AttackManager.prototype.getWonderEnemyPlayer = function(gameState, attack) | ||||||||||
{ | { | ||||||||||
let enemyPlayer; | let enemyPlayer; | ||||||||||
let enemyWonder; | let enemyWonder; | ||||||||||
let moreAdvanced; | let moreAdvanced; | ||||||||||
for (let wonder of gameState.getEnemyStructures().filter(API3.Filters.byClass("Wonder")).values()) | for (let wonder of gameState.getEnemyStructures().filter(API3.Filters.byClass("Wonder")).values()) | ||||||||||
{ | { | ||||||||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | for (let unit of attackPlan.unitCollection.values()) | ||||||||||
unit.setMetadata(PlayerID, "role", "attack"); | unit.setMetadata(PlayerID, "role", "attack"); | ||||||||||
attackPlan.targetPlayer = target.owner(); | attackPlan.targetPlayer = target.owner(); | ||||||||||
attackPlan.targetPos = pos; | attackPlan.targetPos = pos; | ||||||||||
attackPlan.target = target; | attackPlan.target = target; | ||||||||||
attackPlan.state = "arrived"; | attackPlan.state = "arrived"; | ||||||||||
return true; | return true; | ||||||||||
}; | }; | ||||||||||
PETRA.AttackManager.prototype.updateEmergency = function(gameState) { | |||||||||||
Freagarach: You wil miss out on important events if you don't process them, like player defeat and entity… | |||||||||||
Not Done Inline ActionsJSDOC Missing. Stan: JSDOC Missing. | |||||||||||
// First call will stop all attacks, the second call to this | |||||||||||
// function will essentially be a no-op. | |||||||||||
for (const attackType in this.upcomingAttacks) | |||||||||||
Done Inline Actionsare you sure you cleared bombingAttacks properly by this? Silier: are you sure you cleared bombingAttacks properly by this? | |||||||||||
Done Inline ActionsYes, as I could not find any state modifications to each own unit JCWasmx86: Yes, as I could not find any state modifications to each own unit | |||||||||||
for (const attack of this.upcomingAttacks[attackType]) | |||||||||||
attack.targetPlayer = undefined; | |||||||||||
for (const attackType in this.startedAttacks) | |||||||||||
Done Inline ActionsupcomingAttacks should be stopped and cleared properly, then forbid creating new ones while in emergency Silier: upcomingAttacks should be stopped and cleared properly, then forbid creating new ones while in… | |||||||||||
Done Inline ActionsI've done basically the same as in cancelAttacksAgainstPlayer JCWasmx86: I've done basically the same as in `cancelAttacksAgainstPlayer` | |||||||||||
for (var i = 0; i < this.startedAttacks[attackType].length; ++i) | |||||||||||
{ | |||||||||||
const attack = this.startedAttacks[attackType][i]; | |||||||||||
Done Inline ActionsWe choose let for these kind of variables, they don't live outside the scope they are defined in, which prevents accidental usage. Freagarach: We choose `let` for these kind of variables, they don't live outside the scope they are defined… | |||||||||||
attack.Abort(gameState); | |||||||||||
this.startedAttacks[attackType].splice(i--, 1); | |||||||||||
} | |||||||||||
Done Inline Actions
Freagarach: | |||||||||||
}; | |||||||||||
PETRA.AttackManager.prototype.Serialize = function() | PETRA.AttackManager.prototype.Serialize = function() | ||||||||||
{ | { | ||||||||||
let properties = { | let properties = { | ||||||||||
"totalNumber": this.totalNumber, | "totalNumber": this.totalNumber, | ||||||||||
"attackNumber": this.attackNumber, | "attackNumber": this.attackNumber, | ||||||||||
"rushNumber": this.rushNumber, | "rushNumber": this.rushNumber, | ||||||||||
"raidNumber": this.raidNumber, | "raidNumber": this.raidNumber, | ||||||||||
"debugTime": this.debugTime, | "debugTime": this.debugTime, | ||||||||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
You wil miss out on important events if you don't process them, like player defeat and entity renames (for the bombers).