1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-03 14:52:11 +02:00

Workaround for starting map with invalid witch huts

This commit is contained in:
Ivan Savenko 2023-11-26 18:56:26 +02:00
parent 81a48f2d80
commit 68de34e508

View File

@ -1162,18 +1162,24 @@ CGObjectInstance * CMapLoaderH3M::readWitchHut(const int3 & position, std::share
allowedAbilities.insert(SecondarySkill(skillID));
}
JsonVector anyOfList;
for (auto const & skill : allowedAbilities)
{
JsonNode entry;
entry.String() = VLC->skills()->getById(skill)->getJsonKey();
anyOfList.push_back(entry);
}
JsonNode variable;
variable["anyOf"].Vector() = anyOfList;
variable.setMeta(ModScope::scopeGame()); // list may include skills from all mods
if (allowedAbilities.size() == 1)
{
variable.String() = VLC->skills()->getById(*allowedAbilities.begin())->getJsonKey();
}
else
{
JsonVector anyOfList;
for (auto const & skill : allowedAbilities)
{
JsonNode entry;
entry.String() = VLC->skills()->getById(skill)->getJsonKey();
anyOfList.push_back(entry);
}
variable["anyOf"].Vector() = anyOfList;
}
variable.setMeta(ModScope::scopeGame()); // list may include skills from all mods
rewardable->configuration.presetVariable("secondarySkill", "gainedSkill", variable);
}
return object;