diff options
| author | 2017-02-12 11:05:54 +0100 | |
|---|---|---|
| committer | 2017-02-12 11:05:54 +0100 | |
| commit | b0ddec64a03135484a7439a65de8486974f08499 (patch) | |
| tree | 5e3a845183fd78d6b07903983feeae26edf73308 /die.cpp | |
| parent | 32f164c6e807c4f3d6fab3b147d1cf98e7a949c0 (diff) | |
| download | OneRoll-b0ddec64a03135484a7439a65de8486974f08499.tar.gz OneRoll-b0ddec64a03135484a7439a65de8486974f08499.zip | |
-Fix range management for DF dice.
Diffstat (limited to 'die.cpp')
| -rw-r--r-- | die.cpp | 20 |
1 files changed, 15 insertions, 5 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; +} + |