mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-22 15:17:08 +00:00
Added local attack
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -60,7 +60,7 @@ export class Executor {
|
||||
intent.troops,
|
||||
player,
|
||||
intent.targetID,
|
||||
null,
|
||||
intent.sourceTile ?? null,
|
||||
);
|
||||
}
|
||||
case "cancel_attack":
|
||||
|
||||
Reference in New Issue
Block a user