|
|
- #include "src/class/character.hpp"
-
- Character::Character(std::string characterName)
- {
- name = characterName;
- maxHP = 100;
- currentHP = 100;
- atk = 10;
- def = 5;
- }
-
- Character::Character(std::string characterName, int characterMaxHP, int characterAtk, int characterDef)
- {
- name = characterName;
- maxHP = characterMaxHP;
- currentHP = maxHP;
- atk = characterAtk;
- def = characterDef;
- }
-
- bool Character::isDead()
- {
- return currentHP <= 0;
- }
-
- bool Character::isAlive()
- {
- return currentHP > 0;
- }
-
- std::string Character::getName()
- {
- return name;
- }
-
- void Character::restoreHP()
- {
- currentHP = maxHP;
- }
-
- int Character::getCurrentHP()
- {
- return currentHP;
- }
-
- int Character::getMaxHP()
- {
- return maxHP;
- }
-
- int Character::getDef()
- {
- return def;
- }
-
- int Character::getAtk()
- {
- return atk;
- }
-
- int Character::defend(int dmg)
- {
- int cleanDamage = dmg - def;
- if (cleanDamage <= 0)
- {
- return 0;
- }
- else
- {
- currentHP = currentHP - cleanDamage;
- return cleanDamage;
- }
- }
|