Question: struct Object { std::string name; int strength { 0 } ; int health { 0 } ; } ; Create an object called player. Give
struct Object
std::string name;
int strength;
int health;
;
Create an object called player.
Give it a fun name.
random health normal distribution with mean of and stdev of
random strength normal distribution with mean of and stdev of
make sure health and strength are at least
create a vector of Objects called monsters
random number of monsters uniform between and
name is monster plus the number of the monster.
health & strength same way as player.
Game play:
Loop until the player is dead, or all monsters are dead.
display players name and health, along with each monsters name and health regular for loop
Ask if you want to attack or heal.
healing adds twice the players strength to the health.
attack: choose a monster to attack and subtract your strength from that monsters health.
For monster attack, use a ranged based for loop and use a bernoulli distribution to give the monster a chance to attack. Attacking subtracts the monsters strength from the players health.
When a monster dies, display instead of its health. Dont let players attack a dead monster
Game Over.
Display appropriate message depending on if the player died, the monsters died, or both.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
