diff options
Diffstat (limited to 'src/main/input-output/input/json-parsing')
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
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<uint8_t>(d["cells"].GetInt()); + if (d["cells"].IsObject()) { + if (d["cells"].HasMember("count")) { + if (d["cells"]["count"].IsInt()) { + sr.cells = static_cast<uint8_t>(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<uint8_t>(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", |
