summaryrefslogtreecommitdiff
path: root/Userland/Games/Hearts
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-07-24 00:55:07 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-24 01:40:51 +0200
commit5201c17d9b571d58a0e7b1e5bb140ddf39b379a2 (patch)
treeb34c8c0648dfca236df3247df3e49847d22b9ff4 /Userland/Games/Hearts
parent1621311d73f9e3721f98df52fa5b5b2f345465e2 (diff)
downloadserenity-5201c17d9b571d58a0e7b1e5bb140ddf39b379a2.zip
Hearts: Use AK::get_random_uniform() instead of rand()/srand()
Diffstat (limited to 'Userland/Games/Hearts')
-rw-r--r--Userland/Games/Hearts/Game.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp
index 9df6056a0d..5ef03979b0 100644
--- a/Userland/Games/Hearts/Game.cpp
+++ b/Userland/Games/Hearts/Game.cpp
@@ -10,13 +10,13 @@
#include "ScoreCard.h"
#include <AK/Debug.h>
#include <AK/QuickSort.h>
+#include <AK/Random.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
#include <LibGUI/Dialog.h>
#include <LibGUI/Painter.h>
#include <LibGfx/Font.h>
#include <LibGfx/Palette.h>
-#include <time.h>
REGISTER_WIDGET(Hearts, Game);
@@ -24,8 +24,6 @@ namespace Hearts {
Game::Game()
{
- srand(time(nullptr));
-
m_delay_timer = Core::Timer::create_single_shot(0, [this] {
dbgln_if(HEARTS_DEBUG, "Continuing game after delay...");
advance_game();
@@ -215,7 +213,7 @@ void Game::setup(String player_name, int hand_number)
for (auto& player : m_players) {
for (uint8_t i = 0; i < Card::card_count; ++i) {
- auto card = deck.take(rand() % deck.size());
+ auto card = deck.take(get_random_uniform(deck.size()));
if constexpr (!HEARTS_DEBUG) {
if (&player != &m_players[0])
card->set_upside_down(true);