aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-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;
+}