public override PD_GameStateBase OnCommand( Random randomness_provider, PD_Game game, PD_Action command) { if (command.GetType() == typeof(PA_DrawNewPlayerCards)) { command.Execute(randomness_provider, game); // conditional checking... bool playerHandIncludesEpidemicCard = game.GQ_SS_CurrentPlayerHandIncludesEpidemicCard(); bool playerHandIsBiggerThanPermitted = game.GQ_SS_CurrentPlayerHandIsBiggerThanPermitted(); if (playerHandIncludesEpidemicCard == true) { return(new PD_GS_ApplyingEpidemicCard()); } else if (playerHandIncludesEpidemicCard == false) { if (playerHandIsBiggerThanPermitted == true) { return(new PD_GS_Discarding_AfterDrawing()); } else if (playerHandIsBiggerThanPermitted == false) { return(new PD_GS_DrawingNewInfectionCards()); } } } return(null); }
public override PD_GameStateBase OnCommand( Random randomness_provider, PD_Game game, PD_Action command ) { if (command.GetType() == typeof(PA_ApplyInfectionCard)) { command.Execute( randomness_provider, game ); // check if game is lost, etc.. if (game.GQ_SS_NotEnoughDiseaseCubestoCompleteAnInfection()) { return(new PD_GS_GameLost()); } if (game.GQ_SS_DeadlyOutbreaks()) { return(new PD_GS_GameLost()); } if (game.GQ_SS_ThereAreActiveInfectionCards()) { return(null); } game.game_state_counter.IncreaseCurrentPlayerIndex(); return(new PD_GS_ApplyingMainPlayerActions()); } return(null); }
public override PD_GameStateBase OnCommand( Random randomness_provider, PD_Game game, PD_Action command) { if (command.GetType() == typeof(PA_Discard_AfterDrawing)) { command.Execute( randomness_provider, game ); // condition checks: bool playerHandBiggerThanPermitted = game.GQ_SS_CurrentPlayerHandIsBiggerThanPermitted(); if (playerHandBiggerThanPermitted == false) { return(new PD_GS_DrawingNewInfectionCards()); } else { return(null); // stay in same state } } return(null); }
public override PD_GameStateBase OnCommand( Random randomness_provider, PD_Game game, PD_Action command) { if (command.GetType() == typeof(PA_DrawNewInfectionCards)) { command.Execute( randomness_provider, game ); return(new PD_GS_ApplyingInfectionCards()); } return(null); }
public override PD_GameStateBase OnCommand( Random randomness_provider, PD_Game game, PD_Action command) { if (command.GetType() == typeof(PA_ApplyEpidemicCard)) { command.Execute( randomness_provider, game ); // condition checks: bool playerHandIncludesEpidemicCard = game.GQ_SS_CurrentPlayerHandIncludesEpidemicCard(); bool playerHandBiggerThanPermitted = game.GQ_SS_CurrentPlayerHandIsBiggerThanPermitted(); if (game.GQ_SS_DeadlyOutbreaks() == true) { return(new PD_GS_GameLost()); } else if (game.GQ_SS_NotEnoughDiseaseCubestoCompleteAnInfection() == true) { return(new PD_GS_GameLost()); } else if (playerHandIncludesEpidemicCard == true) { return(new PD_GS_ApplyingEpidemicCard()); } else if (playerHandBiggerThanPermitted == true) { return(new PD_GS_Discarding_AfterDrawing()); } else { return(new PD_GS_DrawingNewInfectionCards()); } } return(null); }
public override PD_GameStateBase OnCommand( Random randomness_provider, PD_Game game, PD_Action command ) { if (command.GetType() == typeof(PA_Discard_DuringMainPlayerActions)) { command.Execute( randomness_provider, game); bool playerActionsFinished = game.SS_PlayerActionsFinished(); bool allDiseasesCured = game.GQ_SS_AllDiseasesCured(); bool anyPlayerNeedsToDiscard = game.GQ_SS_AnyPlayerHandIsBiggerThanPermitted(); bool enoughPlayerCardsToDraw = game.GQ_SS_EnoughPlayerCardsToDraw(); // stay in same state bool stayAt_Discarding_During_MainPlayerActions = anyPlayerNeedsToDiscard == true; // go back to applying main player actions bool goTo_Applying_MainPlayerActions = playerActionsFinished == false && anyPlayerNeedsToDiscard == false; // proceed to drawing new player cards bool goTo_Drawing_New_PlayerCards = playerActionsFinished == true && anyPlayerNeedsToDiscard == false && enoughPlayerCardsToDraw == true && allDiseasesCured == false; // go to game lost bool goTo_GameLost = playerActionsFinished == true && allDiseasesCured == false && enoughPlayerCardsToDraw == false; // go to game won bool goTo_GameWon = playerActionsFinished == true && allDiseasesCured == true && anyPlayerNeedsToDiscard == false; if (stayAt_Discarding_During_MainPlayerActions) { return(null); // stay in same state } else if (goTo_Applying_MainPlayerActions) { return(new PD_GS_ApplyingMainPlayerActions()); } else if (goTo_Drawing_New_PlayerCards) { return(new PD_GS_DrawingNewPlayerCards()); } else if (goTo_GameLost) { return(new PD_GS_GameLost()); } else if (goTo_GameWon) { return(new PD_GS_GameWon()); } else { throw new System.Exception("something wrong here..."); } } else { throw new System.Exception("something wrong here"); } }
public override PD_GameStateBase OnCommand( Random randommness_provider, PD_Game game, PD_Action command) { command.Execute( randommness_provider, game ); game.game_state_counter.IncreasePlayerActionIndex(); // after executing a main player action: bool playerActionsFinished = game.SS_PlayerActionsFinished(); bool allDiseasesCured = game.GQ_SS_AllDiseasesCured(); bool anyPlayerNeedsToDiscard = game.GQ_SS_AnyPlayerHandIsBiggerThanPermitted(); bool enoughPlayerCardsToDraw = game.GQ_SS_EnoughPlayerCardsToDraw(); bool stayAt_Applying_MainPlayerActions = playerActionsFinished == false && anyPlayerNeedsToDiscard == false; bool goTo_DrawingNewPlayerCards = playerActionsFinished == true && anyPlayerNeedsToDiscard == false && enoughPlayerCardsToDraw == true && allDiseasesCured == false; bool goTo_Discarding_During_MainPlayerActions = anyPlayerNeedsToDiscard == true; bool goTo_GameLost = playerActionsFinished == true && allDiseasesCured == false && enoughPlayerCardsToDraw == false; bool goTo_GameWon = playerActionsFinished == true && allDiseasesCured == true && anyPlayerNeedsToDiscard == false; if (stayAt_Applying_MainPlayerActions) { return(null); } else if (goTo_DrawingNewPlayerCards) { return(new PD_GS_DrawingNewPlayerCards()); } else if (goTo_Discarding_During_MainPlayerActions) { return(new PD_GS_Discarding_DuringMainPlayerActions()); } else if (goTo_GameLost) { game.game_state_counter.insufficient_player_cards_to_draw = true; return(new PD_GS_GameLost()); } else if (goTo_GameWon) { return(new PD_GS_GameWon()); } else { throw new System.Exception("something wrong here"); } }