diff options
| author | 2015-05-15 14:48:30 +0200 | |
|---|---|---|
| committer | 2015-05-15 14:48:30 +0200 | |
| commit | 74b931cd4dd5af57ee7e34948a92dad62733d722 (patch) | |
| tree | cdd28c39319aad8f351f280c4dbf72524dcded43 /die.cpp | |
| parent | 5acbf79338f01857f4d646727cd5f819c6de2183 (diff) | |
| download | OneRoll-74b931cd4dd5af57ee7e34948a92dad62733d722.tar.gz OneRoll-74b931cd4dd5af57ee7e34948a92dad62733d722.zip | |
add management of base, the minimum value of die
Diffstat (limited to 'die.cpp')
| -rw-r--r-- | die.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -26,7 +26,7 @@ #include <QDebug> Die::Die() - : m_hasValue(false),m_displayStatus(false),m_highlighted(true) + : m_hasValue(false),m_displayStatus(false),m_highlighted(true),m_base(1) { uint seed = quintptr(this) + QDateTime::currentDateTime().toMSecsSinceEpoch(); qsrand(seed); @@ -42,6 +42,7 @@ Die::Die(const Die& die) m_displayStatus = die.m_displayStatus; m_faces = die.m_faces; m_highlighted = die.m_highlighted; + m_base = die.m_base; } void Die::setValue(qint64 r) @@ -97,7 +98,7 @@ void Die::roll(bool adding) { if(m_faces!=0) { - quint64 value=(qrand()%m_faces)+1; + quint64 value=(qrand()%m_faces)+m_base; if((adding)||(m_rollResult.isEmpty())) { insertRollValue(value); @@ -144,3 +145,7 @@ bool Die::isHighlighted() { return m_highlighted; } +void Die::setBase(qint64 base) +{ + m_base = base; +} |