From 49cb4ef2e55afcd30bc5019de2c6c381c8846ced Mon Sep 17 00:00:00 2001 From: obiwankennedy Date: Tue, 7 Jan 2014 18:44:35 +0100 Subject: Update die.cpp management of dice and it prepare the way to reroll it again. --- die.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'die.cpp') 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 Die::getListValue() const { return m_rollResult; } +bool Die::hasChildrenValue() +{ + return m_rollResult.size()>1?true:false; +} -- cgit v1.2.3-70-g09d2