From f92c4ef763bbd3e0d8dc1145121e3af5d3ea16cf Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 14 Oct 2018 13:08:51 +0100 Subject: Add pre-filled cells --- .../input/json-parsing/rules_parser.cpp | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/main/input-output/input/json-parsing/rules_parser.cpp') diff --git a/src/main/input-output/input/json-parsing/rules_parser.cpp b/src/main/input-output/input/json-parsing/rules_parser.cpp index bcff1fd..731ab47 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -280,10 +280,24 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } if (d.HasMember("cells")) { - if (d["cells"].IsInt()) { - sr.cells = static_cast(d["cells"].GetInt()); + if (d["cells"].IsObject()) { + if (d["cells"].HasMember("count")) { + if (d["cells"]["count"].IsInt()) { + sr.cells = static_cast(d["cells"]["count"].GetInt()); + } else { + json_helper::json_parse_err("[cells][count] must be an integer"); + } + } + + if (d["cells"].HasMember("pre-filled")) { + if (d["cells"]["pre-filled"].IsInt()) { + sr.cells_pre_filled = static_cast(d["cells"]["pre-filled"].GetInt()); + } else { + json_helper::json_parse_err("[cells][pre-filled] must be an integer"); + } + } } else { - json_helper::json_parse_err("[cells] must be an integer"); + json_helper::json_parse_err("[cells] must be an object"); } } @@ -606,8 +620,18 @@ string rules_parser::rules_schema_json() { "type": "boolean" }, "cells": { - "type": "integer", - "minimum": 0 + "type": "object", + "properties": { + "count": { + "type": "integer", + "minimum": 0 + }, + "pre-filled": { + "type": "integer", + "minimum": 0 + } + }, + "additionalProperties": false }, "stock": { "type": "object", -- cgit v1.2.1