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

LibCards+Games: Return ErrorOr from deck-creation factory functions :^)

Also, be smarter about appending cards to the deck: we can
unchecked_append them to the deck, since we already ensured enough
capacity earlier.
This commit is contained in:
Sam Atkins 2023-01-20 13:19:56 +00:00 committed by Linus Groh
parent 0855e9f014
commit c7c4d70f6e
5 changed files with 15 additions and 14 deletions

View file

@ -199,7 +199,7 @@ void Game::setup(DeprecatedString player_name, int hand_number)
m_passing_button->set_focus(false);
}
NonnullRefPtrVector<Card> deck = Cards::create_standard_deck(Cards::Shuffle::Yes);
NonnullRefPtrVector<Card> deck = Cards::create_standard_deck(Cards::Shuffle::Yes).release_value_but_fixme_should_propagate_errors();
for (auto& player : m_players) {
player.hand.ensure_capacity(Card::card_count);