mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-14 19:09:33 +00:00
Merge branch 'main' into local-attack
This commit is contained in:
@@ -39,6 +39,7 @@ export class BotExecution implements Execution {
|
||||
if (ticks % this.attackRate !== this.attackTick) return;
|
||||
|
||||
if (!this.bot.isAlive()) {
|
||||
//removeOnDeath is called from bot's PlayerExecution
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ export class NationExecution implements Execution {
|
||||
}
|
||||
|
||||
if (!this.player.isAlive()) {
|
||||
//removeOnDeath is called from nation's PlayerExecution
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,19 +60,7 @@ export class PlayerExecution implements Execution {
|
||||
}
|
||||
|
||||
if (!this.player.isAlive()) {
|
||||
// Player has no tiles, delete any remaining units and gold
|
||||
const gold = this.player.gold();
|
||||
this.player.removeGold(gold);
|
||||
this.player.units().forEach((u) => {
|
||||
if (
|
||||
u.type() !== UnitType.AtomBomb &&
|
||||
u.type() !== UnitType.HydrogenBomb &&
|
||||
u.type() !== UnitType.MIRVWarhead &&
|
||||
u.type() !== UnitType.MIRV
|
||||
) {
|
||||
u.delete();
|
||||
}
|
||||
});
|
||||
this.removeOnDeath();
|
||||
this.active = false;
|
||||
this.mg.stats().playerKilled(this.player, ticks);
|
||||
return;
|
||||
@@ -400,4 +388,24 @@ export class PlayerExecution implements Execution {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private removeOnDeath(): void {
|
||||
// Player (bot, human, nation) has no tiles
|
||||
// Delete any remaining gold, non-nuke units and alliances
|
||||
const gold = this.player.gold();
|
||||
this.player.removeGold(gold);
|
||||
|
||||
this.player.units().forEach((u) => {
|
||||
if (
|
||||
u.type() !== UnitType.AtomBomb &&
|
||||
u.type() !== UnitType.HydrogenBomb &&
|
||||
u.type() !== UnitType.MIRVWarhead &&
|
||||
u.type() !== UnitType.MIRV
|
||||
) {
|
||||
u.delete();
|
||||
}
|
||||
});
|
||||
|
||||
this.player.removeAllAlliances();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user