diff options
| author | 2014-01-07 18:44:35 +0100 | |
|---|---|---|
| committer | 2014-01-07 18:44:35 +0100 | |
| commit | 49cb4ef2e55afcd30bc5019de2c6c381c8846ced (patch) | |
| tree | 5142c95da9c82e06228869ce8fc0f032476c9373 /die.cpp | |
| parent | bcf1b0c9c285230b28126e270deac12a88d12ebd (diff) | |
| download | OneRoll-49cb4ef2e55afcd30bc5019de2c6c381c8846ced.tar.gz OneRoll-49cb4ef2e55afcd30bc5019de2c6c381c8846ced.zip | |
Update die.cpp
management of dice and it prepare the way to reroll it again.
Diffstat (limited to 'die.cpp')
| -rw-r--r-- | die.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1,17 +1,19 @@ #include "die.h" Die::Die() + : m_hasValue(false) { } void Die::setValue(qint64 r) { m_value = r; + m_hasValue = true; } void Die::insertRollValue(qint64 r) { - m_rollResult.insert(r); + m_rollResult.append(r); } void Die::setSelected(bool b) @@ -26,9 +28,23 @@ bool Die::isSelected() const } qint64 Die::getValue() const { - return m_value; + if(m_hasValue) + return m_value; + else + { + qint64 value=0; + foreach(qint64 tmp,m_rollResult) + { + value+=tmp; + } + return value; + } } QList<qint64> Die::getListValue() const { return m_rollResult; } +bool Die::hasChildrenValue() +{ + return m_rollResult.size()>1?true:false; +} |