1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:28:13 +00:00

LibCards: Use AK::shuffle() for shuffling new decks

This commit is contained in:
Sam Atkins 2023-01-20 13:24:41 +00:00 committed by Linus Groh
parent c7a66882f4
commit 926e61dec6
2 changed files with 1 additions and 9 deletions

View file

@ -80,16 +80,9 @@ ErrorOr<NonnullRefPtrVector<Card>> create_deck(unsigned full_club_suit_count, un
TRY(add_cards_for_suit(Cards::Suit::Spades, full_spade_suit_count));
if (shuffle == Shuffle::Yes)
shuffle_deck(deck);
AK::shuffle(deck);
return deck;
}
void shuffle_deck(NonnullRefPtrVector<Card>& deck)
{
auto iteration_count = deck.size() * 4;
for (auto i = 0u; i < iteration_count; ++i)
deck.append(deck.take(get_random_uniform(deck.size())));
}
}