Requirement
For this project, you will implement a JavaFX-based two-player (human vs. computer) version of the dice game called Cosmic Wimpout. You will need to use many or all of the techniques covered in class this semester, like arrays, classes, inheritance and polymorphism, and GUI programming.
Cosmic Wimpout is played with five six-sided dice. Four of these dice have the following values printed on their faces: 10, 2, 3, 4, 5, 6. The fifth die is called the “Sun” die, and has the image of a star (the “Flaming Sun”) in place of the 3. Thus, its faces have the values 10, 2, *(sun), 4, 5, and 6. The sun is treated as a wild value; that is, it may be substituted for any other face value. During a player’s turn, he rolls all five of these dice.
Play follows the official rules:
- The players agree on a game goal, usually 300 or 500 points (this is known as the Winning Total). The first player to exceed this score wins the game.
- Each player rolls one of the regular dice (not the “Sun” die). The player who rolls the highest face value goes first (10 beats 6). If a tie occurs, the tied players roll again.
When it becomes a player’s turn, he begins by rolling all five dice, and counts up the score for that roll: - Five matching faces are called a Freight Train. A Freight Train is worth a number of points equal to 100 times the face showing on any one die. For example, a Freight Train consisting of five 4’s is worth 400 points.
- If a player rolls five sixes, he automatically wins the game.
- Too Many Points: Rolling five 10’s (a Supernova) automatically knocks a player out of the game.
Three matching faces on the same throw are called a flash, and are worth 10 points times the face value. For example, three 5’s are worth 50 points. - If the “Flaming Sun” comes up, it can be used to form the third value in a flash, or it can be treated as a 5 or a 10 for the purposes of scoring. If a Flaming Sun is rolled along with a pair of any other values, the Flaming Sun MUST be used to form a flash.
5’s and 10’s that do not form part of a flash are worth 5 or 10 points, respectively. - If a player rolls something other than numbers (5 or 10), flashes, or a Freight Train, he is said to have wimped out, and loses his turn. He does not gain any points for that turn.
- If a player rolls anything that will earn him points during a turn (a 5 or 10 on one or more dice, or a flash, or a freight train), he may set aside those dice and re-roll the remaining dice to accumulate more points. He may continue to re-roll and accumulate points until he either wimps out (losing all points for the turn) or chooses to stop voluntarily.
- A player officially enters the game when he gets 35 or more points on his first roll. Until a player enters the game, he does not accumulate any points from rolling the dice. Your program should announce when each player enters the game.
You May Not Want To But You Must: If a player scores with all five dice, he must continue his turn and roll all five dice again. He continues to accumulate points until he either wimps out or scores with four or fewer dice. - The Futtless Rule: All flashes must be cleared. To clear a flash (three of a kind), a player must re-roll all non-scoring dice. If one or more of the re-rolled dice match the dice that make up the flash, the player must repeat the re-roll until none of them match the flash value.
- The current player may voluntarily end his turn whenever he rolls and does not wimp out, except when he has fewer than 35 points or is subject to the “You May Not Want To But You Must” rule or the Futtless Rule. When a player ends his turn without wimping out, he adds his accumulated points to his total.
12。 Last Licks: When a player reaches the Winning Total, each of the other players receives one last roll, which they must use to attempt to catch up in terms of points.
Your program should use JavaFX to present an appealing user interface for the game (focus on implementing a text-based version of the game first, then add the GUI at the end).
Example
A player rolls1
5 10 3 4 2
The 5 and 10 are scoring dice, so they are set aside (for a total of 15 points so far). The player chooses to re-roll the remaining three dice, obtaining:1
10 10 4
(Note that this does not create a flash, since three 10s were not rolled at the same time)
Now the player chooses to stop (he has not wimped out, since he rolled at least one scoring die), and take his 35 points for the turn.
Suppose the current player rolls1
5 3 5 * 4
This creates a flash worth 50 points (the Flaming Sun counts as the third 5 for the purposes of the flash). This flash must be cleared, so the player re-rolls the 3 and 4, getting:1
2 5
Since the 5 duplicates the flash that was just rolled, both dice must be re-rolled:1
10 3
This clears the flash (since the player didn’t roll a 5 this time), but 3 is a non-scoring value (remember that only 5 and 10 count as scoring values outside of a flash or freight train). As a result, the player has wimped out, and will not earn any points for this turn.
Grading Rubric
This program is worth a total of 40 points, broken down as follows:
- Game correctly plays one turn by the human player - 10 points
- Game correctly plays one turn by the computer - 10 points
- Game correctly plays to completion - 10 points
- Graphical User Interface - 10 points