Commit ca4fcf50 authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Use QRandomGenerator instead of KRandomSequence.

parent 871912cc
/***************************************************************************
* Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com> *
* (C) 2007-2014 by Jeremy Whiting <jpwhiting@kde.org> *
* (C) 2007-2021 by Jeremy Whiting <jpwhiting@kde.org> *
* (C) 2012 by Laszlo Papp <lpapp@kde.org> *
* *
* Portions of this code taken from KMessedWords by Reuben Sutton *
......@@ -37,6 +37,7 @@
#include <QLocale>
#include <QFileInfo>
#include <QRandomGenerator>
#include <QStandardPaths>
KanagramGame::KanagramGame()
......@@ -204,7 +205,7 @@ void KanagramGame::nextAnagram()
if (checkFile())
{
int totalWords = m_document->lesson()->entryCount(KEduVocLesson::Recursive);
int randomWordIndex = m_random.getLong(totalWords);
int randomWordIndex = QRandomGenerator::global()->bounded(totalWords);
if (totalWords == (int)m_answeredWords.size())
{
......@@ -218,7 +219,7 @@ void KanagramGame::nextAnagram()
// Find the next word not used yet
while (m_answeredWords.contains(translation->text()))
{
randomWordIndex = m_random.getLong(totalWords);
randomWordIndex = QRandomGenerator::global()->bounded(totalWords);
translation = m_document->lesson()->entries(KEduVocLesson::Recursive).at(randomWordIndex)->translation(0);
}
......@@ -307,7 +308,7 @@ void KanagramGame::createAnagram()
letters = m_originalWord;
while (!letters.isEmpty())
{
randomIndex = m_random.getLong(letters.count());
randomIndex = QRandomGenerator::global()->bounded(letters.count());
anagram.append(letters.at(randomIndex));
letters.remove(randomIndex, 1);
}
......
/***************************************************************************
* Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com> *
* (C) 2007-2014 by Jeremy Whiting <jpwhiting@kde.org> *
* (C) 2007-2021 by Jeremy Whiting <jpwhiting@kde.org> *
* (C) 2012 by Laszlo Papp <lpapp@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -264,9 +264,6 @@ class KanagramGame : public QObject
/** Load score settings into local variables */
void loadSettings();
/** Random sequence used to scramble the letters */
KRandomSequence m_random;
/** The current scrambled word */
QString m_anagram;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment