Skip to content
Permalink
Browse files
Fixing getters and setters
  • Loading branch information
wlodarsb committed Mar 4, 2019
1 parent 7fe8d1f commit 3edd14f543c2cfec7c66247c020a3847a60af9bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
@@ -27,11 +27,11 @@ class Hero
int GetMP();
int GetSPD();
int GetDEF();
void SetHP(int _HP);
void SetSP(int _SP);
void SetMP(int _MP);
void SetSPD(int _SPD);
void SetDEF(int _DEF);
void DealDMG(int dmg);
void TakeSP(int amount);
void TakeMP(int amount);
void SetSPD(int speed);
void SetDEF(int defence);
friend ostream& operator<<( ostream&, const Hero&);
};

@@ -60,11 +60,19 @@ int Hero::GetMP() {return MP;}
int Hero::GetSPD() {return SPD;}
int Hero::GetDEF() {return DEF;}

void Hero::SetHP(int _HP) {HP = _HP;}
void Hero::SetSP(int _SP) {SP = _SP;}
void Hero::SetMP(int _MP) {MP = _MP;}
void Hero::SetSPD(int _SPD) {SPD = _SPD;}
void Hero::SetDEF(int _DEF) {DEF = _DEF;}
void Hero::DealDMG(int dmg) {HP = dmg * ((100-DEF)/100);}
void Hero::TakeSP(int amount)
{
SP -= amount;
if(SP < 0) SP = 0;
}
void Hero::TakeMP(int amount)
{
MP -= amount;
if(MP < 0) MP = 0;
}
void Hero::SetSPD(int speed) {SPD = speed;}
void Hero::SetDEF(int defence) {DEF = defence;}

ostream& operator<<( ostream& os, const Hero& hero )
{

0 comments on commit 3edd14f

Please sign in to comment.