Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/defenseManager.js
Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | if (!this.armies.length) | ||||
// check if we can recover capture points from any of our notdecaying structures | // check if we can recover capture points from any of our notdecaying structures | ||||
for (let ent of gameState.getOwnStructures().values()) | for (let ent of gameState.getOwnStructures().values()) | ||||
{ | { | ||||
if (ent.decaying()) | if (ent.decaying()) | ||||
continue; | continue; | ||||
let capture = ent.capturePoints(); | let capture = ent.capturePoints(); | ||||
if (capture === undefined) | if (capture === undefined) | ||||
continue; | continue; | ||||
if (!capture.length) | |||||
continue; | |||||
let lost = 0; | let lost = 0; | ||||
for (let j = 0; j < capture.length; ++j) | for (let j = 0; j < capture.length; ++j) | ||||
if (gameState.isPlayerEnemy(j)) | if (gameState.isPlayerEnemy(j)) | ||||
lost += capture[j]; | lost += capture[j]; | ||||
if (lost < Math.ceil(0.25 * capture[i])) | if (lost < Math.ceil(0.25 * capture[i])) | ||||
continue; | continue; | ||||
this.makeIntoArmy(gameState, ent.id(), "capturing"); | this.makeIntoArmy(gameState, ent.id(), "capturing"); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 727 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator