diff options
| -rw-r--r-- | die.cpp | 20 | ||||
| -rw-r--r-- | die.h | 5 |
2 files changed, 19 insertions, 6 deletions
@@ -44,7 +44,7 @@ Die::Die(const Die& die) m_selected = die.m_selected; m_hasValue = die.m_hasValue; m_displayStatus = die.m_displayStatus; - m_faces = die.m_faces; + m_maxValue = die.m_maxValue; m_highlighted = die.m_highlighted; m_base = die.m_base; m_color = die.getColor(); @@ -103,11 +103,11 @@ void Die::replaceLastValue(qint64 value) void Die::roll(bool adding) { - if(m_faces!=0) + if(m_maxValue!=0) { //quint64 value=(qrand()%m_faces)+m_base; - std::uniform_int_distribution<qint64> dist(m_base,m_faces); + std::uniform_int_distribution<qint64> dist(m_base,m_maxValue); qint64 value = dist(m_rng); if((adding)||(m_rollResult.isEmpty())) { @@ -122,12 +122,12 @@ void Die::roll(bool adding) quint64 Die::getFaces() const { - return m_faces; + return abs(m_maxValue-m_base)+1; } void Die::setFaces(quint64 face) { - m_faces=face; + //m_maxValue=m_base+face-1; } qint64 Die::getLastRolledValue() { @@ -169,3 +169,13 @@ void Die::setColor(const QString &color) m_color = color; } +quint64 Die::getMaxValue() const +{ + return m_maxValue; +} + +void Die::setMaxValue(const quint64 &maxValue) +{ + m_maxValue = maxValue; +} + @@ -128,6 +128,9 @@ public: QString getColor() const; void setColor(const QString &color); + quint64 getMaxValue() const; + void setMaxValue(const quint64 &maxValue); + private: qint64 m_value; QList<qint64> m_rollResult; @@ -135,7 +138,7 @@ private: bool m_hasValue; bool m_displayStatus; bool m_highlighted; - quint64 m_faces; + quint64 m_maxValue; qint64 m_base; QString m_color; |