diff --git a/src/damage.cpp b/src/damage.cpp index 49e9a589..b0ceca63 100644 --- a/src/damage.cpp +++ b/src/damage.cpp @@ -8,6 +8,8 @@ #include "damage.hpp" +#include + static status_info_t status_info[int(eStatus::CHARM) + 1] = { {false, 4}, // POISONED_WEAPON {false, 2, 3}, // BLESS_CURSE @@ -46,3 +48,29 @@ const status_info_t& operator* (eStatus status) { const status_info_t& operator* (ePartyStatus status) { return party_status_info[int(status)]; } + +std::pair status_bounds(eStatus which) { + static const std::set allow_negative = { + // The obvious ones: + eStatus::BLESS_CURSE, eStatus::HASTE_SLOW, + // The ones that BoE previously allowed: + eStatus::POISONED_WEAPON, eStatus::POISON, eStatus::ASLEEP, + // (Note: Negative levels of sleep can be obtained from the Hyperactivity spell. The other two never go negative.) + // The additional ones that make sense in the negative: + eStatus::MAGIC_RESISTANCE, eStatus::DUMB, + }; + + int lo = 0, hi = 8; + + if(which == eStatus::MARTYRS_SHIELD) + hi = 10; + else if(which == eStatus::PARALYZED) + hi = 5000; + else if(which == eStatus::FORCECAGE) + hi = 1000; + + if(allow_negative.count(which)) + lo = -hi; + + return std::make_pair(lo, hi); +} \ No newline at end of file diff --git a/src/damage.hpp b/src/damage.hpp index 71f4a010..87e095ad 100644 --- a/src/damage.hpp +++ b/src/damage.hpp @@ -110,6 +110,8 @@ inline bool isDead(eMainStatus stat) { return code > 1 && code < 5; } +std::pair status_bounds(eStatus which); + std::ostream& operator << (std::ostream& out, eStatus e); std::istream& operator >> (std::istream& in, eStatus& e); std::istream& operator >> (std::istream& in, ePartyStatus& type); diff --git a/src/universe/living.cpp b/src/universe/living.cpp index 7b553f76..f6976fa9 100644 --- a/src/universe/living.cpp +++ b/src/universe/living.cpp @@ -8,34 +8,14 @@ #include "living.hpp" -#include #include #include "mathutil.hpp" void iLiving::apply_status(eStatus which, int how_much) { if(!is_alive()) return; - static const std::set allow_negative = { - // The obvious ones: - eStatus::BLESS_CURSE, eStatus::HASTE_SLOW, - // The ones that BoE previously allowed: - eStatus::POISONED_WEAPON, eStatus::POISON, eStatus::ASLEEP, - // (Note: Negative levels of sleep can be obtained from the Hyperactivity spell. The other two never go negative.) - // The additional ones that make sense in the negative: - eStatus::MAGIC_RESISTANCE, eStatus::DUMB, - }; - - int lo = 0, hi = 8; - - if(which == eStatus::MARTYRS_SHIELD) - hi = 10; - else if(which == eStatus::PARALYZED) - hi = 5000; - else if(which == eStatus::FORCECAGE) - hi = 1000; - - if(allow_negative.count(which)) - lo = -hi; + std::pair bounds = status_bounds(which); + int lo = bounds.first, hi = bounds.second; if(which == eStatus::ASLEEP || which == eStatus::DUMB) { // No "wrapping" allowed for these effects.