import GameState from "../../../GameState" ; import PlayerMusteringGameState , { PlayerMusteringType , SerializedPlayerMusteringGameState } from "./player-mustering-game-state/PlayerMusteringGameState" ; import House from "../../game-data-structure/House" ; import { ClientMessage } from "../../../../messages/ClientMessage" ; import Player from "../../Player" ; import { ServerMessage } from "../../../../messages/ServerMessage" ; import IngameGameState from "../../IngameGameState" ; import Game from "../../game-data-structure/Game" ; interface ParentGameState extends GameState < any , any > { game : Game ; ingame : IngameGameState ; onMusteringGameStateEnd ( ) : void ; } export default class MusteringGameState extends GameState < ParentGameState , PlayerMusteringGameState > { get game ( ) : Game { return this . parentGameState . game ; } get ingame ( ) : IngameGameState { return this . parentGameState . ingame ; } firstStart ( ) { this . proceedNextHouse ( ) ; } onPlayerMusteringEnd ( house ) { this . proceedNextHouse ( house ) ; } onPlayerMessage ( player , message ) { this . childGameState . onPlayerMessage ( player , message ) ; } onServerMessage ( _message ) { } proceedNextHouse ( house = null ) { if ( this . game . ironThroneTrack [ this . game . ironThroneTrack . length - 1 ] == house ) { this . parentGameState . onMusteringGameStateEnd ( ) ; return ; } const nextHouse = this . ingame . getNextInTurnOrder ( house ) ; this . setChildGameState ( new PlayerMusteringGameState ( this ) ) . firstStart ( nextHouse , PlayerMusteringType . MUSTERING_WESTEROS_CARD ) ; } serializeToClient ( admin , player ) { return { type : "mustering" , childGameState : this . childGameState . serializeToClient ( admin , player ) } ; } static deserializeFromServer ( parent , data ) { const mustering = new MusteringGameState ( parent ) ; mustering . childGameState = mustering . deserializeChildGameState ( data . childGameState ) ; return mustering ; } deserializeChildGameState ( data ) { return PlayerMusteringGameState . deserializeFromServer ( this , data ) ; } } export interface SerializedMusteringGameState { type : "mustering" ; childGameState : SerializedPlayerMusteringGameState ; }