// Public interface public CGameState Clone_By_Observer( EPersistenceID observer, bool is_admin ) { CGameState game_state = new CGameState(); // Unconditional cloning game_state.CurrentTurnIndex = CurrentTurnIndex; game_state.Mode = Mode; DiscardPiles.FullClone( game_state.m_DiscardPiles ); m_TurnSequence.ShallowCopy( game_state.m_TurnSequence ); foreach ( var side_pair in m_CardCollections ) { Dictionary< ECardColor, CCardCollection > collection_dictionary = new Dictionary< ECardColor, CCardCollection >(); game_state.m_CardCollections.Add( side_pair.Key, collection_dictionary ); side_pair.Value.FullClone( collection_dictionary ); } // Conditional cloning m_PlayerHands.VarClone( game_state.m_PlayerHands, n => ( is_admin || observer == n.Key ) ? EGameStateClonePermission.Full : EGameStateClonePermission.Hidden ); game_state.m_Deck = m_Deck.Clone( is_admin ? EGameStateClonePermission.Full : EGameStateClonePermission.Hidden ) as CDeck; return game_state; }
public CMatchInstance( EMatchInstanceID id, CLobbyState lobby_state ) { GameState = new CGameState( lobby_state.GameMode ); GameState.Initialize_Game( lobby_state.Players ); MatchState = new CMatchState( id, lobby_state.GameMode, lobby_state.GameCount ); MatchState.Initialize_Match( lobby_state.Players ); MatchState.Add_Observers( lobby_state ); }
// Construction public CMatchInstance( EMatchInstanceID id, EPersistenceID player1, EPersistenceID player2, uint game_count ) { GameState = new CGameState( EGameModeType.Two_Players ); List< EPersistenceID > players = new List< EPersistenceID >(); players.Add( player1 ); players.Add( player2 ); GameState.Initialize_Game( players ); MatchState = new CMatchState( id, EGameModeType.Two_Players, game_count ); MatchState.Initialize_Match( players ); }
// Construction public CClientMatchInstance( CMatchState match_state, CGameState game_state ) : base(match_state, game_state) { }
public void Apply( CGameState game_state ) { CPlayerHand hand = game_state.Get_Player_Hand( PlayerID ); switch ( DeltaType ) { case ECardDelta.Add: hand.Add_Card( new CCard( Color, CardValue ) ); break; case ECardDelta.Remove: hand.Remove_Card( Color, CardValue ); break; } }
public void Apply( CGameState game_state ) { game_state.CurrentTurnIndex = NewTurnIndex; }
// Construction public CMatchNewGameMessage( CGameState game_state ) : base() { GameState = game_state; }
// Construction public CJoinMatchSuccess( CMatchState match_state, CGameState game_state ) : base() { MatchState = match_state; GameState = game_state; }
public void Apply( CGameState game_state ) { CCardCollection collection = game_state.Get_Card_Collection( Side, Color ); collection.Add_Card( new CCard( Color, Value ) ); }
private static void Build_Match_Message_Samples( List< CNetworkMessage > message_list ) { List< EPersistenceID > player_list = new List< EPersistenceID >(); player_list.Add( (EPersistenceID) 2 ); player_list.Add( (EPersistenceID) 3 ); CMatchState match_state = new CMatchState( (EMatchInstanceID) 1, EGameModeType.Two_Players, 3 ); match_state.Initialize_Match(player_list ); CGameState game_state = new CGameState( EGameModeType.Two_Players ); game_state.Initialize_Game( player_list ); message_list.Add( new CJoinMatchSuccess( match_state, game_state ) ); message_list.Add( new CMatchPlayerLeftMessage( (EPersistenceID) 5, EMatchRemovalReason.Player_Request ) ); message_list.Add( new CMatchPlayerConnectionStateMessage( (EPersistenceID) 11, true ) ); message_list.Add( new CLeaveMatchRequest() ); message_list.Add( new CLeaveMatchResponse( (EMessageRequestID) 2, ELeaveMatchFailureError.Not_In_Match ) ); message_list.Add( new CMatchTakeTurnRequest( new CPlayCardGameAction( new CCard( ECardColor.Green, ECardValue.Four ) ), new CDrawFromDiscardGameAction( ECardColor.Red ) ) ); message_list.Add( new CMatchTakeTurnResponse( (EMessageRequestID) 5, EGameActionFailure.Card_Is_Not_In_Your_Hand ) ); List< IObservedClonableDelta > deltas = new List< IObservedClonableDelta >(); deltas.Add( new CCardCollection.CCardCollectionDelta( EGameSide.Side2, ECardColor.Blue, ECardValue.Eight ) ); deltas.Add( new CDeck.CDeckDelta() ); deltas.Add( new CDiscardPile.CDiscardPileDelta( ECardDelta.Add, ECardColor.White, ECardValue.Multiplier2 ) ); deltas.Add( new CGameState.CGameStateDelta( 2 ) ); deltas.Add( new CPlayerHand.CPlayerHandDelta( (EPersistenceID)6, ECardDelta.Remove, ECardColor.Yellow, ECardValue.Two ) ); message_list.Add( new CMatchDeltaSetMessage( deltas ) ); List< CAbstractMatchDelta > match_deltas = new List< CAbstractMatchDelta >(); match_deltas.Add( new CSideMatchStats.CSideMatchStatsDelta( EGameSide.Side2, 132, 2, 3, 2 ) ); message_list.Add( new CMatchStateDeltaMessage( match_deltas ) ); message_list.Add( new CContinueMatchRequest( true ) ); message_list.Add( new CContinueMatchResponse( (EMessageRequestID) 5, EContinueMatchFailure.Cannot_Change_Previous_Commitment ) ); message_list.Add( new CMatchNewGameMessage( game_state ) ); }
public void Apply( CGameState game_state ) { CDeck deck = game_state.Get_Deck(); deck.Remove_Card(); }
public void Apply( CGameState game_state ) { CDiscardPile pile = game_state.Get_Discard_Pile( Color ); switch ( DeltaType ) { case ECardDelta.Add: pile.Add_Card( new CCard( Color, Value ) ); break; case ECardDelta.Remove: pile.Remove_Card(); break; } }
public CMatchInstance( CMatchState match_state, CGameState game_state ) { GameState = game_state; MatchState = match_state; }
// Protected Interface protected virtual void Start_New_Game() { GameState = new CGameState( GameState.Mode ); GameState.Initialize_Game( MatchState.Players ); MatchState.Halt_Match( EMatchInstanceState.Idle ); }
public void Initialize_New_Game( CGameState game_state ) { GameState = game_state; }