aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node/countexecutenode.cpp
blob: fff00f28dcf8ef84dcf80369c308f969abf6c7f8 (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
#include "countexecutenode.h"

CountExecuteNode::CountExecuteNode()
{
}
void CountExecuteNode::setValidator(Validator* validator)
{
    m_validator = validator;
}

void CountExecuteNode::run(ExecutionNode *previous)
{
    if(NULL==previous)
    {
        return;
    }
    QList<qint64> diceList=previous->getResult()->getResultList();
   qint64 sum = 0;
    foreach(qint64 dice,diceList)
    {
        if(m_validator->isValid(dice))
        {
            ++sum;
        }
    }
    m_result.insertResult(sum);


    if(NULL!=m_nextNode)
    {
        m_nextNode->run(this);
    }
}