1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Additional properties for limiter

This commit is contained in:
nordsoft
2023-10-09 04:19:12 +02:00
parent 937a8d63c7
commit 6a7b23c007
6 changed files with 105 additions and 4 deletions

View File

@@ -16,6 +16,7 @@
#include "../mapObjects/CGHeroInstance.h"
#include "../serializer/JsonSerializeFormat.h"
#include "../constants/StringConstants.h"
#include "../CHeroHandler.h"
#include "../CSkillHandler.h"
#include "../ArtifactUtils.h"
@@ -112,6 +113,16 @@ bool Rewardable::Limiter::heroAllowed(const CGHeroInstance * hero) const
return false;
}
if(!players.empty() && !vstd::contains(players, hero->getOwner()))
return false;
if(!heroes.empty() && !vstd::contains(heroes, hero->type->getId()))
return false;
if(!heroClasses.empty() && !vstd::contains(heroClasses, hero->type->heroClass->getId()))
return false;
for(const auto & sublimiter : noneOf)
{
if (sublimiter->heroAllowed(hero))
@@ -143,6 +154,9 @@ void Rewardable::Limiter::serializeJson(JsonSerializeFormat & handler)
handler.serializeInt("manaPercentage", manaPercentage);
handler.serializeInt("heroExperience", heroExperience);
handler.serializeInt("heroLevel", heroLevel);
handler.serializeIdArray("hero", heroes);
handler.serializeIdArray("heroClass", heroClasses);
handler.serializeIdArray("color", players);
handler.serializeInt("manaPoints", manaPoints);
handler.serializeIdArray("artifacts", artifacts);
handler.enterArray("creatures").serializeStruct(creatures);