Scarne's Dice or the game of Pig is a jeopardy dice game where the aim of the player is to score 100 points. Each player’s turn consists of repeatedly rolling a die. After each roll, the player is faced with two choices: roll again, or hold (decline to roll again).
- If the player rolls a 1, the player scores nothing and it becomes the opponent’s turn.
- If the player rolls a number other than 1, the number is added to the player’s turn total and the player’s turn continues.
- If the player holds, the turn total, the sum of the rolls during the turn, is added to the player’s score, and it becomes the opponent’s turn.
The layout consists of three buttons :Roll, Hold and Reset.
- Hold: Clicked by the user when he/she decides to hold
- Roll: Clicked by the user when he/she decides to roll
- Reset: Clicked by the user when the game is over
And there is an imageview to show the dice face which has been rolled.
- roll : handles the roll click events of the user
- hold : handles the hold click events of the user
- computerTurn : handles the computer player of the game
- reset : resets the game
- setComputerOverallScore : sets the computer score after it decides to hold or rolls a 1
- declareWinner : declares the winner of the game