// This is schema for checking game settings from settings.json
// Any new settings should be added in this file for correct serialization and initialization
{
	"type" : "object",
	"$schema": "http://json-schema.org/draft-04/schema",
	"required" : [ "general", "video", "adventure", "battle", "server", "logging", "launcher" ],
	"definitions" : {
		"logLevelEnum" : { 
			"type" : "string", 
			"enum" : [ "trace", "debug", "info", "warn", "error" ]
		}
	},
	"additionalProperties" : false,
	"properties":
	{
		"general" : {
			"type" : "object",
			"default": {},
			"additionalProperties" : false,
			"required" : [ "playerName", "showfps", "music", "sound", "encoding" ],
			"properties" : {
				"playerName" : {
					"type":"string",
					"default" : "Player"
				},
				"showfps" : {
					"type" : "boolean",
					"default" : false
				},
				"music" : {
					"type" : "number",
					"default" : 88
				},
				"sound" : {
					"type" : "number",
					"default" : 88
				},
				"encoding" : {
					"type" : "string",
					"default" : "CP1252"
				}
			}
		},
		"video" : {
			"type" : "object",
			"additionalProperties" : false,
			"default": {},
			"required" : [ "screenRes", "bitsPerPixel", "fullscreen", "spellbookAnimation","driver", "showIntro" ],
			"properties" : {
				"screenRes" : {
					"type" : "object",
					"additionalProperties" : false,
					"required" : [ "width", "height" ],
					"properties" : {
						"width"  : { "type" : "number" },
						"height" : { "type" : "number" }
					},
					"default": {"width" : 800, "height": 600 }
				},
				"bitsPerPixel" : {
					"type" : "number",
					"default" : 32
				},
				"fullscreen" : {
					"type" : "boolean",
					"default" : false
				},
				"showIntro" : {
					"type" : "boolean",
					"default" : true
				},
				"spellbookAnimation" :  {
					"type" : "boolean",
					"default" : true
				},
				"driver":{
					"type" : "string",
					"default" : "opengl",
					"description" : "preferred graphics backend driver name for SDL2"
				}
			}
		},
		"adventure" : {
			"type" : "object",
			"additionalProperties" : false,
			"default": {},
			"required" : [ "heroSpeed", "enemySpeed", "scrollSpeed", "heroReminder", "quickCombat" ],
			"properties" : {
				"heroSpeed" : {
					"type" : "number",
					"default" : 2
				},
				"enemySpeed" : {
					"type" : "number",
					"default" : 2
				},
				"scrollSpeed" : {
					"type" : "number",
					"default" : 1
				},
				"heroReminder" : {
					"type" : "boolean",
					"default" : true
				},
				"quickCombat" : {
					"type" : "boolean",
					"default" : false
				}
			}
		},
		"battle" : {
			"type" : "object",
			"additionalProperties" : false,
			"default": {},
			"required" : [ "animationSpeed", "mouseShadow", "cellBorders", "stackRange", "showQueue" ],
			"properties" : {
				"animationSpeed" : {
					"type" : "number",
					"default" : 0.63
				},
				"mouseShadow" : {
					"type":"boolean",
					"default" : true
				},
				"cellBorders" : {
					"type" : "boolean",
					"default" : false
				},
				"stackRange" : {
					"type" : "boolean",
					"default" : true
				},
				"showQueue" : {
					"type" : "boolean",
					"default" : true
				}
			}
		},
		"server" : {
			"type" : "object",
			"additionalProperties" : false,
			"default": {},
			"required" : [ "server", "port", "localInformation", "playerAI", "neutralAI" ],
			"properties" : {
				"server" : {
					"type":"string",
					"default" : "127.0.0.1"
				},
				"port" : {
					"type" : "number",
					"default" : 3030
				},
				"localInformation" : {
					"type" : "number",
					"default" : 2
				},
				"playerAI" : {
					"type" : "string",
					"default" : "VCAI"
				},
				"neutralAI" : {
					"type" : "string",
					"default" : "StupidAI"
				}
			}
		},
		"logging" : {
			"type" : "object",
			"additionalProperties" : false,
			"default" : {},
			"required" : [ "console", "file", "loggers" ],
			"properties" : {
				"console" : {
					"type" : "object",
					"default" : {},
					"required" : [ "format", "threshold", "coloredOutputEnabled", "colorMapping" ],
					"properties" : {
						"format" : {
							"type" : "string",
							"default" : "%m"
						},
						"threshold" : {
							"$ref" : "#/definitions/logLevelEnum",
							"default" : "info"
						},
						"coloredOutputEnabled" : {
							"type" : "boolean",
							"default" : true
						},
						"colorMapping" : {
							"type" : "array",
							"default" : [
								{ "domain" : "global", "level" : "trace", "color" : "gray"},
								{ "domain" : "global", "level" : "debug", "color" : "white"},
								{ "domain" : "global", "level" : "info", "color" : "green"},
								{ "domain" : "global", "level" : "warn", "color" : "yellow"},
								{ "domain" : "global", "level" : "error", "color" : "red"}
							],
							"items" : {
								"type" : "object",
								"additionalProperties" : false,
								"default" : {},
								"required" : [ "domain", "level", "color" ],
								"properties" : {
									"domain" : { "type" : "string" },
									"level" : { "$ref" : "#/definitions/logLevelEnum" },
									"color" : { "type" : "string", "enum" : [ "default", "green", "red", "magenta", "yellow", "white", "gray", "teal" ] }
								}
							}
						}
					}
				},
				"file" : {
					"type" : "object",
					"additionalProperties" : false,
					"default" : {},
					"required" : [ "format" ],
					"properties" : {
						"format" : {
							"type" : "string",
							"default" : "%d %l %n [%t] - %m"
						}
					}
				},
				"loggers" : {
					"type" : "array",
					"default" : [ { "domain" : "global", "level" : "trace" } ],
					"items" : {
						"type" : "object",
						"additionalProperties" : false,
						"required" : [ "level", "domain" ],
						"properties" : {
							"domain" : { "type" : "string" },
							"level" : { "$ref" : "#/definitions/logLevelEnum" }
						}

					}
				}
			}
		},
		"launcher" : {
			"type" : "object",
			"default": {},
			"additionalProperties" : false,
			"required" : [ "repositoryURL", "enableInstalledMods", "autoCheckRepositories" ],
			"properties" : {
				"repositoryURL" : {
					"type" : "array",
					"default" : [
						"http://download.vcmi.eu/mods/repository/repository.json"
					],
					"items" : {
						"type" : "string"
					},
				},
				"enableInstalledMods" : {
					"type" : "boolean",
					"default" : true
				},
				"autoCheckRepositories" : {
					"type" : "boolean",
					"default" : true
				}
			}
		}
	}
}
