diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-01-20 13:24:41 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-22 21:31:36 +0000 |
commit | 926e61dec65093fede0a3cae7364dbf7f1cfe997 (patch) | |
tree | 0e55e048a5ebcb10c24f0c09bb878cb0d863733a /Userland | |
parent | c7a66882f43cf81d3db7d81a9d1dd64986826b1e (diff) | |
download | serenity-926e61dec65093fede0a3cae7364dbf7f1cfe997.zip |
LibCards: Use AK::shuffle() for shuffling new decks
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCards/Card.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibCards/Card.h | 1 |
2 files changed, 1 insertions, 9 deletions
diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index 90ecf84830..b6fc71826b 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -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()))); -} - } diff --git a/Userland/Libraries/LibCards/Card.h b/Userland/Libraries/LibCards/Card.h index 5e86170939..2c828a91de 100644 --- a/Userland/Libraries/LibCards/Card.h +++ b/Userland/Libraries/LibCards/Card.h @@ -133,7 +133,6 @@ enum class Shuffle { }; ErrorOr<NonnullRefPtrVector<Card>> create_standard_deck(Shuffle); ErrorOr<NonnullRefPtrVector<Card>> create_deck(unsigned full_club_suit_count, unsigned full_diamond_suit_count, unsigned full_heart_suit_count, unsigned full_spade_suit_count, Shuffle); -void shuffle_deck(NonnullRefPtrVector<Card>&); } |