1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:27:35 +00:00

LibCards+Games: Move "create a deck" logic to LibCards

`create_standard_deck()` is the usual 52-card deck, but more custom
setups (such as Spider's multiples-of-one-suit) can be created by
passing suit counts to `create_deck()`.
This commit is contained in:
Sam Atkins 2022-09-28 11:35:12 +01:00 committed by Sam Atkins
parent 1d533acbc0
commit 46299f3853
5 changed files with 64 additions and 42 deletions

View file

@ -162,15 +162,7 @@ void Game::setup(Mode mode)
if (on_undo_availability_change)
on_undo_availability_change(false);
for (int i = 0; i < Card::card_count; ++i) {
m_new_deck.append(Card::construct(Cards::Suit::Clubs, static_cast<Cards::Rank>(i)));
m_new_deck.append(Card::construct(Cards::Suit::Spades, static_cast<Cards::Rank>(i)));
m_new_deck.append(Card::construct(Cards::Suit::Hearts, static_cast<Cards::Rank>(i)));
m_new_deck.append(Card::construct(Cards::Suit::Diamonds, static_cast<Cards::Rank>(i)));
}
for (uint8_t i = 0; i < 200; ++i)
m_new_deck.append(m_new_deck.take(get_random_uniform(m_new_deck.size())));
m_new_deck = Cards::create_standard_deck(Cards::Shuffle::Yes);
m_focused_stack = nullptr;
m_focused_cards.clear();