Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C + + i need help fixing my health system and save health for the next enemy.. I know it deals with my logic and
C i need help fixing my health system and save health for the next enemy..
I know it deals with my logic and how im calling the variables.
The player weapon isn't registering to deal damage.
For example, bosshealth and playerhealth
The Boss weapon does damage, and the player Sword weapon does damage. But when the player attacks it does nothing. The Boss weapon does damage to itself and player, so the output for the boss health is now and player health is So what am i doing wrong? why isn't the player weapon being returned?
character.hpp
class Character
private:
int atk;
int def;
int hp;
public:
virtual void equipEquip equipment;
virtual void attackCharacter target;
virtual void special;
void setattackint newatk atk newatk;
int getattack return atk;
void setdefenseint newdef def newdef;
int getdefense return def;
void sethpint newhp hp newhp;
int gethp return hp;
;
class Player : public Character
private:
Equip currentEquipment;
public:
void equipEquip equipment override
currentEquipment equipment;
setattackcurrentEquipmentgetattackbonus;
setdefensecurrentEquipmentgetdefensebonus;
void attackCharacter target override
bool enemy; logic to determine if target is enemy
int updateHealth;
ifenemy
updateHealth targetgethp targetgetattack;
apply damage to target
targetsethpupdateHealth;
void special override
std::cout "Defualt Implementation
;
;
class Boss : public Character
private:
Equip currentEquipment;
public:
void equipEquip equipment override
currentEquipment equipment;
setattackcurrentEquipmentgetattackbonus;
setdefensecurrentEquipmentgetdefensebonus;
overloading function
equip 'sythe' weapon to boss
void equip
Equip sythe new Sythe;
equipsythe;
delete sythe;
void attackCharacter target override
bool enemy;
int updateHealth;
equip;
ifenemy
updateHealth targetgethp getattack;
targetsethpupdateHealth;
void special override
special attacks go here
std::cout "Defualt Implementation
;
game.cpp
constexpr int PLAYERHEALTH ;
constexpr int BOSSHEALTH ;
void fight
when enemy is found, player can fight or run away...
Player player;
Boss boss;
setting the health to player and enemy
player.sethpPLAYERHEALTH;
boss.sethpBOSSHEALTH;
string response;
int hit;
do
boss.attack&player;
player.attack&boss;
cout Do you want to fight or run away?
;
std::cin response;
ifresponse "fight"
cout ################ endl;
cout "Player Health: player.gethp endl;
cout "Boss Health: boss.gethp endl;
cout ################ endl;
else ifresponse "run"
srandtimeNULL;
hit rand;
if hit
cout
Damage took when escaping: player.gethp endl;
else cout
Took no damage when escaping." endl;
whileplayergethp && player.gethp && response "run";
ifplayergethp cout "Game Over! You Died!" endl; main;
else ifbossgethp cout "Congrats! You Defeated the Boss!" endl;
Thank you in advanced!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started