Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Note: Global Variables are banned Skills to be Obtained: -Reinforce work with loops, conditional statements, and random numbers. -Implement pass-by-reference (NO GLOBAL VARIABLES

Using C++

Note: Global Variables are banned

Skills to be Obtained:

-Reinforce work with loops, conditional statements, and random numbers.

-Implement pass-by-reference (NO GLOBAL VARIABLES FOR THIS ASSIGNMENT)

-Create and use functions

-Using 1D and 2D arrays

Details: To start the combat off, welcome the player and tell them about the monster they are fighting (be creative!). The monster will start with between 40 and 60 hit points chosen from the array below (HP, determined randomly using a 2D array, not shown to the player). Each turn, the player with choose an action and perform that action, then the monster will attack and deal the player 2-6 damage (determined randomly). The player will start at 25 HP and take one action each turn from the options provided. Loop the game until the monster is defeated, the player is defeated, or the combat ends for another reason.

Monster HP: Make a 2D arrays filled with the following numbers and choose one randomly - you will need 2 random number for the row and column indexes to choose the Monster HP at the start of the game! Remember to roll a separate number for each index in the array.

{40, 45, 47}, {43, 48, 53}, {50, 55, 60},

Game Design: For this homework, you will make a main function that will ask the user which choice they want to take on each turn (they can pick a new option each turn). Using a switch, you will run a difference function based on which choice the user selected (one character/number only for the variable used for the switch). In the switch, each choice the players picks will run a separate function that will perform the action the player choses. You choose which 4 actions the player can choose from the options below. You must include Attack as one of the options. The game will need to loop until the monster is defeated, the player has died, or something else ends the combat. Each round, after the player has taken an action, the monster attacks the player for between 2-6 damage (exact value decided randomly). Do not tell the user how much health of monster has remaining but if the monster has less than 10 HP, you may tell the player the monster is almost dead. At the start of each turn, tell the player how much health the player has and any ongoing effects that are active (ally, poison, etc.).

Pick 6 of the following options (one of which must be Attack). Possible Options:

Attack Send the Monster HP and a random number to a function. In the function, randomly choose a number from the following 1D array and deal that much damage (subtract damage dealt to the monster from the monsters HP). Use pass-by-reference to make sure the variable is changed in both the main and the function. If the player deals any extra damage, be sure to add it to the attack!

Player attack array: {4, 6, 6, 8, 10, 10};

Ally You recruit an ally who distracts the monster so the monster deals 1-3 less damage on the upcoming attack. In addition, after the ally is activated 3 times, it deals the monster 10 damage (this attack happens only once each combat).

Heal gain 3-8 HP. I recommend using pass-by-reference to make this work. The player should not be able to have more than their starting HP. Make to check if their HP is over their max HP and set it to max HP if it is too high.

Befriend Instead of fighting this round, you start to become friends with the monster. Add 1-3 (determined randomly) to a friendship variable that starts at 0. Use a switch inside this function to tell the user how they and the monster are growing closer and once Friendship reaches 10+, end the combat with the player becoming the monsters best friend (with an appropriate ending message). You should have messages for each friendship value from 1-10 (with 10 including number greater than 10).

Capture You have a percent chance to capture the monster. Your odds to capture the monster is the (monsters max HP minus current HP) then divided by their max HP (convert to a number from 0-100 and use random numbers to determine if the monster is caught if it is between 0 and the capture odds determined here). If the monster is caught, end the combat with the player becoming the monsters trainer (with an appropriate ending message).

Dodge You have a 90% of dodging the next monster attack (taking no damage from the attack) and a 10% chance to take damage from the Monster normally. If you dodge successfully, you have a 20% chance to parry dealing 3-8 damage to the monster (determined randomly).

Poison Add 2-5 to the monsters poison stat. At the end of each turn, after the monster attacks the player, the monster suffers damage equal to their poison stats value. Then subtract one from the poison stat (minimum 0).

Item (extra difficult to use) the player chooses one of the following items to use. Each item can be used only once (use a bool array to turn the items on/off). When the item has been used, do not offer that item as an option in the future turns. If you use Item when you have no items left, you have an 80% chance to recover all items instead of using an item that turn:

Potion player heals 15 HP

Nail Bomb deal the monster 10 damage

Mythril Armor Take 1 less damage from monsters for the rest of the fight

Sleep Potion The monster deals no damage for the next 3 turns

Throughout this assignment, make sure the player knows what is happening. Make sure to regularly output what the program is doing to the player. When the player has something special happening (ally, poison, etc.), them at the start of the turn.

Helpful Tips:

-Making the variables in the main and learn how to send them to other functions using pass-by-reference will make this assignment much easier. (Especially since you cannot use global variables)

-When using a switch in the main function, I recommend a structure like this:

Begin the game LOOP{

Begin the turn Switch (control variable)

Case 1: { RUN A FUCTION;

break;

}

Case 2: { RUN A FUCTION;

break;

}

Case 3: { RUN A FUCTION;

break;

}

Case 4: { RUN A FUCTION;

break;

}

(CONTINUE with case 5 and 6)

Default case: error message

End the Switch End the turn }Check the Loop

End the Game

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

6. What is process reengineering? Why is it relevant to training?

Answered: 1 week ago