Exemple #1
0
 public static void AddGame(WinState outcome)
 {
     totalGames++;
     switch (outcome.Outcome)
     {
         case Outcome.Win:
             humanWins++;
             break;
         case Outcome.Tie:
             ties++;
             break;
         case Outcome.Loss:
             computerWins++;
             break;
     }
 }
Exemple #2
0
 private static WinState Rules(Hand playerOne, Hand playerTwo)
 {
     WinState oneBeatsTwo = new WinState();
     if (playerOne == playerTwo)
     {
         oneBeatsTwo.Outcome = Outcome.Tie;
         oneBeatsTwo.Message = GameMessages.tie;
     }
     else
     {
         switch (playerOne)
         {
             case Hand.Rock:
                 switch (playerTwo)
                 {
                     case Hand.Paper:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.paperVRock;
                         break;
                     case Hand.Scissors:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.rockVScissors;
                         break;
                     case Hand.Lizard:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.rockVLizard;
                         break;
                     case Hand.Spock:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.spockVRock;
                         break;
                 }
                 break;
             case Hand.Paper:
                 switch (playerTwo)
                 {
                     case Hand.Rock:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.paperVRock;
                         break;
                     case Hand.Scissors:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.scissorsVPaper;
                         break;
                     case Hand.Lizard:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.lizardVPaper;
                         break;
                     case Hand.Spock:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.paperVSpock;
                         break;
                 }
                 break;
             case Hand.Scissors:
                 switch (playerTwo)
                 {
                     case Hand.Rock:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.rockVScissors;
                         break;
                     case Hand.Paper:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.scissorsVPaper;
                         break;
                     case Hand.Lizard:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.scissorsVLizard;
                         break;
                     case Hand.Spock:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.spockVScissors;
                         break;
                 }
                 break;
             case Hand.Lizard:
                 switch (playerTwo)
                 {
                     case Hand.Rock:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.rockVLizard;
                         break;
                     case Hand.Paper:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.lizardVPaper;
                         break;
                     case Hand.Scissors:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.scissorsVLizard;
                         break;
                     case Hand.Spock:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.lizardVSpock;
                         break;
                 }
                 break;
             case Hand.Spock:
                 switch (playerTwo)
                 {
                     case Hand.Rock:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.spockVRock;
                         break;
                     case Hand.Paper:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.paperVSpock;
                         break;
                     case Hand.Scissors:
                         oneBeatsTwo.Outcome = Outcome.Win;
                         oneBeatsTwo.Message = GameMessages.spockVScissors;
                         break;
                     case Hand.Lizard:
                         oneBeatsTwo.Outcome = Outcome.Loss;
                         oneBeatsTwo.Message = GameMessages.lizardVSpock;
                         break;
                 }
                 break;
         }
     }
     return oneBeatsTwo;
 }