diff options
| -rw-r--r-- | die.cpp | 9 | ||||
| -rw-r--r-- | die.h | 6 |
2 files changed, 13 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; +} @@ -119,6 +119,11 @@ public: */ bool isHighlighted(); + /** + * @brief setBase + */ + void setBase(qint64); + private: qint64 m_value; QList<qint64> m_rollResult; @@ -127,6 +132,7 @@ private: bool m_displayStatus; bool m_highlighted; quint64 m_faces; + qint64 m_base; }; |