Remove custom erase_if function in favor of std::remove_if
It was originally added before I understood the correct way to use remove_if As a side-effect, remove bad status now also removes forcecage and charm.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "living.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include "mathutil.hpp"
|
||||
|
||||
void iLiving::apply_status(eStatus which, int how_much) {
|
||||
@@ -46,21 +47,24 @@ void iLiving::apply_status(eStatus which, int how_much) {
|
||||
}
|
||||
|
||||
void iLiving::clear_bad_status() {
|
||||
status[eStatus::POISON] = 0;
|
||||
if(status[eStatus::BLESS_CURSE] < 0)
|
||||
status[eStatus::BLESS_CURSE] = 0;
|
||||
if(status[eStatus::HASTE_SLOW] < 0)
|
||||
status[eStatus::HASTE_SLOW] = 0;
|
||||
status[eStatus::WEBS] = 0;
|
||||
status[eStatus::DISEASE] = 0;
|
||||
if(status[eStatus::DUMB] > 0)
|
||||
status[eStatus::DUMB] = 0;
|
||||
if(status[eStatus::ASLEEP] > 0)
|
||||
status[eStatus::ASLEEP] = 0;
|
||||
status[eStatus::PARALYZED] = 0;
|
||||
status[eStatus::ACID] = 0;
|
||||
if(status[eStatus::MAGIC_RESISTANCE] < 0)
|
||||
status[eStatus::MAGIC_RESISTANCE] = 0;
|
||||
std::map<eStatus, short> old;
|
||||
status.swap(old);
|
||||
std::remove_copy_if(old.begin(), old.end(), std::inserter(status, status.begin()), [](std::pair<const eStatus, short> kv) {
|
||||
return isStatusNegative(kv.first) ? kv.second > 0 : kv.second < 0;
|
||||
});
|
||||
}
|
||||
|
||||
void iLiving::clear_brief_status() {
|
||||
std::map<eStatus, short> old;
|
||||
status.swap(old);
|
||||
std::remove_copy_if(old.begin(), old.end(), std::inserter(status, status.begin()), [](std::pair<const eStatus, short> kv) -> bool {
|
||||
if(kv.first == eStatus::POISON) return false;
|
||||
if(kv.first == eStatus::DISEASE) return false;
|
||||
if(kv.first == eStatus::DUMB) return false;
|
||||
if(kv.first == eStatus::ACID && kv.second > 2)
|
||||
return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void iLiving::void_sanctuary() {
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
virtual int get_shared_dmg(int base_dmg) const = 0; // And this goes with the above.
|
||||
|
||||
virtual void apply_status(eStatus which, int how_much);
|
||||
virtual void clear_brief_status();
|
||||
virtual void clear_bad_status();
|
||||
virtual void void_sanctuary();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user