Question: Game.h #pragma once #include using namespace std; namespace game { struct Hero { string name = ; int healthMax = 5 ; int
Game.h
#pragma once
#include
using namespace std;
namespace game
struct Hero
string name ;
int healthMax ;
int health ;
int defence ;
int attack ;
;
void play;
bool fightHero player;
void levelupHero player;
void attackHero a Hero b;
void showstatsHero hero;
string nameGenerator;
Game.cpp
#include "Game.h
#include
void game::play
Hero player;
cout "Please enter your name: ;
cin.ignore;
getlinecin player.name;
int fightsWon ;
while fight&player true
fightsWon;
if fightsWon
levelup&player;
player.health player.healthMax;
else
cout You've defeated opponents and won the championship!" endl;
void game::levelupHero player
int input;
cout "You've won a fight! Choose an attribute to increase. endl endl;
cout Increase Health by currently playerhealthMax endl;
cout Increase Attack by currently playerattack endl;
cout Increase Defence by currently playerdefence endl;
cin input;
switch input
case :
playerhealthMax ;
break;
case :
playerattack;
break;
case :
playerdefence;
break;
void game::showstatsHero hero
cout hero.name endl;
cout "Health: hero.health endl;
cout "Attacks: hero.attack endl;
cout "Defence: hero.defence endl endl;
bool game::fightHero player
Hero enemy;
enemy.name nameGenerator;
enemy.health rand;
enemy.defence rand;
enemy.attack rand;
cout endl playername faces enemy.name endl;
showstatsplayer;
showstatsenemy;
Main.cpp
#include
#include
#include
#include "Game.h
using namespace std;
int main
srandtimeNULL;
enum State
QUIT
PLAY
HELP
MAINMENU
;
State currentState MAINMENU;
int input;
while currentState QUIT
switch currentState
case MAINMENU:
cout "Welcome What would you like to do endl endl;
cout Play endl endl;
cout Help endl endl;
cout Quit game endl endl;
cin input;
if input input
cout "Invalid input." endl;
else
currentState staticcastinput;
break;
case PLAY:
game::play;
currentState MAINMENU;
break;
case HELP:
cout "How to play" endl;
cout You, and many other heroes, have been selected to compete endl;
cout against each other for sport and glory in a compition endl;
cout for the ages! Name your champion and attempt to defeat five endl;
cout advesaries to win the tournoment. After each victory you endl;
cout will get to enhance one of your abilities. Choose wilsey! endl;
currentState MAINMENU;
break;
return ;
bool game::fightHero player
Hero enemy;
enemy.name "Opponent";
enemy.health rand;
enemy.defence rand;
enemy.attack rand;
cout endl playername "faces" enemy.name endl;
while playerhealth && enemy.health
attackplayer &enemy;
if enemyhealth
attack&enemy, player;
cout endl;
if playerhealth
cout playername "was defeatedd by enemy.name endl endl;
return true;
else
cout playername was defeated by enemy.name endl endl;
return false;
void game::attackHero a Hero b
int roll rand aattack;
cout endl aname attacks bname for roll;
if roll bhealth
bhealth roll bdefence;
if bhealth
cout vanquishing them!";
else
cout bringing bname s health down to bhealth ;
else
cout but they managed to dodge out of the way.";
string game::nameGenerator
string preflix
;
string adjective
"Ultimate"
"Steel"
"Iron"
"Wicked"
"Striking"
"Azure"
"Pink"
"Emerald"
"Crimson"
"Siland"
"Keen"
;
string noun
"Brick"
"Tower"
"One"
"Advercery"
"Warrior"
"Wanderer"
"Fists"
"Professor"
"Contendor"
"Warlock"
;
string name preflixrand;
name adjectiverand;
name nounrand;
return name;
this is my code fix it to match the display in the picture madith
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
