diff options
author | Your Name <you@example.com> | 2022-01-03 16:25:45 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2022-01-03 16:25:45 -0500 |
commit | 3f78a7e1647ba94129236bd2bf4fc855c109628a (patch) | |
tree | 0a1538d44715738c8cbbae00bf1995777227b963 /src/creature.cc | |
parent | d222c5a39943ed9f83f11d63a42bdff4978179af (diff) | |
download | dmtool-3f78a7e1647ba94129236bd2bf4fc855c109628a.tar.gz dmtool-3f78a7e1647ba94129236bd2bf4fc855c109628a.tar.bz2 dmtool-3f78a7e1647ba94129236bd2bf4fc855c109628a.zip |
Added command to force a saving throw
Diffstat (limited to 'src/creature.cc')
-rw-r--r-- | src/creature.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/creature.cc b/src/creature.cc index f48888c..6491024 100644 --- a/src/creature.cc +++ b/src/creature.cc @@ -115,6 +115,17 @@ namespace creature { } } + int Creature::saveOrDamage(const rules::Ability& ability, int DC, int amount, const std::string& type, const std::vector<rules::Qualifier>& qualifiers, bool saveHalves) { + // TODO: Something about evasion + int rolled = dice::roll(20) + getAbilitySaveBonus(ability); + if(rolled >= DC and saveHalves) { + applyDamage(amount/2, type, qualifiers); + } else if(rolled < DC) { + applyDamage(amount, type, qualifiers); + } + return rolled; + } + void Creature::applyHealing(int amount) { data->hp += amount; if(data->hp > data->hpMax) { |