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/occurencecountnode.cpp | |
| parent | e4dc41cdc3ebb84ef7e42f5cf261e36fe874c901 (diff) | |
| download | OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.tar.gz OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.zip | |
Add execute node.
Diffstat (limited to 'src/libparser/node/occurencecountnode.cpp')
| -rw-r--r-- | src/libparser/node/occurencecountnode.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/libparser/node/occurencecountnode.cpp b/src/libparser/node/occurencecountnode.cpp index fc5c2f2..780ca08 100644 --- a/src/libparser/node/occurencecountnode.cpp +++ b/src/libparser/node/occurencecountnode.cpp @@ -27,13 +27,14 @@ OccurenceCountNode::OccurenceCountNode() : ExecutionNode() {} void OccurenceCountNode::run(ExecutionNode* previous) { + if(isValid(!previous, Dice::ERROR_CODE::NO_PREVIOUS_ERROR, tr("No Previous node"))) + return; + m_previousNode= previous; std::map<qint64, qint64> mapOccurence; - if(nullptr == m_previousNode) - return; DiceResult* previousDiceResult= dynamic_cast<DiceResult*>(m_previousNode->getResult()); - if(nullptr == previousDiceResult) + if(isValid(!previousDiceResult, Dice::ERROR_CODE::NO_VALID_RESULT, tr("No Valid result"))) return; auto const& diceList= previousDiceResult->getResultList(); @@ -52,14 +53,10 @@ void OccurenceCountNode::run(ExecutionNode* previous) } std::sort(vec.begin(), vec.end()); - if(nullptr == m_nextNode) - { + if(!m_nextNode) runForStringResult(mapOccurence, vec); - } else - { runForDiceResult(mapOccurence); - } } QString OccurenceCountNode::toString(bool label) const { @@ -177,9 +174,4 @@ void OccurenceCountNode::runForDiceResult(const std::map<qint64, qint64>& mapOcc m_diceResult->insertResult(die); } } - - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } } |