Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (playGame) {
- // Repeat until 1 is rolled or player holds
- while (stillPlaying) {
- // Roll the die
- die.Roll();
- // Check if its not a 1 and add to tally
- if (!(die.GetFaceValue() == 1)) {
- // Display information about the player's current condition
- position += die.GetFaceValue();
- DisplayCondition();
- // Ask player if they want to hold
- if (Hold()) {
- // Add total position to score
- pointsTotal[player] += position;
- position = 0;
- stillPlaying = false;
- }
- } else {
- // Else reset tally to 0
- position = 0;
- DisplayCondition();
- stillPlaying = false;
- }
- }
- // Switch to the computer
- if (player == 0) {
- player = 1;
- } else {
- player = 0;
- }
- // Check to see if the player won
- if (HasWon(player)) {
- // Output winner
- Console.WriteLine("{0} has won.", playersName[player]);
- // Ask to play again
- if (!(ConsoleUtilities.WantToPlayAgain())) {
- playGame = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement