Spider: Use AK::get_random_uniform() instead of rand()/srand()

This also has the added benefit that after a restart we don't get the
same random numbers all the time because we forgot to initialize the
RNG with srand().
This commit is contained in:
Gunnar Beutner 2021-07-24 00:58:40 +02:00 committed by Andreas Kling
parent 807b79d89e
commit 58d1e46628
Notes: sideshowbarker 2024-07-18 08:25:01 +09:00

View File

@ -5,6 +5,7 @@
*/
#include "Game.h"
#include <AK/Random.h>
#include <LibGUI/Painter.h>
#include <LibGfx/Palette.h>
@ -72,7 +73,7 @@ void Game::setup(Mode mode)
m_new_deck.clear_with_capacity();
m_new_deck.ensure_capacity(deck.size());
while (!deck.is_empty())
m_new_deck.append(deck.take(rand() % deck.size()));
m_new_deck.append(deck.take(get_random_uniform(deck.size())));
m_new_game_animation = true;
start_timer(s_timer_interval_ms);