diff options
| author | 2024-10-23 15:42:08 +0200 | |
|---|---|---|
| committer | 2024-12-29 14:46:30 +0100 | |
| commit | cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea (patch) | |
| tree | c261de4ad8d0f85aec0200bf500e9579437577df /src/libparser/node/jumpbackwardnode.cpp | |
| parent | e4dc41cdc3ebb84ef7e42f5cf261e36fe874c901 (diff) | |
| download | OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.tar.gz OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.zip | |
Add execute node.
Diffstat (limited to 'src/libparser/node/jumpbackwardnode.cpp')
| -rw-r--r-- | src/libparser/node/jumpbackwardnode.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/libparser/node/jumpbackwardnode.cpp b/src/libparser/node/jumpbackwardnode.cpp index 9fa0f45..e4ae59a 100644 --- a/src/libparser/node/jumpbackwardnode.cpp +++ b/src/libparser/node/jumpbackwardnode.cpp @@ -116,43 +116,37 @@ void JumpBackwardNode::run(ExecutionNode* previous) parent= parent->getPreviousNode(); } } - if(nullptr == result) - { - m_errors.insert( - Dice::ERROR_CODE::DIE_RESULT_EXPECTED, - QObject::tr(" The @ operator expects dice result. Please check the documentation to fix your command.")); - } - else + if(isValid(!result, Dice::ERROR_CODE::DIE_RESULT_EXPECTED, + tr(" The @ operator expects dice result. Please check the documentation to fix your command."))) + return; + + DiceResult* diceResult= dynamic_cast<DiceResult*>(result); + if(nullptr != diceResult) { - DiceResult* diceResult= dynamic_cast<DiceResult*>(result); - if(nullptr != diceResult) + for(auto& die : diceResult->getResultList()) { - for(auto& die : diceResult->getResultList()) - { - Die* tmpdie= new Die(*die); - //*tmpdie= *die; - m_diceResult->insertResult(tmpdie); - die->displayed(); - } + Die* tmpdie= new Die(*die); + //*tmpdie= *die; + m_diceResult->insertResult(tmpdie); + die->displayed(); } + } - m_result->setPrevious(previous->getResult()); + m_result->setPrevious(previous->getResult()); - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } - if(nullptr != diceResult) + if(m_nextNode) + m_nextNode->execute(this); + + if(!diceResult) + return; + + for(int i= 0; i < diceResult->getResultList().size(); ++i) + { + Die* tmp= diceResult->getResultList().at(i); + Die* tmp2= m_diceResult->getResultList().at(i); + if(tmp->isHighlighted()) { - for(int i= 0; i < diceResult->getResultList().size(); ++i) - { - Die* tmp= diceResult->getResultList().at(i); - Die* tmp2= m_diceResult->getResultList().at(i); - if(tmp->isHighlighted()) - { - tmp2->setHighlighted(true); - } - } + tmp2->setHighlighted(true); } } } @@ -166,3 +160,8 @@ ExecutionNode* JumpBackwardNode::getCopy() const } return node; } + +void JumpBackwardNode::execute(ExecutionNode* previous) +{ + run(previous); +} |