diff options
author | Your Name <you@example.com> | 2021-05-02 10:12:49 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-02 10:12:49 -0400 |
commit | 77b43093c7b157e8ff0b68af4efd0eff226da35a (patch) | |
tree | af051e78ebe6c26ea373b50fb266935e0b51f9fa /src/creature.cc | |
parent | 9e6936d325751a7e0670e8cc6aa61faf048cb241 (diff) | |
download | dmtool-77b43093c7b157e8ff0b68af4efd0eff226da35a.tar.gz dmtool-77b43093c7b157e8ff0b68af4efd0eff226da35a.tar.bz2 dmtool-77b43093c7b157e8ff0b68af4efd0eff226da35a.zip |
Added damage and heal commands
Diffstat (limited to 'src/creature.cc')
-rw-r--r-- | src/creature.cc | 13 |
1 files changed, 13 insertions, 0 deletions
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) { |