mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Added validation of flaggable objects
This commit is contained in:
64
config/schemas/flaggable.json
Normal file
64
config/schemas/flaggable.json
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"type" : "object",
|
||||||
|
"$schema" : "http://json-schema.org/draft-04/schema",
|
||||||
|
"title" : "VCMI map object format",
|
||||||
|
"description" : "Description of map object class",
|
||||||
|
"required" : [ "message" ],
|
||||||
|
"anyOf" : [ //NOTE: strictly speaking, not required - buidling can function without it, but won't do anythin
|
||||||
|
{
|
||||||
|
"required" : [ "bonuses" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"required" : [ "dailyIncome" ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"additionalProperties" : false,
|
||||||
|
|
||||||
|
"properties" : {
|
||||||
|
"bonuses" : {
|
||||||
|
"type" : "object",
|
||||||
|
"description" : "List of bonuses provided by this map object. See bonus format for more details",
|
||||||
|
"additionalProperties" : { "$ref" : "bonus.json" }
|
||||||
|
},
|
||||||
|
|
||||||
|
"message" : {
|
||||||
|
"description" : "Message that will be shown to player on capturing this object",
|
||||||
|
"anyOf" : [
|
||||||
|
{
|
||||||
|
"type" : "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type" : "number",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"dailyIncome" : {
|
||||||
|
"type" : "object",
|
||||||
|
"additionalProperties" : false,
|
||||||
|
"description" : "Daily income that this building provides to owner, if any",
|
||||||
|
"properties" : {
|
||||||
|
"gold" : { "type" : "number"},
|
||||||
|
"wood" : { "type" : "number"},
|
||||||
|
"ore" : { "type" : "number"},
|
||||||
|
"mercury" : { "type" : "number"},
|
||||||
|
"sulfur" : { "type" : "number"},
|
||||||
|
"crystal" : { "type" : "number"},
|
||||||
|
"gems" : { "type" : "number"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Properties that might appear since this node is shared with object config
|
||||||
|
"compatibilityIdentifiers" : { },
|
||||||
|
"blockedVisitable" : { },
|
||||||
|
"removable" : { },
|
||||||
|
"aiValue" : { },
|
||||||
|
"index" : { },
|
||||||
|
"base" : { },
|
||||||
|
"name" : { },
|
||||||
|
"rmg" : { },
|
||||||
|
"templates" : { },
|
||||||
|
"battleground" : { },
|
||||||
|
"sounds" : { }
|
||||||
|
}
|
||||||
|
}
|
@@ -10,14 +10,19 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "FlaggableInstanceConstructor.h"
|
#include "FlaggableInstanceConstructor.h"
|
||||||
|
|
||||||
#include "../json/JsonBonus.h"
|
#include "../CConfigHandler.h"
|
||||||
#include "../texts/CGeneralTextHandler.h"
|
|
||||||
#include "../VCMI_Lib.h"
|
#include "../VCMI_Lib.h"
|
||||||
|
#include "../json/JsonBonus.h"
|
||||||
|
#include "../json/JsonUtils.h"
|
||||||
|
#include "../texts/CGeneralTextHandler.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
void FlaggableInstanceConstructor::initTypeData(const JsonNode & config)
|
void FlaggableInstanceConstructor::initTypeData(const JsonNode & config)
|
||||||
{
|
{
|
||||||
|
if (settings["mods"]["validation"].String() != "off")
|
||||||
|
JsonUtils::validate(config, "vcmi:flaggable", getJsonKey());
|
||||||
|
|
||||||
for (const auto & bonusJson : config["bonuses"].Struct())
|
for (const auto & bonusJson : config["bonuses"].Struct())
|
||||||
providedBonuses.push_back(JsonUtils::parseBonus(bonusJson.second));
|
providedBonuses.push_back(JsonUtils::parseBonus(bonusJson.second));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user