The following is a list of topics we wish to address with this assignment:
Background: Jumanji is a game for those who wish to find a way to leave their world behind. Adventurers should beware; the exciting consequences of the game will vanish only when a player has reached Jumanji and called out its name! Wow. In homework #9 you will create object classes necessary for a program that will allow users to actually play Jumanji in homework #10.
In this game, there can be 2-4 players. At the beginning of the game each player will be expected to enter his/her name and choose the color of his/her game piece (red, green, blue, or orange); note that no two players can have the same colored game piece. Each player will also have a number of lives, which, in the game, can be lost!
The game board consists of winding, albeit linear, paths through a jungle. Each player will have his/her own path. There are 42 spaces on a path, numbered from 0 to 41. Each space on a path will contain 1 of 4 different kinds of entries: blank, wait for 5 or 8, jungle, or rhino. Each players path can be different. You will have to randomly create each users path according to the following specifications: there should be 5 randomly positioned wait for 5 or 8 entries, 3 randomly positioned jungle entries, and 7 randomly positioned rhino entries; all other positions should be blank.
The game also has a single deck of (at most 50) cards that the players will draw from throughout the game. Each card contains 4 things: a positive integer that will determine how many spaces a player can move along his/her path, a riddle (of at most 128 characters) about the danger they are encountering, a string (of at most 25 characters) identifying what the danger is (in case they cant solve the riddle!), and a string (of at most 20 characters) describing what will rescue them from this danger (e.g., axe). Before the players can start the game, you must create the deck of cards by reading information about the cards from a data file (cards.dat) into an array and then shuffling the deck (i.e., array) of cards; there are many ways to do that (think about it). Each line of card information in the data file contains the 4 entries for that card as described above, with each entry separated by a tab; this is called a tab-separated file. The last line in the file contains a single entry of -1, which signals the end of the data; this is called a sentinel file.
There is one other important part of the game. The players will have to roll a rescue die (die is singular for dice). It has 8 sides which are respectively labeled: "axe", "die", "open door", "racquet", "raft", "rope", "saber", and "hourglass". Not coincidentally, these are the same rescue strings that can appear on the cards.
Specifications: Here are descriptions of the classes we want you to create:
card class:
Member variables:
Member functions:
cardDeck class:
Member variables:
Member functions:
path class:
Member variables:
Member functions:
player class:
Member variables:
Member functions:
Note: You can create additional member functions for each of these classes and you can create additional classes. But you must create the things listed above. Also, for the insertion ops, make them so that the information fits on one line if possible. For the path, you might shoot for this format as an example:
path:
13 : rhino
14 : wait for 5 or 8
17 : jungle
-- etc -- (leave out specifying blanks)
There is a LOT of code that we are NOT specifying for you. It is up to you how you want to implement what's going on here. Be cool...and write good code!
Now, in order to test your homework #9 functionality, we want you to write your main() function as a driver (as previously discussed). Specifically, your main( ) should do the following:
1. Prompt for and get input for the names of 4 players. For testing purposes, use BoJack, Todd, Mr. Peanutbutter, and your own name. Let the players pick whatever colors (red, green, blue, or orange) they want for their game pieces but remember that no two players can have the same color.
2. Initialize a Player object for each of the 4 players and output all their information including their paths. Note: For a path, you don't have to output the entries for all 42 spaces; just output what is in the non-BLANK entries.
3. Initialize and output the shuffled deck of cards. Output everything that is on each card.
4. Do the following 3 times:
Have each player (in the order they were originally entered) do the following:
a. Roll a 6-sided die (i.e., sides are numbered 1-6).
b. Move that many spaces forward on the player's path.
c. Output what entry that space of the path has on it (i.e., blank, wait for 5 or 8, jungle, or rhino).
d. Select the next available card from the deck and output the info that is on it.
e. Roll the rescue die and output what label it shows.
f. Tell whether the rescue die label matches the rescue string on the card.
We might point out that you should not open this file with an editor you don't know really well. Some editors can change a file simply by opening it. As stated, the "fields" of this data file are tab-character delimited. You don't want to risk messing that up.