Selaa lähdekoodia

Json validation for battle effects

Ivan Savenko 3 kuukautta sitten
vanhempi
sitoutus
87555c600d
1 muutettua tiedostoa jossa 230 lisäystä ja 2 poistoa
  1. 230 2
      config/schemas/spell.json

+ 230 - 2
config/schemas/spell.json

@@ -148,8 +148,236 @@
 			]
 		},
 		"battleEffect" : {
-			"type" : "object"
-			// TODO
+			"type" : "object",
+			"required" : [ "type" ],
+			"properties" : {
+				"type" : {
+					"type" : "string",
+					"enum" : [ 
+						"core:catapult",
+						"core:clone",
+						"core:damage",
+						"core:demonSummon",
+						"core:dispel",
+						"core:heal",
+						"core:moat",
+						"core:obstacle",
+						"core:removeObstacle",
+						"core:sacrifice",
+						"core:summon",
+						"core:teleport",
+						"core:timed"
+					]
+				},
+				"indirect" : { "type" : "boolean" },
+				"optional" : { "type" : "boolean" }
+			},
+			"allOf" : [
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:catapult" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"targetsToAttack" : { "type" : "number" },
+							"chanceToHitKeep" : { "type" : "number" },
+							"chanceToHitGate" : { "type" : "number" },
+							"chanceToHitTower" : { "type" : "number" },
+							"chanceToHitWall" : { "type" : "number" },
+							"chanceToNormalHit" : { "type" : "number" },
+							"chanceToCrit" : { "type" : "number" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:clone" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"maxTier" : { "type" : "number" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:damage" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"killByPercentage" : { "type" : "boolean" },
+							"killByCount" : { "type" : "boolean" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:demonSummon" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"id" : { "type" : "string" },
+							"permanent" : { "type" : "boolean" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:dispel" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"dispelPositive" : { "type" : "boolean" },
+							"dispelNegative" : { "type" : "boolean" },
+							"dispelNeutral" : { "type" : "boolean" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "enum" : [ "core:heal", "core:sacrifice" ] } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"healLevel" : { "type" : "string" },
+							"healPower" : { "type" : "string" },
+							"minFullUnits" : { "type" : "number" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:moat" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"hidden" : { "type" : "boolean" },
+							"trap" : { "type" : "boolean" },
+							"removeOnTrigger" : { "type" : "boolean" },
+							"dispellable" : { "type" : "boolean" },
+							"moatDamage" : { "type" : "number" },
+							"moatHexes" : {  },
+							"triggerAbility" : { "type" : "string" },
+							"defender" : {  },
+							"bonus" : { "additionalProperties" : { "$ref" : "bonusInstance.json" } }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:obstacle" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"hidden" : { "type" : "boolean" },
+							"passable" : { "type" : "boolean" },
+							"trap" : { "type" : "boolean" },
+							"removeOnTrigger" : { "type" : "boolean" },
+							"hideNative" : { "type" : "boolean" },
+							"patchCount" : { "type" : "number" },
+							"turnsRemaining" : { "type" : "number" },
+							"triggerAbility" : { "type" : "string" },
+							"attacker" : {  },
+							"defender" : {  },
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:removeObstacle" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"removeAbsolute" : { "type" : "boolean" },
+							"removeUsual" : { "type" : "boolean" },
+							"removeAllSpells" : { "type" : "boolean" },
+							"removeSpells" : {  }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:summon" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"id" : { "type" : "string" },
+							"permanent" : { "type" : "boolean" },
+							"exclusive" : { "type" : "boolean" },
+							"summonByHealth" : { "type" : "boolean" },
+							"summonSameUnit" : { "type" : "boolean" },
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:teleport" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"triggerObstacles" : { "type" : "boolean" },
+							"isWallPassable" : { "type" : "boolean" },
+							"isMoatPassable" : { "type" : "boolean" }
+						},
+						"additionalProperties" : false
+					}
+				},
+				{ 
+					"if" : { "properties" : { "type" : { "const" : "core:timed" } } },
+					"then" : {
+						"properties" : {
+							"type" : {},
+							"indirect" : {},
+							"optional" : {},
+							"ignoreImmunity" : { "type" : "boolean" },
+							"chainLength" : { "type" : "number" },
+							"chainFactor" : { "type" : "number" },
+							"cumulative" : { "type" : "boolean" },
+							"bonus" : { "additionalProperties" : { "$ref" : "bonusInstance.json" } }
+						},
+						"additionalProperties" : false
+					}
+				},
+			]
 		},
 		"flags" : {
 			"type" : "object",