コード例 #1
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 //Start player turn (before player input)
 public void PlayerTurn()
 {
     //Update Computer Hand
     //UpdateHandImages(computerHand, false);
     //check game state (returns false if no longer running)
     if (CheckGameState())
     {
         //retrieve playable cards from hand
         playerPlayableCards = Crazy_Eight_Game.CheckPlayable(playerHand, topCard);
         //if playable card is present, deny draw. If not, allow draw and prompt the user to draw.
         if (playerPlayableCards.Count() != 0)
         {
             allowDraw = false;
             output    = "Your turn. \nSelect a card to discard. \n(You have at least one)";
             UpdateInstructions();
         }
         else
         {
             //Check pass status
             CheckPass();
             if (playerPass)
             {
                 output = "Your hand is full, you cannot draw anymore cards. \nPassing your turn...";
                 UpdateInstructions();
                 NextTurn();
             }
             else
             {
                 //permit draw card
                 output = "You have no cards to discard. \nDraw a card";
                 UpdateInstructions();
                 allowDraw = true;
             }
         }
     }
     else
     {
         //end game
         EndGame();
     }
 }
コード例 #2
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 //Computer turn
 public void ComputerTurn()
 {
     //Update Player Hand
     //UpdateHandImages(playerHand, true);
     //check game state (returns false if no longer running)
     if (CheckGameState())
     {
         //retrieve playable cards from hand
         computerPlayableCards = Crazy_Eight_Game.CheckPlayable(computerHand, topCard);
         //if playable card is present, discard a card. If not, draw a card if possible.
         if (computerPlayableCards.Count() != 0)
         {
             //get card based on computer rules of play and discard it
             Card playCard = Crazy_Eight_Game.ComputerDecision(computerPlayableCards, topCard);
             DiscardCard(computerHand, playCard);
         }
         else
         {
             //check pass status
             CheckPass();
             if (computerPass)
             {
                 //computer pass, trigger next turn
                 NextTurn();
             }
             else
             {
                 //permit draw card
                 DrawCard(computerHand);
             }
         }
     }
     else
     {
         //end game
         EndGame();
     }
 }