Question: write in c++ Write a function with the following signature to simulate one turn of a Pocket Monster attack: void attack(double& attackerHP, double& defenderHP, int
Write a function with the following signature to simulate one turn of a Pocket Monster attack: void attack(double\& attackerHP, double\& defenderHP, int move); Here attackerHP is the current health state for the attacker, and defenderHP is the current health state for the defender. Both input variables have a possible value range from 0.0 to 100.0. The user and the computer will take turns to choose one of the following three moves based on the following value of move: 1. An attack with damage between 15.0 and 30.0 with equal probability to the defender (Bolt of Thunder) 2. An attack with damage between 0.0 and 50.0 with equal probability to the defender (Blast of Fire) 3. Heal an amount between 5.0 and 20.0 with equal probability to the attacker (Heal) Using this function, write a main program that simulates a Pocket Monster battle between the user and the computer. - Initially, both the user and the computer have 100HP. - The user should take the first move, and the function should take the user's choice of move using cin. - If the user entered an invalid option, please ask the user to enter a new choice again until a valid option is entered. - The computer should choose one of the three options with equal probability. - After each attack, a message should be printed out that tells the user what just happened, and how much health the user and computer have. - If a heal leads to a health state over 100.0, the health state will be set to 100.0. - If an attack leads to a health state below 0.0, the health state will be set to 0.0, and the battle ends
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
