diff options
| author | 2018-04-23 13:41:46 +0200 | |
|---|---|---|
| committer | 2018-04-23 13:41:46 +0200 | |
| commit | fd5728eb399e10514afd0bb55b73d504d50b7517 (patch) | |
| tree | d40b0541ca91a56f6ec349c6d8569e8bb2b70d3a /node/rerolldicenode.cpp | |
| parent | 4fa76667c4e7f31ed6b28eb43ad277ac448e0e71 (diff) | |
| download | OneRoll-fd5728eb399e10514afd0bb55b73d504d50b7517.tar.gz OneRoll-fd5728eb399e10514afd0bb55b73d504d50b7517.zip | |
reroll dice with replacement by expression
Diffstat (limited to 'node/rerolldicenode.cpp')
| -rw-r--r-- | node/rerolldicenode.cpp | 12 |
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); |