TransportShipExecution

This commit is contained in:
Scott Anderson
2025-04-14 21:00:23 -04:00
parent 0f3e0e7d6f
commit 02b74077d1
+10 -7
View File
@@ -55,7 +55,7 @@ export class TransportShipExecution implements Execution {
this.active = false;
return;
}
if (this.targetID != null && !mg.hasPlayer(this.targetID)) {
if (this.targetID !== null && !mg.hasPlayer(this.targetID)) {
console.warn(`TransportShipExecution: target ${this.targetID} not found`);
this.active = false;
return;
@@ -90,13 +90,16 @@ export class TransportShipExecution implements Execution {
return;
}
if (this.targetID == null || this.targetID == this.mg.terraNullius().id()) {
if (
this.targetID === null ||
this.targetID === this.mg.terraNullius().id()
) {
this.target = mg.terraNullius();
} else {
this.target = mg.player(this.targetID);
}
if (this.troops == null) {
if (this.troops === null) {
this.troops = this.mg
.config()
.boatAttackAmount(this.attacker, this.target);
@@ -105,7 +108,7 @@ export class TransportShipExecution implements Execution {
this.troops = Math.min(this.troops, this.attacker.troops());
this.dst = targetTransportTile(this.mg, this.ref);
if (this.dst == null) {
if (this.dst === null) {
consolex.warn(
`${this.attacker} cannot send ship to ${this.target}, cannot find attack tile`,
);
@@ -113,7 +116,7 @@ export class TransportShipExecution implements Execution {
return;
}
const src = this.attacker.canBuild(UnitType.TransportShip, this.dst);
if (src == false) {
if (src === false) {
consolex.warn(`can't build transport ship`);
this.active = false;
return;
@@ -129,7 +132,7 @@ export class TransportShipExecution implements Execution {
}
tick(ticks: number) {
if (this.dst == null) {
if (this.dst === null) {
this.active = false;
return;
}
@@ -148,7 +151,7 @@ export class TransportShipExecution implements Execution {
const result = this.pathFinder.nextTile(this.boat.tile(), this.dst);
switch (result.type) {
case PathFindResultType.Completed:
if (this.mg.owner(this.dst) == this.attacker) {
if (this.mg.owner(this.dst) === this.attacker) {
this.attacker.addTroops(this.troops);
this.boat.delete(false);
this.active = false;