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/splitnode.cpp | |
| parent | e4dc41cdc3ebb84ef7e42f5cf261e36fe874c901 (diff) | |
| download | OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.tar.gz OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.zip | |
Add execute node.
Diffstat (limited to 'src/libparser/node/splitnode.cpp')
| -rw-r--r-- | src/libparser/node/splitnode.cpp | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/src/libparser/node/splitnode.cpp b/src/libparser/node/splitnode.cpp index 8faa0a5..ff5fc40 100644 --- a/src/libparser/node/splitnode.cpp +++ b/src/libparser/node/splitnode.cpp @@ -27,39 +27,35 @@ SplitNode::SplitNode() : m_diceResult(new DiceResult()) } void SplitNode::run(ExecutionNode* previous) { + if(isValid(!previous, Dice::ERROR_CODE::NO_PREVIOUS_ERROR, tr("No Previous node"))) + return; m_previousNode= previous; - if(nullptr != previous) - { - m_result->setPrevious(previous->getResult()); - Result* tmpResult= previous->getResult(); - if(nullptr != tmpResult) + m_result->setPrevious(previous->getResult()); + + Result* tmpResult= previous->getResult(); + if(isValid(!tmpResult, Dice::ERROR_CODE::NO_VALID_RESULT, tr("No Valid result"))) + return; + + DiceResult* dice= dynamic_cast<DiceResult*>(tmpResult); + if(isValid(!dice, Dice::ERROR_CODE::NO_VALID_RESULT, tr("No Valid dice result"))) + return; + + for(auto& oldDie : dice->getResultList()) + { + oldDie->displayed(); + m_diceResult->setOperator(oldDie->getOp()); + for(qint64& value : oldDie->getListValue()) { - DiceResult* dice= dynamic_cast<DiceResult*>(tmpResult); - if(nullptr != dice) - { - for(auto& oldDie : dice->getResultList()) - { - oldDie->displayed(); - m_diceResult->setOperator(oldDie->getOp()); - for(qint64& value : oldDie->getListValue()) - { - Die* tmpdie= new Die(); - tmpdie->insertRollValue(value); - tmpdie->setBase(oldDie->getBase()); - tmpdie->setMaxValue(oldDie->getMaxValue()); - tmpdie->setValue(value); - tmpdie->setOp(oldDie->getOp()); - m_diceResult->insertResult(tmpdie); - } - } - } + Die* tmpdie= new Die(); + tmpdie->insertRollValue(value); + tmpdie->setBase(oldDie->getBase()); + tmpdie->setMaxValue(oldDie->getMaxValue()); + tmpdie->setValue(value); + tmpdie->setOp(oldDie->getOp()); + m_diceResult->insertResult(tmpdie); } } - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } } QString SplitNode::toString(bool withLabel) const |