From 77b43093c7b157e8ff0b68af4efd0eff226da35a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 2 May 2021 10:12:49 -0400 Subject: Added damage and heal commands --- src/creature.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/creature.cc') diff --git a/src/creature.cc b/src/creature.cc index 88b26e7..e1f2b61 100644 --- a/src/creature.cc +++ b/src/creature.cc @@ -104,6 +104,13 @@ namespace creature { } } + void Creature::applyHealing(int amount) { + hp += amount; + if(hp > hpMax) { + hp = hpMax; + } + } + int Creature::getSkillBonus(const rules::Skill& skill) const { int bonus = this->getBonus(skill.getAbility()); if(skills.contains(skill)) { @@ -150,7 +157,13 @@ namespace creature { } void Creature::setScore(const rules::Ability& ability, int score) { + int initBonus = getBonus(ability); stats.insert({ability, score}); + if(ability == rules::Ability::Con()) { + int delta = getBonus(ability) - initBonus; + hpMax += delta * hdCount; + hp += delta * hdCount; + } } void Creature::setProfLevel(const rules::Skill& skill, int level) { -- cgit v1.2.3