1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

skills.json uses base and struct for effects

This commit is contained in:
Henning Koehler 2017-08-30 10:25:36 +12:00
parent 3fe9bc34b8
commit 899e8403f7
3 changed files with 458 additions and 674 deletions

View File

@ -18,17 +18,20 @@
"description": "localizable description"
},
"effects": {
"type": "array",
"items": {
"type": "object",
"additionalProperties" : {
"$ref" : "vcmi:bonus"
}
}
}
},
"required" : ["basic", "advanced", "expert"],
"required" : ["base", "basic", "advanced", "expert"],
"properties": {
"base":{
"$ref" : "#/definitions/skillBonus"
},
"basic":{
"$ref" : "#/definitions/skillBonus"
},

File diff suppressed because it is too large Load Diff

View File

@ -147,9 +147,9 @@ CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string &
const std::string & levelName = NSecondarySkill::levels[level]; // basic, advanced, expert
const JsonNode & levelNode = json[levelName];
// parse bonus effects
for(auto b : levelNode["effects"].Vector())
for(auto b : levelNode["effects"].Struct())
{
auto bonus = JsonUtils::parseBonus(b);
auto bonus = JsonUtils::parseBonus(b.second);
bonus->sid = skill->id;
skill->addNewBonus(bonus, level);
}
@ -198,6 +198,16 @@ void CSkillHandler::afterLoadFinalization()
void CSkillHandler::beforeValidate(JsonNode & object)
{
//handle "base" level info
JsonNode & base = object["base"];
auto inheritNode = [&](const std::string & name){
JsonUtils::inherit(object[name], base);
};
inheritNode("basic");
inheritNode("advanced");
inheritNode("expert");
}
CSkillHandler::~CSkillHandler()