aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libparser/node/uniquenode.cpp
diff options
context:
space:
mode:
authorRenaud Guezennec <renaud@rolisteam.org>2024-10-23 15:42:08 +0200
committerRenaud Guezennec <renaud@rolisteam.org>2024-12-29 14:46:30 +0100
commitcb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea (patch)
treec261de4ad8d0f85aec0200bf500e9579437577df /src/libparser/node/uniquenode.cpp
parente4dc41cdc3ebb84ef7e42f5cf261e36fe874c901 (diff)
downloadOneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.tar.gz
OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.zip
Add execute node.
Diffstat (limited to 'src/libparser/node/uniquenode.cpp')
-rw-r--r--src/libparser/node/uniquenode.cpp52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/libparser/node/uniquenode.cpp b/src/libparser/node/uniquenode.cpp
index c4668be..e5ede7b 100644
--- a/src/libparser/node/uniquenode.cpp
+++ b/src/libparser/node/uniquenode.cpp
@@ -27,38 +27,34 @@ UniqueNode::UniqueNode() : m_diceResult(new DiceResult())
}
void UniqueNode::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(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;
+
+ auto const& resultList= dice->getResultList();
+ std::vector<qint64> formerValues;
+ formerValues.reserve(resultList.size());
+ for(auto& oldDie : resultList)
{
- m_result->setPrevious(previous->getResult());
- Result* tmpResult= previous->getResult();
- if(nullptr != tmpResult)
- {
- DiceResult* dice= dynamic_cast<DiceResult*>(tmpResult);
- if(nullptr != dice)
- {
- auto const& resultList= dice->getResultList();
- std::vector<qint64> formerValues;
- formerValues.reserve(resultList.size());
- for(auto& oldDie : resultList)
- {
- auto value= oldDie->getValue();
- auto it= std::find(formerValues.begin(), formerValues.end(), value);
+ auto value= oldDie->getValue();
+ auto it= std::find(formerValues.begin(), formerValues.end(), value);
- if(it == formerValues.end())
- {
- auto die= new Die(*oldDie);
- m_diceResult->insertResult(die);
- formerValues.push_back(value);
- }
- oldDie->displayed();
- }
- }
+ if(it == formerValues.end())
+ {
+ auto die= new Die(*oldDie);
+ m_diceResult->insertResult(die);
+ formerValues.push_back(value);
}
- }
- if(nullptr != m_nextNode)
- {
- m_nextNode->run(this);
+ oldDie->displayed();
}
}