1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Data for campaign win/loss conditions. All campaigns should now have

correct conditions.
All custom conditions are now validated using schema.

Note that some of scenarios may not work due to instant win/loss, mostly
because some placeholders fail to import (Mantis #1643)
This commit is contained in:
Ivan Savenko 2014-01-01 13:30:31 +00:00
parent aff704d1ca
commit cd8a0c01e4
3 changed files with 1736 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
{
"type":"object",
"$schema": "http://json-schema.org/draft-04/schema",
"title" : "VCMI map header format",
"description" : "Part of map in json format, defines core settings of the map",
"required": [ "defeatIconIndex", "defeatString", "victoryIconIndex", "victoryString" ],
"additionalProperties" : false,
"properties":{
"defeatIconIndex": {
"type":"number"
},
"defeatString": {
"type":"string"
},
"victoryIconIndex": {
"type":"number"
},
"victoryString": {
"type":"string"
},
"triggeredEvents" : {
"type" : "object",
"additionalProperties" : {
"type" : "object",
"additionalProperties" : "false",
"properties" : {
"required" : [ "condition", "message", "effect" ],
"condition" : { "type" : "array" },
"description" : { "type" : "string" },
"message" : { "type" : "string" },
"effect" : {
"type" : "object",
"additionalProperties" : false,
"required" : [ "type", "messageToSend" ],
"properties" : {
"type" : { "type" : "string" },
"messageToSend" : { "type" : "string" },
}
}
}
}
}
}
}

View File

@ -86,10 +86,22 @@ std::unique_ptr<IMapLoader> CMapService::getMapLoader(std::unique_ptr<CInputStre
}
}
static JsonNode loadPatches(std::string path)
{
JsonNode node = JsonUtils::assembleFromFiles(path);
for (auto & entry : node.Struct())
JsonUtils::validate(entry.second, "vcmi:mapHeader", "patch for " + entry.first);
return node;
}
std::unique_ptr<IMapPatcher> CMapService::getMapPatcher(std::string scenarioName)
{
static JsonNode node;
if (node.isNull())
node = loadPatches("config/mapOverrides.json");
boost::to_lower(scenarioName);
logGlobal->debugStream() << "Request to patch map " << scenarioName;
JsonNode node = JsonUtils::assembleFromFiles("config/mapOverrides.json");
return std::unique_ptr<IMapPatcher>(new CMapLoaderJson(node[scenarioName]));
}