Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. while (playGame) {
  2.                 // Repeat until 1 is rolled or player holds
  3.                 while (stillPlaying) {
  4.                     // Roll the die
  5.                     die.Roll();
  6.  
  7.                     // Check if its not a 1 and add to tally
  8.                     if (!(die.GetFaceValue() == 1)) {
  9.                         // Display information about the player's current condition
  10.                         position += die.GetFaceValue();
  11.                         DisplayCondition();
  12.                        
  13.                         // Ask player if they want to hold
  14.                         if (Hold()) {
  15.                             // Add total position to score
  16.                             pointsTotal[player] += position;
  17.                             position = 0;
  18.                             stillPlaying = false;
  19.                         }
  20.                        
  21.                     } else {
  22.                         // Else reset tally to 0
  23.                         position = 0;
  24.                         DisplayCondition();
  25.                         stillPlaying = false;                        
  26.                     }
  27.                 }
  28.  
  29.                 // Switch to the computer
  30.                 if (player == 0) {
  31.                     player = 1;
  32.                 } else {
  33.                     player = 0;
  34.                 }
  35.  
  36.                 // Check to see if the player won
  37.                 if (HasWon(player)) {
  38.                     // Output winner
  39.                     Console.WriteLine("{0} has won.", playersName[player]);
  40.  
  41.                     // Ask to play again
  42.                     if (!(ConsoleUtilities.WantToPlayAgain())) {
  43.                         playGame = false;
  44.                     }
  45.                 }
  46.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement