1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

- Implemented "mapObject" entry for hero classes

- Updated schemas
- Some bugfixing
This commit is contained in:
Ivan Savenko
2014-06-16 19:27:26 +03:00
parent 89b89ff85d
commit 09d595e385
15 changed files with 125 additions and 164 deletions

View File

@@ -91,10 +91,34 @@ void CHeroInstanceConstructor::initTypeData(const JsonNode & input)
{
VLC->modh->identifiers.requestIdentifier("heroClass", input["heroClass"],
[&](si32 index) { heroClass = VLC->heroh->classes.heroClasses[index]; });
filtersJson = input["filters"];
}
void CHeroInstanceConstructor::afterLoadFinalization()
{
for (auto entry : filtersJson.Struct())
{
filters[entry.first] = LogicalExpression<HeroTypeID>(entry.second, [this](const JsonNode & node)
{
return HeroTypeID(VLC->modh->identifiers.getIdentifier("hero", node.Vector()[0]).get());
});
}
}
bool CHeroInstanceConstructor::objectFilter(const CGObjectInstance * object, const ObjectTemplate & templ) const
{
auto hero = dynamic_cast<const CGHeroInstance *>(object);
auto heroTest = [&](const HeroTypeID & id)
{
return hero->type->ID == id;
};
if (filters.count(templ.stringID))
{
return filters.at(templ.stringID).test(heroTest);
}
return false;
}