simplify deck parsing function
This commit is contained in:
parent
52f114b020
commit
426807f730
1 changed files with 0 additions and 4 deletions
|
@ -64,16 +64,12 @@ namespace Hanabi {
|
||||||
|
|
||||||
std::vector<Hanabi::Card> parse_deck(const boost::json::value& deck_json) {
|
std::vector<Hanabi::Card> 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);
|
||||||
std::array<std::array<Hanabi::rank_t, 5>, 6> next_copy_indices {};
|
|
||||||
for(size_t i = 0; i < deck.size(); i++) {
|
for(size_t i = 0; i < deck.size(); i++) {
|
||||||
auto &card = deck[i];
|
auto &card = deck[i];
|
||||||
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.index = i;
|
|
||||||
card.copy = next_copy_indices[card.suit][card.rank];
|
|
||||||
next_copy_indices[card.suit][card.rank]++;
|
|
||||||
}
|
}
|
||||||
return deck;
|
return deck;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue