diff options
| author | Charlie Blake | 2018-10-14 15:06:44 +0100 |
|---|---|---|
| committer | GitHub | 2018-10-14 15:06:44 +0100 |
| commit | 247fba9d4cefc511aebec4d494ce7659ac31beb5 (patch) | |
| tree | e2a941215006fecf4bd0379e3b6dbf7494ed0720 /src/main/input-output/input/json-parsing | |
| parent | Merge pull request #98 from thecharlesblake/deal-print (diff) | |
| parent | Add pre-filled cells (diff) | |
| download | metasol-247fba9d4cefc511aebec4d494ce7659ac31beb5.tar.gz metasol-247fba9d4cefc511aebec4d494ce7659ac31beb5.zip | |
Merge pull request #99 from thecharlesblake/pre-filled-cells
Add pre-filled cells
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", |
