From 2bd5ff1b613c20e31269e71a8c2150eb206788cc Mon Sep 17 00:00:00 2001 From: obiwankennedy Date: Tue, 7 Jan 2014 18:48:17 +0100 Subject: Update countexecutenode.cpp counting working --- node/countexecutenode.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'node/countexecutenode.cpp') diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp index fff00f2..278f1ff 100644 --- a/node/countexecutenode.cpp +++ b/node/countexecutenode.cpp @@ -1,7 +1,12 @@ #include "countexecutenode.h" +#include "diceresult.h" + + CountExecuteNode::CountExecuteNode() + : m_scalarResult(new ScalarResult()) { + m_result = m_scalarResult; } void CountExecuteNode::setValidator(Validator* validator) { @@ -14,20 +19,24 @@ void CountExecuteNode::run(ExecutionNode *previous) { return; } - QList diceList=previous->getResult()->getResultList(); - qint64 sum = 0; - foreach(qint64 dice,diceList) + DiceResult* previous_result = static_cast(previous->getResult()); + if(NULL!=previous_result) { - if(m_validator->isValid(dice)) + QList diceList=previous_result->getResultList(); + qint64 sum = 0; + foreach(Die dice,diceList) { - ++sum; + if(m_validator->isValid(dice)) + { + ++sum; + } } - } - m_result.insertResult(sum); + m_scalarResult->setValue(sum); - if(NULL!=m_nextNode) - { - m_nextNode->run(this); + if(NULL!=m_nextNode) + { + m_nextNode->run(this); + } } } -- cgit v1.2.3-70-g09d2