1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +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" "description": "localizable description"
}, },
"effects": { "effects": {
"type": "array", "type": "object",
"items": { "additionalProperties" : {
"$ref" : "vcmi:bonus" "$ref" : "vcmi:bonus"
} }
} }
} }
}, },
"required" : ["basic", "advanced", "expert"], "required" : ["base", "basic", "advanced", "expert"],
"properties": { "properties": {
"base":{
"$ref" : "#/definitions/skillBonus"
},
"basic":{ "basic":{
"$ref" : "#/definitions/skillBonus" "$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 std::string & levelName = NSecondarySkill::levels[level]; // basic, advanced, expert
const JsonNode & levelNode = json[levelName]; const JsonNode & levelNode = json[levelName];
// parse bonus effects // 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; bonus->sid = skill->id;
skill->addNewBonus(bonus, level); skill->addNewBonus(bonus, level);
} }
@@ -198,6 +198,16 @@ void CSkillHandler::afterLoadFinalization()
void CSkillHandler::beforeValidate(JsonNode & object) 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() CSkillHandler::~CSkillHandler()