create alliance request flow

This commit is contained in:
evanpelle
2024-09-17 19:43:45 -07:00
parent 149ffaa026
commit 44877b8e59
8 changed files with 141 additions and 13 deletions
@@ -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
}
}
+4 -1
View File
@@ -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`)
}