blob: 6df64ba6c66d55b6f4ae2bdf557393a5ffd521aa (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#include "explodedicenode.h"
ExplodeDiceNode::ExplodeDiceNode() : m_diceResult(new DiceResult()), m_validator(nullptr)
{
m_result= m_diceResult;
}
void ExplodeDiceNode::run(ExecutionNode* previous)
{
m_previousNode= previous;
if((nullptr != previous) && (nullptr != previous->getResult()))
{
DiceResult* previous_result= dynamic_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previous_result);
if(nullptr != previous_result)
{
for(auto& die : previous_result->getResultList())
{
Die* tmpdie= new Die();
*tmpdie= *die;
m_diceResult->insertResult(tmpdie);
die->displayed();
}
QList<Die*> list= m_diceResult->getResultList();
for(auto& die : list)
{
while(m_validator->hasValid(die, false))
{
die->roll(true);
}
}
// m_diceResult->setResultList(list);
if(nullptr != m_nextNode)
{
m_nextNode->run(this);
}
}
}
}
ExplodeDiceNode::~ExplodeDiceNode()
{
if(nullptr != m_validator)
{
delete m_validator;
}
}
void ExplodeDiceNode::setValidator(Validator* val)
{
m_validator= val;
}
QString ExplodeDiceNode::toString(bool withlabel) const
{
if(withlabel)
{
return QString("%1 [label=\"ExplodeDiceNode %2\"]").arg(m_id, m_validator->toString());
}
else
{
return m_id;
}
}
qint64 ExplodeDiceNode::getPriority() const
{
qint64 priority= 0;
if(nullptr != m_previousNode)
{
priority= m_previousNode->getPriority();
}
return priority;
}
ExecutionNode* ExplodeDiceNode::getCopy() const
{
ExplodeDiceNode* node= new ExplodeDiceNode();
if(nullptr != m_validator)
{
node->setValidator(m_validator->getCopy());
}
if(nullptr != m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
return node;
}
|