mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 15:53:37 +00:00
add logic break alliance. break alliance makes you traitor
This commit is contained in:
@@ -15,7 +15,11 @@ export class AllianceRequestExecution implements Execution {
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
this.mg.createAllianceRequest(this.requestor, this.recipient)
|
||||
if (this.requestor.alliedWith(this.recipient)) {
|
||||
console.warn('already allied')
|
||||
} else {
|
||||
this.mg.createAllianceRequest(this.requestor, this.recipient)
|
||||
}
|
||||
this.active = false
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import {PriorityQueue} from "@datastructures-js/priority-queue";
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, PlayerID, TerrainType, TerraNullius, Tile} from "../game/Game";
|
||||
import {Cell, Execution, MutableGame, MutablePlayer, Player, PlayerID, TerrainType, TerraNullius, Tile} from "../game/Game";
|
||||
import {PseudoRandom} from "../PseudoRandom";
|
||||
import {manhattanDist} from "../Util";
|
||||
import {Terrain} from "../game/TerrainMapLoader";
|
||||
|
||||
export class AttackExecution implements Execution {
|
||||
private breakAlliance = false
|
||||
private active: boolean = true;
|
||||
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>((a: TileContainer, b: TileContainer) => {
|
||||
if (a.priority == b.priority) {
|
||||
@@ -83,6 +84,14 @@ export class AttackExecution implements Execution {
|
||||
} else {
|
||||
this.refreshToConquer()
|
||||
}
|
||||
|
||||
if (this.target.isPlayer()) {
|
||||
if (this._owner.alliedWith(this.target)) {
|
||||
// No updates should happen in init.
|
||||
this.breakAlliance = true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private refreshToConquer() {
|
||||
@@ -100,6 +109,11 @@ export class AttackExecution implements Execution {
|
||||
if (ticks < this.mg.config().numSpawnPhaseTurns()) {
|
||||
return
|
||||
}
|
||||
if (this.breakAlliance) {
|
||||
this.breakAlliance = false
|
||||
alert('set player traitor')
|
||||
this._owner.breakAllianceWith(this.target as Player)
|
||||
}
|
||||
|
||||
let numTilesPerTick = this.mg.config().attackTilesPerTick(this._owner, this.target, this.border.size + this.random.nextInt(0, 5))
|
||||
// console.log(`num tiles per tick: ${numTilesPerTick}`)
|
||||
|
||||
Reference in New Issue
Block a user