From 2b88e6941c744eb3e4b0bd46630f6a3978f9bd63 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Wed, 11 Oct 2023 01:43:24 +0200 Subject: [PATCH] Fix mana limiter --- lib/rewardable/Info.cpp | 2 +- lib/rewardable/Limiter.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rewardable/Info.cpp b/lib/rewardable/Info.cpp index 6453b9175..b9a8f1b2b 100644 --- a/lib/rewardable/Info.cpp +++ b/lib/rewardable/Info.cpp @@ -112,7 +112,7 @@ void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, CRan limiter.heroLevel = JsonRandom::loadValue(source["heroLevel"], rng) + JsonRandom::loadValue(source["minLevel"], rng); // VCMI 1.1 compatibilty - limiter.manaPercentage = JsonRandom::loadValue(source["manaPercentage"], rng, -1); + limiter.manaPercentage = JsonRandom::loadValue(source["manaPercentage"], rng); limiter.manaPoints = JsonRandom::loadValue(source["manaPoints"], rng); limiter.resources = JsonRandom::loadResources(source["resources"], rng); diff --git a/lib/rewardable/Limiter.cpp b/lib/rewardable/Limiter.cpp index d49ccd550..48328d7a1 100644 --- a/lib/rewardable/Limiter.cpp +++ b/lib/rewardable/Limiter.cpp @@ -27,7 +27,7 @@ Rewardable::Limiter::Limiter() , daysPassed(0) , heroExperience(0) , heroLevel(-1) - , manaPercentage(-1) + , manaPercentage(0) , manaPoints(0) , primary(GameConstants::PRIMARY_SKILLS, 0) { @@ -177,9 +177,9 @@ void Rewardable::Limiter::loadComponents(std::vector & comps, if (heroLevel) comps.emplace_back(Component::EComponentType::EXPERIENCE, 1, heroLevel, 0); - if (manaPoints || manaPercentage >= 0) + if (manaPoints || manaPercentage > 0) { - int absoluteMana = (h->manaLimit() && manaPercentage >= 0) ? (manaPercentage * h->mana / h->manaLimit() / 100) : 0; + int absoluteMana = h->manaLimit() ? (manaPercentage * h->mana / h->manaLimit() / 100) : 0; comps.emplace_back(Component::EComponentType::PRIM_SKILL, 5, absoluteMana + manaPoints, 0); } @@ -223,7 +223,7 @@ void Rewardable::Limiter::serializeJson(JsonSerializeFormat & handler) handler.serializeInt("dayOfWeek", dayOfWeek); handler.serializeInt("daysPassed", daysPassed); resources.serializeJson(handler, "resources"); - handler.serializeInt("manaPercentage", manaPercentage, -1); + handler.serializeInt("manaPercentage", manaPercentage); handler.serializeInt("heroExperience", heroExperience); handler.serializeInt("heroLevel", heroLevel); handler.serializeIdArray("heroes", heroes);