aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libparser/node/explodedicenode.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/explodedicenode.cpp
parente4dc41cdc3ebb84ef7e42f5cf261e36fe874c901 (diff)
downloadOneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.tar.gz
OneRoll-cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea.zip
Add execute node.
Diffstat (limited to 'src/libparser/node/explodedicenode.cpp')
-rw-r--r--src/libparser/node/explodedicenode.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/libparser/node/explodedicenode.cpp b/src/libparser/node/explodedicenode.cpp
index 5f51f95..136611a 100644
--- a/src/libparser/node/explodedicenode.cpp
+++ b/src/libparser/node/explodedicenode.cpp
@@ -31,7 +31,7 @@ void ExplodeDiceNode::run(ExecutionNode* previous)
qint64 limit= -1;
if(m_limit)
{
- m_limit->run(this);
+ m_limit->execute(this);
auto limitNode= ParsingToolBox::getLeafNode(m_limit);
auto result= limitNode->getResult();
if(result->hasResultOfType(Dice::RESULT_TYPE::SCALAR))
@@ -42,16 +42,15 @@ void ExplodeDiceNode::run(ExecutionNode* previous)
std::function<void(Die*, qint64)> f= [&hasExploded, this, limit](Die* die, qint64)
{
static QHash<Die*, qint64> explodePerDice;
- if(Dice::CONDITION_STATE::ALWAYSTRUE
- == m_validatorList->isValidRangeSize(std::make_pair<qint64, qint64>(die->getBase(), die->getMaxValue())))
- {
- m_errors.insert(Dice::ERROR_CODE::ENDLESS_LOOP_ERROR,
- QObject::tr("Condition (%1) cause an endless loop with this dice: %2")
- .arg(toString(true))
- .arg(QStringLiteral("d[%1,%2]")
- .arg(static_cast<int>(die->getBase()))
- .arg(static_cast<int>(die->getMaxValue()))));
- }
+ auto validity
+ = m_validatorList->isValidRangeSize(std::make_pair<qint64, qint64>(die->getBase(), die->getMaxValue()));
+ isValid(Dice::CONDITION_STATE::ALWAYSTRUE == validity, Dice::ERROR_CODE::ENDLESS_LOOP_ERROR,
+ QObject::tr("Condition (%1) cause an endless loop with this dice: %2")
+ .arg(toString(true))
+ .arg(QStringLiteral("d[%1,%2]")
+ .arg(static_cast<int>(die->getBase()))
+ .arg(static_cast<int>(die->getMaxValue()))));
+
hasExploded= true;
if(limit >= 0)
{
@@ -70,11 +69,6 @@ void ExplodeDiceNode::run(ExecutionNode* previous)
hasExploded= false;
m_validatorList->validResult(m_diceResult, false, false, f);
} while(hasExploded);
-
- if(nullptr != m_nextNode)
- {
- m_nextNode->run(this);
- }
}
ExplodeDiceNode::~ExplodeDiceNode()
{