diff options
| author | 2018-04-10 20:43:24 +0200 | |
|---|---|---|
| committer | 2018-04-11 00:18:05 +0200 | |
| commit | d205f806d0bcfc119e2ecd3ea063288877064dde (patch) | |
| tree | e1bd4b4741143972aabdeeef2cb2146eac41265b /node/rerolldicenode.cpp | |
| parent | 826f21f33721f0c232e1440ab8c4d04a822aff8c (diff) | |
| download | OneRoll-d205f806d0bcfc119e2ecd3ea063288877064dde.tar.gz OneRoll-d205f806d0bcfc119e2ecd3ea063288877064dde.zip | |
-Add support for subcommand on reroll operator.
Diffstat (limited to 'node/rerolldicenode.cpp')
| -rw-r--r-- | node/rerolldicenode.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp index 2ead761..f51eb9e 100644 --- a/node/rerolldicenode.cpp +++ b/node/rerolldicenode.cpp @@ -1,5 +1,5 @@ #include "rerolldicenode.h" - +#include "parsingtoolbox.h" RerollDiceNode::RerollDiceNode() : m_diceResult(new DiceResult()),m_adding(false),m_validator(nullptr) @@ -32,13 +32,29 @@ void RerollDiceNode::run(ExecutionNode* previous) } //m_diceResult->setResultList(list); - QList<Die*> list = m_diceResult->getResultList(); + QList<Die*>& list = m_diceResult->getResultList(); for(Die* die: list) { if(m_validator->hasValid(die,false)) { - die->roll(m_adding); + if(m_instruction != nullptr) + { + m_instruction->run(this); + auto lastNode = ParsingToolBox::getLatestNode(m_instruction); + if(lastNode != nullptr) + { + auto lastResult = dynamic_cast<DiceResult*>(lastNode->getResult()); + if(lastResult != nullptr) + { + list.append(lastResult->getResultList()); + } + } + } + else + { + die->roll(m_adding); + } } } @@ -96,3 +112,13 @@ ExecutionNode* RerollDiceNode::getCopy() const } return node; } + +ExecutionNode *RerollDiceNode::getInstruction() const +{ + return m_instruction; +} + +void RerollDiceNode::setInstruction(ExecutionNode *instruction) +{ + m_instruction = instruction; +} |