mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fixed base merging and limiter creation
This commit is contained in:
parent
6ae103dd63
commit
16f59fb213
@ -35,10 +35,12 @@
|
||||
],
|
||||
"specialty" : {
|
||||
"base" : {
|
||||
"limiter" : {
|
||||
"parameters" : [ "archer", true ],
|
||||
"type" : "CREATURE_TYPE_LIMITER"
|
||||
}
|
||||
"limiters" : [
|
||||
{
|
||||
"parameters" : [ "archer", true ],
|
||||
"type" : "CREATURE_TYPE_LIMITER"
|
||||
}
|
||||
]
|
||||
},
|
||||
"bonuses" : {
|
||||
"attack" : {
|
||||
|
@ -536,14 +536,15 @@ std::vector<std::shared_ptr<Bonus>> SpecialtyInfoToBonuses(const SSpecialtyInfo
|
||||
void CHeroHandler::beforeValidate(JsonNode & object)
|
||||
{
|
||||
//handle "base" specialty info
|
||||
const JsonNode & specialtyNode = object["specialty"];
|
||||
JsonNode & specialtyNode = object["specialty"];
|
||||
if(specialtyNode.getType() == JsonNode::JsonType::DATA_STRUCT)
|
||||
{
|
||||
const JsonNode & base = specialtyNode["base"];
|
||||
if(!base.isNull())
|
||||
{
|
||||
for(auto keyValue : specialtyNode["bonuses"].Struct())
|
||||
JsonUtils::inherit(keyValue.second, base);
|
||||
JsonMap & bonuses = specialtyNode["bonuses"].Struct();
|
||||
for(std::pair<std::string, JsonNode> keyValue : bonuses)
|
||||
JsonUtils::inherit(bonuses[keyValue.first], base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ JsonNode Bonus::toJsonNode() const
|
||||
if(valType != ADDITIVE_VALUE)
|
||||
root["valType"].String() = vstd::findKey(bonusValueMap, valType);
|
||||
if(limiter)
|
||||
root["limiter"] = limiter->toJsonNode();
|
||||
root["limiters"].Vector().push_back(limiter->toJsonNode());
|
||||
if(updater)
|
||||
root["updater"] = updater->toJsonNode();
|
||||
return root;
|
||||
|
Loading…
Reference in New Issue
Block a user