1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

vcmi: add UnitOnHex limiter

Bonus will be accepted, if unit stands in listed hexes
This commit is contained in:
Konstantin
2023-03-28 02:14:18 +03:00
parent ffe24627e7
commit 4c08e6a0f9
4 changed files with 61 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include "CGeneralTextHandler.h"
#include "JsonDetail.h"
#include "StringConstants.h"
#include "battle/BattleHex.h"
namespace
{
@ -770,6 +771,17 @@ std::shared_ptr<ILimiter> JsonUtils::parseLimiter(const JsonNode & limiter)
}
return terrainLimiter;
}
else if(limiterType == "UNIT_ON_HEXES") {
auto hexLimiter = std::make_shared<UnitOnHexLimiter>();
if(!parameters.empty())
{
for (const auto & parameter: parameters){
if(parameter.isNumber())
hexLimiter->applicableHexes.insert(BattleHex(parameter.Integer()));
}
}
return hexLimiter;
}
else
{
logMod->error("Error: invalid customizable limiter type %s.", limiterType);