mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:00:43 +00:00
feat: when player has no port warship do not capture trade or heal anymore (#280)
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user