mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-04 00:10:37 +00:00
create alliance request flow
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import {AllianceRequest, Execution, MutableGame, MutablePlayer, Player, PlayerID} from "../Game";
|
||||
|
||||
export class AllianceRequestExecution implements Execution {
|
||||
private active = true
|
||||
private mg: MutableGame = null
|
||||
private requestor: Player;
|
||||
private recipient: Player
|
||||
|
||||
|
||||
constructor(private requestorID: PlayerID, private recipientID: PlayerID) { }
|
||||
|
||||
init(mg: MutableGame, ticks: number): void {
|
||||
this.mg = mg
|
||||
this.requestor = mg.player(this.requestorID)
|
||||
this.recipient = mg.player(this.recipientID)
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
alert('recied request')
|
||||
|
||||
this.active = false
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
return null
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Cell, Execution, MutableGame, Game, MutablePlayer, PlayerInfo, TerraNullius, Tile, PlayerType} from "../Game";
|
||||
import {Cell, Execution, MutableGame, Game, MutablePlayer, PlayerInfo, TerraNullius, Tile, PlayerType, Alliance} from "../Game";
|
||||
import {AttackIntent, BoatAttackIntentSchema, GameID, Intent, Turn} from "../Schemas";
|
||||
import {AttackExecution} from "./AttackExecution";
|
||||
import {SpawnExecution} from "./SpawnExecution";
|
||||
@@ -9,6 +9,7 @@ import {UpdateNameExecution} from "./UpdateNameExecution";
|
||||
import {FakeHumanExecution} from "./FakeHumanExecution";
|
||||
import Usernames from '../../../resources/Usernames.txt'
|
||||
import {simpleHash} from "../Util";
|
||||
import {AllianceRequestExecution} from "./AllianceRequestExecution";
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +56,8 @@ export class Executor {
|
||||
intent.name,
|
||||
intent.clientID
|
||||
)
|
||||
} else if (intent.type == "allianceRequest") {
|
||||
return new AllianceRequestExecution(intent.requestor, intent.recipient)
|
||||
} else {
|
||||
throw new Error(`intent type ${intent} not found`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user