(reference: Creature, relation: Team)
| 256 | } |
| 257 | |
| 258 | private getTeamCombatPower(reference: Creature, relation: Team): number { |
| 259 | let aliveUnits = 0; |
| 260 | let totalHealthRatio = 0; |
| 261 | let totalLevels = 0; |
| 262 | let upgradedAbilities = 0; |
| 263 | |
| 264 | this.game.creatures.forEach((creature) => { |
| 265 | if (!creature || creature.dead || creature.temp || !isTeam(reference, creature, relation)) { |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | aliveUnits += 1; |
| 270 | |
| 271 | const maxHealth = Number(creature.stats?.health ?? 0); |
| 272 | if (maxHealth > 0) { |
| 273 | totalHealthRatio += Math.max(0, Math.min(1, creature.health / maxHealth)); |
| 274 | } |
| 275 | |
| 276 | totalLevels += Number.isFinite(Number(creature.level)) ? Number(creature.level) : 0; |
| 277 | |
| 278 | upgradedAbilities += creature.abilities.filter( |
| 279 | (ability) => typeof ability?.isUpgraded === 'function' && ability.isUpgraded(), |
| 280 | ).length; |
| 281 | }); |
| 282 | |
| 283 | return aliveUnits * 220 + totalHealthRatio * 140 + totalLevels * 55 + upgradedAbilities * 90; |
| 284 | } |
| 285 | |
| 286 | isBotTurn() { |
| 287 | const activeCreature = this.game.activeCreature; |
no test coverage detected