Background: In homework #9 you created some object classes necessary for a program that would play Jumanji. Now its time to write a program to actually play the game. Warning!: If you play this game too many times, you will turn into a rhino....if you haven't already.

Note: Some specifications have changed since homework #9, so read everything carefully!

So here is how the game is played. Each player starts at position 0 of his/her path. The objective is to get to position 41 of the path. The first player to make it there should shout out JUMANJI! and will be proclaimed the winner! But, alas, there are dangers along the journey, some that are life-threatening. You start the game with 5 lives, and there are situations in which you can lose a life. If you get down to 0 lives, you're dead, and you're out of the game (i.e., you should no longer be considered one of the participating players). Of course, if everyone dies before anyone reaches position 41, the game should end with no one being declared a winner. And, if everyone dies except for one player, the game should also end, with no one being declared a winner.

Each player takes a turn rolling an 8-sided die, moving his/her game piece on the board that many spaces, and doing whatever action that space of his/her path specifies. As we explained in homework #9, each players path is different. But each path contains one of 4 different kinds of entries: BLANK, WAIT_FOR_5_OR_8, JUNGLE, or RHINO. Actually, there is a 5th kind of entry that only occurs in position 41 of each player's path; that entry is JUMANJI. The paths are created with the random distribution of entry types described in hw #9. Note: The entry in position 0 of each player's path should be BLANK.

If you land on a BLANK, do the following:

  • Draw the next available card from the deck. Output the riddle that is on the card, and randomly say some exclamation like OMG!, Egads!, etc., followed by the answer to the riddle that is on the card Its a ...!(e.g., snake, herd of rhinos, etc.). Make up your own list of such exclamations and choose randomly from that list. You can implement that as a file or any other way.
  • Have all players roll the rescue die. If all players match the rescue string that is on the card that was drawn, then you have been saved. Otherwise, repeat this step a total of at most 50 times trying to get everyone to match the rescue string. Note: An hourglass rescue symbol is like a wildcard; it will match anything.
  • If that step resulted in a match, your game piece stays put on its path. But each of the other players gets to move their game piece forward as many spaces as the number that was on the card. They do NOT follow the directions for the space of the path that they move to.
  • If that did not result in a match, your game piece moves backward as many spaces as the number that was on the card. You do NOT follow the directions for the space of the path that you move to. The other players do not move. You also lose 1 of your lives.

If you land on a WAIT_FOR_5_OR_8 space, do the following:

  • Roll the 8-sided die again. If you get a 5 or an 8, your turn is done. Otherwise, move backwards one position; do NOT follow the directions for the space of the path that you move to.
  • Repeat this until you get a 5 or an 8, or until you're back to position 0 of your path.

If you land on a JUNGLE space, do the following:

  • Draw the next available card from the deck. Output the riddle that is on the card, and randomly say some exclamation like "OMG!", "Egads", etc., followed by the answer to the riddle that is on the card "It's a ...!" (e.g., "snake", "herd of rhinos", etc).
  • Have all the players roll the rescue die. If all the players match the 'rescue' string that is on the card that was drawn, then you have been saved. Otherwise, repeat this step a total of at most 50 times trying to get everyone to match the rescue string. Note: An hourglass rescue symbol is like a wildcard; it will match anything.
  • If that resulted in a match, everyone (including you) gets to move their game piece forward as many spaces as the number that was on the card. No one follows the directions for the space of the path they move to.
  • If that did not result in a match, repeat the process again, starting with drawing the next available card from the deck. Do this at most 3 times. If no match occurs after 3 times, everyone loses 1 life and your turn is over.

If you land on a RHINO space, do the following:

  • On your next turn, you must roll an even number on the 8-sided die in order to move forward. This rule applies for all future rolls until you have moved off that rhino. If you roll an odd number, you dont get to move during that turn. An exception to this is if you are currently on position 40 of your path and there is a RHINO in that position. Since only a roll of 1 is viable for you at this point in the game, you cant be expected to roll an even number on your next turn; thus, you are exempt from the rhinos rule.
  • Being "stuck on a rhino" can be canceled by being moved off that rhino as a result of someone else's move, e.g. you are advanced because someone else had bad luck with a card.

There are some other important rules of the game that must be observed:

  • Although each player has his/her own path, some players paths intersect: (1) the green players path intersects with the red players path at position 23 and intersects with the orange players path at position 32, (2) the red players path intersects with the blue players path at position 23 and intersects with the green players path at position 32, (3) the blue players path intersects with the orange players at position 23 and intersects with the red players path at 32, and (4) the orange players path intersects with the green players path at position 23 and intersects with the blue players path at position 32. If two players intersect at a particular position, those two players cannot both occupy that same position at the same time. For example, if the green player is currently at position 23 of his/her path and the red player tries to move to position 23 of his/her path, the red player should not be allowed to do so because there would be a collision of sorts. How you should handle this particular example is to just not move the red player; the red player cant move there until the green player eventually vacates that position or until the red player tries to move to some other position.
  • As you approach the final position in the path (i.e., position 41), you cannot overshoot it. For example, if you are currently in position 40, you have to wait until you roll a 1. If you roll a number that is larger than what you need, you must stay in your current position, and wait for your next turn to try to roll the exact amount you need. And this rule applies no matter how you get to within striking distance of spot 41.
  • If you have to move backwards n spaces and that would cause you to go off the board, then only go to position 0.
  • If you have to move forwards n spaces and that would cause you to go off the board, then don't move at all.
  • If you have to move (forwards or backwards - sideways is NOT an option) n space and that would make you intersect with another player (as described above), then do not move at all.
  • Specifications: You are expected to appropriately extend the Card, CardDeck, Path, and Player classes that you created for homework #9 to implement the functionality described above. You are welcome to create new classes as well. The only particular functionality that we specifically require of you for this assignment (in order to make sure that you get experience with certain C++ concepts) are listed below:
  • Overload (and appropriately use!) either + and - (or += and - =) for the Path class (or Player class) to change the current position on the path a particular number of spaces.
  • Overload (and appropriately use!) = = for the Path (or Player) class to determine if one player's path intersects with another player's path.

When you cssubmit, play the game with 4 players: BoJack, Todd, Mr. Peanutbutter, and yourself. Let the users pick whichever of the 4 game piece colors they want (but no 2 players can have the same color). Your program should output what is going on throughout the game; dont make the output excessive just enough so we can follow what is happening. Be sure to make it clear when a player dies and is no longer in the game.

Note: You are going to find that doing arithmetic with "regular" int-types and unsigned ints will result in unsigned ints. You may possibly generate errors/warnings signaling this issue. You may address this issue by using ONLY ints in this assignment, and abandoning the unsigned int spec without penalty. Also note, the data file has changed.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.