Help! I'm not sure exactly how to get started on this assignment
You have been contracted to write a C++ program for a simple text-based game's battle system. The input to your program will be a file named characterInfo.txt. The file contains five lines in the following format:
The first line represents the hero's name (string), starting health (int), and spell/ability name (string). The second line represents the enemy's name (string), starting health (int), and spell/ability name (string). If any name has two or more words, the words will be connected using underscores. Here are two examples
The second file is invalid because there's a space between "Some" and "Hero". The remaining three lines indicate the minimum and maximum possible damage for the actions the hero and enemy can take. You can assume that the file will always be in the correct format.
After reading the file, the program will open a file for output called battleResults.txt. A message stating the characters' names and starting health will be printed to both the terminal window and the file.
For example,
Next, the program will print out which character's turn it is and their health. Then the program will display a menu with three options representing the actions each character can take. The hero always goes first. For example,
Options 1 and 3 are the same for both characters. Option 2 must include the name of the character's spell or ability. You can use integers (as shown above) or chars (such as 'a' for attack, 's' for spell, and 'p' for potion) for your menu options.
The user will select one of the three options. Use a switch statement to determine which option was selected and take the following action depending on what the user chose:
Attack : Generate a random value between Min_Attack_Damageand Max_Attack_Damage and subtract that value from the other character's health.
Spell / Ability : Generate a random value between Min_Spell/Ability_Damage and Max_Spell/Ability_Damage and subtract that value from the other character's health.
Potion : Generate a random value between Min_Potion and Max_Potion and add that amount to the current character's health. However, a character's current health should never exceed the starting health listed in the file. Also, a character can use a potion a maximum of 3 times. After that, using the potion option should have no effect other than a loss of turn for the current character. Make sure to print a message saying that the character is out of potions in this case.
Regardless of the action selected , you must print out a message describing what happened to both the terminal window and the file . After printing, display the menu again for the other character's turn. See the sample output below.
Continue processing turns until one of the characters has 0 or negative health. Print out an appropriate victory message and exit the program.
Assumptions, Other Requirements and Tips
If the file characterInfo.txt does not exist, print an appropriate .
Unit-IV; Professional Sales Representative (PSR).pptx
Help! I'm not sure exactly how to get started on this assignment You h.docx
1. Help! I'm not sure exactly how to get started on this assignment
You have been contracted to write a C++ program for a simple text-based game's battle system.
The input to your program will be a file named characterInfo.txt. The file contains five lines in
the following format:
The first line represents the hero's name (string), starting health (int), and spell/ability name
(string). The second line represents the enemy's name (string), starting health (int), and
spell/ability name (string). If any name has two or more words, the words will be connected
using underscores. Here are two examples
The second file is invalid because there's a space between "Some" and "Hero". The remaining
three lines indicate the minimum and maximum possible damage for the actions the hero and
enemy can take. You can assume that the file will always be in the correct format.
After reading the file, the program will open a file for output called battleResults.txt. A message
stating the characters' names and starting health will be printed to both the terminal window and
the file.
For example,
Next, the program will print out which character's turn it is and their health. Then the program
will display a menu with three options representing the actions each character can take. The hero
always goes first. For example,
Options 1 and 3 are the same for both characters. Option 2 must include the name of the
character's spell or ability. You can use integers (as shown above) or chars (such as 'a' for attack,
's' for spell, and 'p' for potion) for your menu options.
The user will select one of the three options. Use a switch statement to determine which option
was selected and take the following action depending on what the user chose:
Attack : Generate a random value between Min_Attack_Damageand Max_Attack_Damage and
subtract that value from the other character's health.
Spell / Ability : Generate a random value between Min_Spell/Ability_Damage and
Max_Spell/Ability_Damage and subtract that value from the other character's health.
Potion : Generate a random value between Min_Potion and Max_Potion and add that amount to
the current character's health. However, a character's current health should never exceed the
starting health listed in the file. Also, a character can use a potion a maximum of 3 times. After
that, using the potion option should have no effect other than a loss of turn for the current
character. Make sure to print a message saying that the character is out of potions in this case.
2. Regardless of the action selected , you must print out a message describing what happened to
both the terminal window and the file . After printing, display the menu again for the other
character's turn. See the sample output below.
Continue processing turns until one of the characters has 0 or negative health. Print out an
appropriate victory message and exit the program.
Assumptions, Other Requirements and Tips
If the file characterInfo.txt does not exist, print an appropriate error message and exit the
program. Hint: the ifstream function is_open can help here.
You can assume the file characterInfo.txt is properly formatted and the min values are strictly
less than the max values.
All terminal input must be validated. Print out an appropriate message and prompt the user to try
again if they enter an invalid value. Hint: use the functions provided in the <cctype> header:
http://www.cplusplus.com/reference/cctype/ (Links to an external site.)
Don't forget to close your files when you are done with them!
You must use a switch structure to determine which option was selected.
All messages that detail the results of an action must include the name of the character(s)
involved.
If a character's health changes as the result of an action, the new health value must also be
displayed.
All names of characters and spells will have underscores between words if they contain two or
more words.
Feel free to make the messages as humorous or silly as you want! Beware messages in poor taste
might be frowned upon by the grader.
Test your program with multiple files to make sure it can handle a variety of inputs.
Make good use of white space in your program: vertical spacing, indentation, horizontal spacing,
etc.
You may find it useful to write functions that help you do certain tasks for this program. Make
sure these functions have a clear purpose and do the tasks for a single idea. For example, don't
have one function that prints a main menu, but also does something for a potion, when those
things should each be in their own function.
Formatting, Comments, and Submission Guidelines
3. See Programming Assignment Guidelines. Failure to follow the guidelines will result in a loss of
credit as detailed in said guidelines.
Sample Output
Note: Your output does not have to be formatted exactly like this. As long as all the required
information is displayed, you will get credit for having the correct output. Values in bold were
input by the user.
The corresponding output file battleResults.txt would have the following lines:
Valid File Invalid File
Some_Hero 157 Fireball
Bad_Guy 250 Acid_Bomb
5 25
15 35
20 30
Some Hero 157 Fireball
Bad_Guy 250 Acid_Bomb
5 25
15 35
20 30