2
0
Эх сурвалжийг харах

- VCMI will now read templates from mods
- Added partial schema for RMG template

DjWarmonger 10 жил өмнө
parent
commit
2e70d8a084

+ 0 - 0
config/rmg.json → Mods/vcmi/Mods/defaultTemplates/Content/config/defaultTemplates/rmg.json


+ 12 - 0
Mods/vcmi/Mods/defaultTemplates/mod.json

@@ -0,0 +1,12 @@
+{
+	"name" : "Default templates",
+	"description" : "A set of random map templates for VCMI",
+
+	"version" : "0.99",
+	"author" : "VCMI Team",
+	"contact" : "http://forum.vcmi.eu/index.php",
+	"modType" : "Templates",
+	"templates" : [
+		"config/defaultTemplates/rmg"
+	],
+}

+ 63 - 0
config/schemas/template.json

@@ -0,0 +1,63 @@
+{
+
+	"type":"object",
+	"$schema": "",
+
+	"title" : "VCMI random map template format",
+	"description" : "Format used to define random map templates in VCMI",
+
+
+	"definitions" :
+	{
+		"zone":{
+			"type": "object",
+			"required" : ["type", "monsters", "size", "level"],
+			"properties":{
+				"type":{"$ref" : "#/definitions/type"},
+				"size":{"$ref" : "#/definitions/size"},			
+				"playerTowns":{"$ref" : "#/definitions/playerTowns"},				
+				"neuralTowns":{"$ref" : "#/definitions/neuralTowns"},
+				"townsAreSameType":{"$ref" : "#/definitions/townsAreSameType"},
+				"monsters":{"$ref" : "#/definitions/monsters"},
+				"mines":{"$ref" : "#/definitions/mines"},
+				"treasure":{
+					"type":"array",
+					"items":{
+						"type": "object",
+						"properties":{
+							"min": {"type":"number", "minimum" : 0},
+							"max": {"type":"number", "minimum" : 0},
+							"density": {"type":"number", "minimum" : 1}
+						},					
+						"additionalProperties" : false						
+					}
+				}				
+			}		
+		},
+		"type" :{
+			"type" : "object",
+			"enum": ["playerStart", "treasure", "junction"]
+			"additionalProperties" : false
+			"type":"string"
+		},
+		"size":{
+			"type": "number",
+			"minimum": 1,
+			"additionalProperties" : false,
+		}
+	},
+
+	"properties":
+	{
+		"zones":{
+			"type": "array",
+			"items":{"$ref" : "#/definitions/zone"	}						
+		},
+		"connections":{
+			"type": "array",
+			"items":{"$ref" : "#/definitions/connection"}	
+		}
+		"required" : ["zones", "connections"],
+		"additionalProperties" : false
+	}
+}

+ 1 - 0
lib/CModHandler.cpp

@@ -385,6 +385,7 @@ CContentHandler::CContentHandler()
 	handlers.insert(std::make_pair("objects", ContentTypeHandler(VLC->objtypeh, "object")));
 	handlers.insert(std::make_pair("heroes", ContentTypeHandler(VLC->heroh, "hero")));
 	handlers.insert(std::make_pair("spells", ContentTypeHandler(VLC->spellh, "spell")));
+	handlers.insert(std::make_pair("templates", ContentTypeHandler((IHandlerBase *)VLC->tplh, "template")));
 
 	//TODO: any other types of moddables?
 }

+ 2 - 0
lib/GameConstants.h

@@ -942,6 +942,8 @@ enum class ESpellSchool: ui8
 	EARTH 	= 3
 };
 
+ID_LIKE_OPERATORS_DECLS(SpellID, SpellID::ESpellID)
+
 // Typedef declarations
 typedef ui8 TFaction;
 typedef si64 TExpType;

+ 2 - 2
lib/VCMI_Lib.cpp

@@ -115,12 +115,12 @@ void LibClasses::init()
 
 	createHandler(terviewh, "Terrain view pattern", pomtime);
 
+	createHandler(tplh, "Template", pomtime); //templates need already resolved identifiers (refactor?)
+
 	logGlobal->infoStream()<<"\tInitializing handlers: "<< totalTime.getDiff();
 
 	modh->load();
 
-	createHandler(tplh, "Template", pomtime); //templates need already resolved identifiers (refactor?)
-
 	modh->afterLoad();
 
 	//FIXME: make sure that everything is ok after game restart