mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 20:25:27 +00:00
added right click option break alliance
This commit is contained in:
@@ -9,8 +9,9 @@ import {UpdateNameExecution} from "./UpdateNameExecution";
|
||||
import {FakeHumanExecution} from "./FakeHumanExecution";
|
||||
import Usernames from '../../../resources/Usernames.txt'
|
||||
import {simpleHash} from "../Util";
|
||||
import {AllianceRequestExecution} from "./AllianceRequestExecution";
|
||||
import {AllianceRequestReplyExecution} from "./AllianceRequestReplyExecution";
|
||||
import {AllianceRequestExecution} from "./alliance/AllianceRequestExecution";
|
||||
import {AllianceRequestReplyExecution} from "./alliance/AllianceRequestReplyExecution";
|
||||
import {BreakAllianceExecution} from "./alliance/BreakAllianceExecution";
|
||||
|
||||
|
||||
|
||||
@@ -61,6 +62,8 @@ export class Executor {
|
||||
return new AllianceRequestExecution(intent.requestor, intent.recipient)
|
||||
} else if (intent.type == "allianceRequestReply") {
|
||||
return new AllianceRequestReplyExecution(intent.requestor, intent.recipient, intent.accept)
|
||||
} else if (intent.type == "breakAlliance") {
|
||||
return new BreakAllianceExecution(intent.requestor, intent.recipient)
|
||||
}
|
||||
else {
|
||||
throw new Error(`intent type ${intent} not found`)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {AllianceRequest, Execution, MutableGame, MutablePlayer, Player, PlayerID} from "../game/Game";
|
||||
import {AllianceRequest, Execution, MutableGame, MutablePlayer, Player, PlayerID} from "../../game/Game";
|
||||
|
||||
export class AllianceRequestExecution implements Execution {
|
||||
private active = true
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {AllianceRequest, Execution, MutableGame, MutablePlayer, Player, PlayerID} from "../game/Game";
|
||||
import {AllianceRequest, Execution, MutableGame, MutablePlayer, Player, PlayerID} from "../../game/Game";
|
||||
|
||||
export class AllianceRequestReplyExecution implements Execution {
|
||||
private active = true
|
||||
@@ -0,0 +1,35 @@
|
||||
import {AllianceRequest, Execution, MutableGame, MutablePlayer, Player, PlayerID} from "../../game/Game";
|
||||
|
||||
export class BreakAllianceExecution implements Execution {
|
||||
private active = true
|
||||
private requestor: MutablePlayer;
|
||||
private recipient: MutablePlayer
|
||||
|
||||
constructor(private requestorID: PlayerID, private recipientID: PlayerID) { }
|
||||
|
||||
init(mg: MutableGame, ticks: number): void {
|
||||
this.requestor = mg.player(this.requestorID)
|
||||
this.recipient = mg.player(this.recipientID)
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (!this.requestor.alliedWith(this.recipient)) {
|
||||
console.warn('cant break alliance, not allied')
|
||||
} else {
|
||||
this.requestor.breakAllianceWith(this.recipient)
|
||||
}
|
||||
this.active = false
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
return null
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user