From 8b4281970478091f2e46cc9f034d05ff0905db5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 1 Jan 2024 15:19:25 +0100 Subject: [PATCH] add card orders to deck --- include/hanabi_types.hpp | 3 ++- src/parse_game.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/hanabi_types.hpp b/include/hanabi_types.hpp index 4eaadc1..fe8b9fc 100644 --- a/include/hanabi_types.hpp +++ b/include/hanabi_types.hpp @@ -63,10 +63,11 @@ namespace Hanabi { suit_t suit; rank_t rank; + uint8_t deck_index; /** Order of card in deck, numbered 0, 1, ... */ // These attributes are not needed in general for a card, // they represent internal states during backtracking. - uint8_t local_index; + uint8_t local_index; /** Used for the local representation of the current game state. */ bool in_starting_hand; bool initial_trash; diff --git a/src/parse_game.cpp b/src/parse_game.cpp index 2ab237f..8ca611f 100644 --- a/src/parse_game.cpp +++ b/src/parse_game.cpp @@ -71,12 +71,15 @@ namespace Parsing std::pair, Hanabi::suit_t> parse_deck(const boost::json::value & deck_json) { auto deck = boost::json::value_to>(deck_json); + uint8_t deck_index = 0; for (auto & card: deck) { ASSERT(card.rank < 5); ASSERT(card.rank >= 0); ASSERT(card.suit < 6); ASSERT(card.suit >= 0); + card.deck_index = deck_index; + deck_index++; } Hanabi::suit_t num_suits = 0; for (const auto & card: deck)