Added local attack

This commit is contained in:
Aotumuri
2026-01-10 21:46:28 +09:00
parent 240690c574
commit 54b4c5cdd8
8 changed files with 100 additions and 16 deletions
+17
View File
@@ -97,6 +97,8 @@ export class AttackExecution implements Execution {
return;
}
this.sourceTile = this.resolveSourceTile();
this.startTroops ??= this.mg
.config()
.attackAmount(this._owner, this.target);
@@ -311,6 +313,21 @@ export class AttackExecution implements Execution {
}
}
private resolveSourceTile(): TileRef | null {
if (this.sourceTile === null) {
return null;
}
if (this.mg.owner(this.sourceTile) !== this._owner) {
return null;
}
for (const neighbor of this.mg.neighbors(this.sourceTile)) {
if (this.mg.owner(neighbor) === this.target) {
return this.sourceTile;
}
}
return null;
}
private addNeighbors(tile: TileRef) {
if (this.attack === null) {
throw new Error("Attack not initialized");
+1 -1
View File
@@ -60,7 +60,7 @@ export class Executor {
intent.troops,
player,
intent.targetID,
null,
intent.sourceTile ?? null,
);
}
case "cancel_attack":