aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2016-10-10 20:40:53 +0200
committerRenaud G <renaud@rolisteam.org>2016-10-10 20:40:53 +0200
commit33429179caa08414646f7f6c9d396b070de9bdff (patch)
tree6c0cc05b590b46951e6741fb5dc3ff50f1e95c15
parente225f2edfd365d1709df2cb5bb2f752ec8d82c1c (diff)
downloadOneRoll-33429179caa08414646f7f6c9d396b070de9bdff.tar.gz
OneRoll-33429179caa08414646f7f6c9d396b070de9bdff.zip
-change random method.
-rw-r--r--die.cpp10
-rw-r--r--die.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/die.cpp b/die.cpp
index 1c52adb..864ed27 100644
--- a/die.cpp
+++ b/die.cpp
@@ -25,13 +25,16 @@
#include <QDateTime>
#include <QDebug>
+
Die::Die()
- : m_hasValue(false),m_displayStatus(false),m_highlighted(true),m_base(1),m_color("")
+ : m_hasValue(false),m_displayStatus(false),m_highlighted(true),m_base(1),m_color("")//,m_mt(m_randomDevice)
{
uint seed = quintptr(this) + QDateTime::currentDateTime().toMSecsSinceEpoch();
+
qsrand(seed);
+
}
Die::Die(const Die& die)
{
@@ -99,7 +102,10 @@ void Die::roll(bool adding)
{
if(m_faces!=0)
{
- quint64 value=(qrand()%m_faces)+m_base;
+ //quint64 value=(qrand()%m_faces)+m_base;
+ std::random_device rd;
+ std::uniform_int_distribution<qint64> dist(m_base,m_faces);
+ qint64 value = dist(rd);
if((adding)||(m_rollResult.isEmpty()))
{
insertRollValue(value);
diff --git a/die.h b/die.h
index 8ebda1a..e29f10d 100644
--- a/die.h
+++ b/die.h
@@ -24,7 +24,7 @@
#include <QList>
#include <QString>
-
+#include <random>
/**
* @brief The Die class implements all methods required from a die. You must set the Faces first, then you can roll it and roll it again, to add or replace the previous result.
*/