feat: when player has no port warship do not capture trade or heal anymore (#280)

This commit is contained in:
Ilan Schemoul
2025-03-18 20:07:51 +01:00
committed by GitHub
parent 48d111bf0d
commit 6ad4ac86f4
2 changed files with 7 additions and 1 deletions
+4 -1
View File
@@ -42,12 +42,15 @@ export class PlayerExecution implements Execution {
tick(ticks: number) {
this.player.decayRelations();
const hasPort = this.player.units(UnitType.Port).length > 0;
this.player.units().forEach((u) => {
if (u.health() <= 0) {
u.delete();
return;
}
u.modifyHealth(1);
if (hasPort && u.type() == UnitType.Warship) {
u.modifyHealth(1);
}
const tileOwner = this.mg.owner(u.tile());
if (u.info().territoryBound) {
if (tileOwner.isPlayer()) {
+3
View File
@@ -136,6 +136,7 @@ export class WarshipExecution implements Execution {
if (this.target != null && !this.target.isActive()) {
this.target = null;
}
const hasPort = this._owner.units(UnitType.Port).length > 0;
const ships = this.mg
.units(UnitType.TransportShip, UnitType.Warship, UnitType.TradeShip)
.filter((u) => this.mg.manhattanDist(u.tile(), this.warship.tile()) < 130)
@@ -143,6 +144,8 @@ export class WarshipExecution implements Execution {
.filter((u) => u != this.warship)
.filter((u) => !u.owner().isAlliedWith(this.warship.owner()))
.filter((u) => !this.alreadySentShell.has(u))
// Do not target trade ships if we don't have port
.filter((u) => u.type() != UnitType.TradeShip || hasPort)
.filter((u) => {
const portOwner = u.dstPort() ? u.dstPort().owner() : null;
return u.type() != UnitType.TradeShip || portOwner != this.owner();