blob: 6994b15451cce84333105b68deccc2574f221544 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include "countexecutenode.h"
#include "diceresult.h"
CountExecuteNode::CountExecuteNode()
: m_scalarResult(new ScalarResult())
{
m_result = m_scalarResult;
}
void CountExecuteNode::setValidator(Validator* validator)
{
m_validator = validator;
}
void CountExecuteNode::run(ExecutionNode *previous)
{
qDebug() << "CountExecuteNode node";
if(NULL==previous)
{
return;
}
DiceResult* previous_result = static_cast<DiceResult*>(previous->getResult());
if(NULL!=previous_result)
{
m_result->setPrevious(previous_result);
QList<Die*> diceList=previous_result->getResultList();
qint64 sum = 0;
foreach(Die* dice,diceList)
{
sum+=m_validator->hasValid(dice,true);
}
m_scalarResult->setValue(sum);
if(NULL!=m_nextNode)
{
m_nextNode->run(this);
}
}
}
QString CountExecuteNode::toString() const
{
return "CountExecuteNode";
}
|