From 0111172d25f73a23e9390025f71620d60f2f6c86 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 18 Jan 2018 13:47:38 +0000 Subject: Update parsing to check correct features --- .../input/json-parsing/deal_parser.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/main/input-output/input/json-parsing/deal_parser.cpp') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index b2a4c9d..7cf5f45 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -13,32 +13,32 @@ typedef sol_rules::build_policy pol; void deal_parser::parse(game_state &gs, const rapidjson::Document& doc) { // Construct tableau piles - if (gs.rules.tableau_pile_count > 0) { + if (game_state::rules.tableau_pile_count > 0) { parse_tableau_piles(gs, doc); } // Construct hole card - if (gs.rules.hole) { + if (game_state::rules.hole) { parse_hole(gs, doc); } // Construct filled cells - if (gs.rules.cells) { + if (game_state::rules.cells) { parse_cells(gs, doc); } // Construct stock - if (gs.rules.stock_size > 0) { + if (game_state::rules.stock_size > 0) { parse_stock(gs, doc); } // Construct reserve - if (gs.rules.reserve_size > 0) { + if (game_state::rules.reserve_size > 0) { parse_reserve(gs, doc); } // If the foundations begin with cards in them, fill them - if (gs.rules.foundations_init_card) { + if (game_state::rules.foundations_init_card) { fill_foundations(gs); } } @@ -48,7 +48,7 @@ void deal_parser::parse_tableau_piles(game_state &gs, const rapidjson::Document& const Value& json_tab_piles = doc["tableau piles"]; assert(json_tab_piles.IsArray()); - if (json_tab_piles.Size() != gs.rules.tableau_pile_count ) { + if (json_tab_piles.Size() != game_state::rules.tableau_pile_count ) { json_helper::json_parse_err("Incorrect number of tableau piles"); } @@ -81,7 +81,7 @@ void deal_parser::parse_cells(game_state &gs, const Document& doc) { const auto json_cell_arr = json_cells.GetArray(); if (json_cell_arr.Empty()) return; - else if (json_cell_arr.Size() != gs.rules.cells) { + else if (json_cell_arr.Size() != game_state::rules.cells) { json_helper::json_parse_err("Incorrect number of cells"); } @@ -101,7 +101,7 @@ void deal_parser::parse_stock(game_state &gs, const Document& doc) { const Value &json_stock = doc["stock"]; assert(json_stock.IsArray()); - if (json_stock.Size() != gs.rules.stock_size) { + if (json_stock.Size() != game_state::rules.stock_size) { json_helper::json_parse_err("Incorrect stock size"); } @@ -121,25 +121,25 @@ void deal_parser::parse_reserve(game_state &gs, const Document& doc) { // We treat a regular reserve like multiple single-card piles, // but a stacked reserve as a single multiple-card pile - if (json_reserve_piles.Size() != gs.rules.reserve_size) { + if (json_reserve_piles.Size() != game_state::rules.reserve_size) { json_helper::json_parse_err("Incorrect reserve size"); } for (game_state::pile_ref i = 0; i < json_card_arr.Size(); i++) { assert(json_card_arr[i].IsString()); game_state::pile_ref pr = gs.reserve[0]; - if (!gs.rules.reserve_stacked) pr += i; + if (!game_state::rules.reserve_stacked) pr += i; gs.piles[pr].place(card(json_card_arr[i].GetString())); } } void deal_parser::fill_foundations(game_state &gs) { - auto foundations_count = uint8_t(4 * (gs.rules.two_decks ? 2:1)); + auto foundations_count = uint8_t(4 * (game_state::rules.two_decks ? 2:1)); assert(gs.foundations.size() == foundations_count); for (uint8_t f_idx = 0; f_idx < foundations_count; f_idx++) { gs.piles[gs.foundations[f_idx]].place( - card(card::to_suit(f_idx % uint8_t(4)), 1) + card(f_idx % uint8_t(4), 1) ); } } -- cgit v1.2.1