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{0};
int health{0};
};
Create an object called player.
Give it a fun name.
random health (normal distribution with mean of 30 and stdev of 5)
random strength (normal distribution with mean of 5 and stdev of 1.
make sure health and strength are at least 1
create a vector of Objects called monsters
random number of monsters (uniform between 1 and 3)
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 75% 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!