aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/die.cpp
diff options
context:
space:
mode:
authorobiwankennedy <renaud@rolisteam.org>2014-01-07 18:44:35 +0100
committerobiwankennedy <renaud@rolisteam.org>2014-01-07 18:44:35 +0100
commit49cb4ef2e55afcd30bc5019de2c6c381c8846ced (patch)
tree5142c95da9c82e06228869ce8fc0f032476c9373 /die.cpp
parentbcf1b0c9c285230b28126e270deac12a88d12ebd (diff)
downloadOneRoll-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.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/die.cpp b/die.cpp
index 7dde880..4a968a3 100644
--- a/die.cpp
+++ b/die.cpp
@@ -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;
+}