Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

62 řádky
916 B

#ifndef _2EASY4ME_CHARACTER_H_
#define _2EASY4ME_CHARACTER_H_
#include <cstring>
class Character
{
protected:
char name[16];
int hp;
int att;
int def;
public:
Character(char *name)
{
strncpy(this->name, name, sizeof(this->name));
this->hp = 100;
this->att = 10;
this->def = 5;
}
Character(char *name, int hp, int att, int def)
{
strncpy(this->name, name, sizeof(this->name));
this->hp = hp;
this->att = att;
this->def = def;
}
bool checkDied()
{
return hp <= 0;
}
bool checkAlive()
{
return hp > 0;
}
int defend(int dmg)
{
dmg -= def;
if (dmg > 0)
{
hp -= dmg;
return dmg;
}
else
{
return 0;
}
}
int attack()
{
return att;
}
};
#endif