blob: d0084a32920346ac2c03d9ff6a1fed867531e615 (
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
46
47
48
49
50
51
52
53
54
55
56
|
#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)
{
m_previousNode = previous;
if(NULL==previous)
{
return;
}
DiceResult* previous_result = dynamic_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"+m_validator->toString();
}
qint64 CountExecuteNode::getPriority() const
{
qint64 priority=0;
if(NULL!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
return priority;
}
|