aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node/keepdiceexecnode.cpp
blob: e8cfac816c2b900414a7103be18c990342de27b4 (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
57
58
59
#include <QList>


#include "keepdiceexecnode.h"


KeepDiceExecNode::KeepDiceExecNode()
    : m_diceResult(new DiceResult())
{
    m_result = m_diceResult;
}

void KeepDiceExecNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
    if(NULL==previous)
    {
        return;
    }
    DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult());
    m_result->setPrevious(previousDiceResult);
    if(NULL!=previousDiceResult)
    {
        QList<Die*> diceList=previousDiceResult->getResultList();
        QList<Die*> diceList2=m_diceResult->getResultList();


        diceList2 = diceList.mid(0,m_numberOfDice);
        foreach(Die* tmp,diceList.mid(m_numberOfDice,-1))
        {
            tmp->setHighlighted(false);
        }

        m_diceResult->setResultList(diceList2);
        if(NULL!=m_nextNode)
        {
            m_nextNode->run(this);
        }
    }
}
void KeepDiceExecNode::setDiceKeepNumber(quint64 n)
{
    m_numberOfDice = n;
}
QString KeepDiceExecNode::toString() const
{
    return QString("KeepDiceExecNode");
}
qint64 KeepDiceExecNode::getPriority() const
{
    qint64 priority=0;
    if(NULL!=m_nextNode)
    {
        priority = m_nextNode->getPriority();
    }


    return priority;
}