From 3f78a7e1647ba94129236bd2bf4fc855c109628a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 3 Jan 2022 16:25:45 -0500 Subject: Added command to force a saving throw --- src/creature.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/creature.cc') 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& 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) { -- cgit v1.2.3