add card orders to deck

This commit is contained in:
Maximilian Keßler 2024-01-01 15:19:25 +01:00
parent c6a7eec903
commit 8b42819704
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 5 additions and 1 deletions

View file

@ -63,10 +63,11 @@ namespace Hanabi
{ {
suit_t suit; suit_t suit;
rank_t rank; 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, // These attributes are not needed in general for a card,
// they represent internal states during backtracking. // 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 in_starting_hand;
bool initial_trash; bool initial_trash;

View file

@ -71,12 +71,15 @@ namespace Parsing
std::pair<std::vector<Hanabi::Card>, Hanabi::suit_t> parse_deck(const boost::json::value & deck_json) std::pair<std::vector<Hanabi::Card>, Hanabi::suit_t> parse_deck(const boost::json::value & deck_json)
{ {
auto deck = boost::json::value_to<std::vector<Hanabi::Card>>(deck_json); auto deck = boost::json::value_to<std::vector<Hanabi::Card>>(deck_json);
uint8_t deck_index = 0;
for (auto & card: deck) for (auto & card: deck)
{ {
ASSERT(card.rank < 5); ASSERT(card.rank < 5);
ASSERT(card.rank >= 0); ASSERT(card.rank >= 0);
ASSERT(card.suit < 6); ASSERT(card.suit < 6);
ASSERT(card.suit >= 0); ASSERT(card.suit >= 0);
card.deck_index = deck_index;
deck_index++;
} }
Hanabi::suit_t num_suits = 0; Hanabi::suit_t num_suits = 0;
for (const auto & card: deck) for (const auto & card: deck)