aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
authorobiwankennedy <renaud@rolisteam.org>2018-04-23 13:41:46 +0200
committerobiwankennedy <renaud@rolisteam.org>2018-04-23 13:41:46 +0200
commitfd5728eb399e10514afd0bb55b73d504d50b7517 (patch)
treed40b0541ca91a56f6ec349c6d8569e8bb2b70d3a /node
parent4fa76667c4e7f31ed6b28eb43ad277ac448e0e71 (diff)
downloadOneRoll-fd5728eb399e10514afd0bb55b73d504d50b7517.tar.gz
OneRoll-fd5728eb399e10514afd0bb55b73d504d50b7517.zip
reroll dice with replacement by expression
Diffstat (limited to 'node')
-rw-r--r--node/rerolldicenode.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp
index f51eb9e..a24ffa9 100644
--- a/node/rerolldicenode.cpp
+++ b/node/rerolldicenode.cpp
@@ -33,9 +33,11 @@ void RerollDiceNode::run(ExecutionNode* previous)
//m_diceResult->setResultList(list);
QList<Die*>& list = m_diceResult->getResultList();
+ QList<Die*> toRemove;
- for(Die* die: list)
+ for(int i = 0; i < list.size() ; ++i)
{
+ auto die = list.at(i);
if(m_validator->hasValid(die,false))
{
if(m_instruction != nullptr)
@@ -47,8 +49,10 @@ void RerollDiceNode::run(ExecutionNode* previous)
auto lastResult = dynamic_cast<DiceResult*>(lastNode->getResult());
if(lastResult != nullptr)
{
+ toRemove.append(die);
list.append(lastResult->getResultList());
}
+ lastResult->clear();
}
}
else
@@ -58,6 +62,12 @@ void RerollDiceNode::run(ExecutionNode* previous)
}
}
+ for(auto die: toRemove)
+ {
+ list.removeOne(die);
+ }
+
+
if(nullptr!=m_nextNode)
{
m_nextNode->run(this);