Merge branch 'main' into meta3

This commit is contained in:
1brucben
2025-04-22 16:52:55 +02:00
21 changed files with 455 additions and 194 deletions
+2 -1
View File
@@ -68,8 +68,9 @@ export class Executor {
return new TransportShipExecution(
playerID,
intent.targetID,
this.mg.ref(intent.x, intent.y),
this.mg.ref(intent.dstX, intent.dstY),
intent.troops,
this.mg.ref(intent.srcX, intent.srcY),
);
case "allianceRequest":
return new AllianceRequestExecution(playerID, intent.recipient);
+2
View File
@@ -398,6 +398,7 @@ export class FakeHumanExecution implements Execution {
other.id(),
closest.y,
this.player.troops() / 5,
null,
),
);
}
@@ -558,6 +559,7 @@ export class FakeHumanExecution implements Execution {
this.mg.owner(dst).id(),
dst,
this.player.troops() / 5,
null,
),
);
return;
+13 -5
View File
@@ -10,9 +10,9 @@ import {
UnitType,
} from "../game/Game";
import { TileRef } from "../game/GameMap";
import { targetTransportTile } from "../game/TransportShipUtils";
import { PathFindResultType } from "../pathfinding/AStar";
import { PathFinder } from "../pathfinding/PathFinding";
import { targetTransportTile } from "../Util";
import { AttackExecution } from "./AttackExecution";
export class TransportShipExecution implements Execution {
@@ -30,7 +30,6 @@ export class TransportShipExecution implements Execution {
// TODO make private
public path: TileRef[];
private src: TileRef | null;
private dst: TileRef | null;
private boat: Unit;
@@ -42,6 +41,7 @@ export class TransportShipExecution implements Execution {
private targetID: PlayerID | null,
private ref: TileRef,
private troops: number | null,
private src: TileRef | null,
) {}
activeDuringSpawnPhase(): boolean {
@@ -113,14 +113,22 @@ export class TransportShipExecution implements Execution {
this.active = false;
return;
}
const src = this.attacker.canBuild(UnitType.TransportShip, this.dst);
if (src == false) {
const closestTileSrc = this.attacker.canBuild(
UnitType.TransportShip,
this.dst,
);
if (closestTileSrc == false) {
consolex.warn(`can't build transport ship`);
this.active = false;
return;
}
this.src = src;
if (this.src == null) {
// Only update the src if it's not already set
// because we assume that the src is set to the best spawn tile
this.src = closestTileSrc;
}
this.boat = this.attacker.buildUnit(
UnitType.TransportShip,