Преглед на файлове

Adjust creature schema to detect misconfigured adventure map amounts

Ivan Savenko преди 3 месеца
родител
ревизия
2d00d8a585
променени са 1 файла, в които са добавени 39 реда и са изтрити 6 реда
  1. 39 6
      config/schemas/creature.json

+ 39 - 6
config/schemas/creature.json

@@ -4,15 +4,47 @@
 	"title" : "VCMI creature format",
 	"description" : "Json format for defining new creatures in VCMI",
 	"required" : [ "faction" ],
-	"anyOf" : [
+	"allOf" : [
 		{
-			"disabled" : { "enum" : [ true ] }
+			"if" : {
+				"properties" : {
+					"disabled" : {
+						"const" : false
+					}
+				}
+			},
+			"then" : {
+				"required" : [
+					"name", "level", "cost", "speed", "hitPoints", "attack", "defense", "damage", "fightValue", "aiValue", "graphics", "sound"
+				]
+			}
 		},
 		{
-			"required" : [
-				"name", "level", "cost", "speed", "hitPoints", "attack", "defense", "damage",
-				"fightValue", "aiValue", "advMapAmount", "graphics", "sound"
-			]
+			"if" : {
+				"properties" : {
+					"special" : {
+						"const" : false
+					},
+					"disabled" : {
+						"const" : false 
+					}
+				}
+			},
+			"then" : {
+				"required" : [ "advMapAmount" ],
+				"properties" : {
+					"advMapAmount" : {
+						"type" : "object",
+						"additionalProperties" : false,
+						"description" : "Initial size of random stacks on adventure map",
+						"required" : [ "min", "max" ],
+						"properties" : {
+							"min" : { "type" : "number", "minimum" : 1 },
+							"max" : { "type" : "number", "minimum" : 1 }
+						}
+					}
+				}
+			}
 		}
 	],
 	"additionalProperties" : false,
@@ -80,6 +112,7 @@
 		"damage" : {
 			"type" : "object",
 			"additionalProperties" : false,
+			"required" : [ "min", "max" ],
 			"properties" : {
 				"max" : { "type" : "number" },
 				"min" : { "type" : "number" }