mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 04:58:01 +00:00
when attacking by boat, attack execution only starts from boat pixel
This commit is contained in:
@@ -17,6 +17,7 @@ export class AttackExecution implements Execution {
|
||||
private troops: number,
|
||||
private _ownerID: PlayerID,
|
||||
private targetID: PlayerID | null,
|
||||
private sourceCell: Cell | null,
|
||||
private targetCell: Cell | null,
|
||||
) { }
|
||||
|
||||
@@ -54,16 +55,18 @@ export class AttackExecution implements Execution {
|
||||
}
|
||||
}
|
||||
// Existing attack on same target, add troops
|
||||
if (otherAttack._owner == this._owner && otherAttack.targetID == this.targetID) {
|
||||
if (otherAttack._owner == this._owner && otherAttack.targetID == this.targetID && this.sourceCell == otherAttack.sourceCell) {
|
||||
otherAttack.troops += this.troops
|
||||
otherAttack.refreshToConquer()
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.refreshToConquer()
|
||||
if (this.sourceCell != null) {
|
||||
this.addNeighbors(mg.tile(this.sourceCell))
|
||||
} else {
|
||||
this.refreshToConquer()
|
||||
}
|
||||
}
|
||||
|
||||
private refreshToConquer() {
|
||||
|
||||
@@ -118,7 +118,7 @@ export class BoatAttackExecution implements Execution {
|
||||
return
|
||||
}
|
||||
this.attacker.conquer(this.dst)
|
||||
this.mg.addExecution(new AttackExecution(this.troops, this.attacker.id(), this.targetID, null))
|
||||
this.mg.addExecution(new AttackExecution(this.troops, this.attacker.id(), this.targetID, this.dst.cell(), null))
|
||||
this.boat.delete()
|
||||
this.active = false
|
||||
return
|
||||
|
||||
@@ -67,6 +67,7 @@ export class BotExecution implements Execution {
|
||||
this.bot.troops() / 20,
|
||||
this.bot.id(),
|
||||
toAttack.isPlayer() ? toAttack.id() : null,
|
||||
null,
|
||||
null
|
||||
))
|
||||
}
|
||||
|
||||
@@ -22,11 +22,14 @@ export class Executor {
|
||||
|
||||
createExec(intent: Intent): Execution {
|
||||
if (intent.type == "attack") {
|
||||
const source: Cell | null = intent.sourceX != null && intent.sourceY != null ? new Cell(intent.sourceX, intent.sourceY) : null
|
||||
const target: Cell | null = intent.targetX != null && intent.targetY != null ? new Cell(intent.targetX, intent.targetY) : null
|
||||
return new AttackExecution(
|
||||
intent.troops,
|
||||
intent.attackerID,
|
||||
intent.targetID,
|
||||
new Cell(intent.targetX, intent.targetY)
|
||||
source,
|
||||
target,
|
||||
)
|
||||
} else if (intent.type == "spawn") {
|
||||
return new SpawnExecution(
|
||||
|
||||
Reference in New Issue
Block a user