mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Somewhat configurable spell schools
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "../GameLibrary.h"
|
||||
#include "../IGameSettings.h"
|
||||
#include "spells/SpellSchoolHandler.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@@ -59,22 +60,18 @@ bool BonusValueCache::hasBonus() const
|
||||
|
||||
MagicSchoolMasteryCache::MagicSchoolMasteryCache(const IBonusBearer * target)
|
||||
:target(target)
|
||||
,schools(LIBRARY->spellSchoolHandler->getAllObjects().size() + 1)
|
||||
{}
|
||||
|
||||
void MagicSchoolMasteryCache::update() const
|
||||
{
|
||||
static const CSelector allBonusesSelector = Selector::type()(BonusType::MAGIC_SCHOOL_SKILL);
|
||||
static const std::array schoolsSelector = {
|
||||
Selector::subtype()(SpellSchool::ANY),
|
||||
Selector::subtype()(SpellSchool::AIR),
|
||||
Selector::subtype()(SpellSchool::FIRE),
|
||||
Selector::subtype()(SpellSchool::WATER),
|
||||
Selector::subtype()(SpellSchool::EARTH),
|
||||
};
|
||||
|
||||
auto list = target->getBonuses(allBonusesSelector);
|
||||
for (int i = 0; i < schoolsSelector.size(); ++i)
|
||||
schools[i] = list->valOfBonuses(schoolsSelector[i]);
|
||||
schools[0] = list->valOfBonuses(Selector::subtype()(SpellSchool::ANY));
|
||||
|
||||
for (int i = 1; i < schools.size(); ++i)
|
||||
schools[i] = list->valOfBonuses(Selector::subtype()(SpellSchool(i-1)));
|
||||
|
||||
version = target->getTreeVersion();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user