aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node/dicerollernode.cpp
blob: 3c16a347757fafdeded8f5f67e5218211bad73bf (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
#include "dicerollernode.h"
#include "die.h"



#include <QDebug>

DiceRollerNode::DiceRollerNode(quint64 faces)
    : m_faces(faces),m_myDiceResult(new DiceResult())
{

    m_result=m_myDiceResult;

}
void DiceRollerNode::run(ExecutionNode* previous)
{
    if(NULL!=previous)
    {
        m_diceCount = previous->getResult()->getScalar();
        for(quint64 i=0; i < m_diceCount ; ++i)
        {
            Die* die = new Die();
            die->setFaces(m_faces);
            die->roll();
            m_myDiceResult->insertResult(die);
        }
        if(NULL!=m_nextNode)
        {
            m_nextNode->run(this);
        }
    }
}

quint64 DiceRollerNode::getFaces()
{
    return m_faces;
}