From cb1dcb5ee28994a2cd691ad696a5ba4c3c3802ea Mon Sep 17 00:00:00 2001 From: Renaud Guezennec Date: Wed, 23 Oct 2024 15:42:08 +0200 Subject: Add execute node. --- src/libparser/node/explodedicenode.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/libparser/node/explodedicenode.cpp') 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 f= [&hasExploded, this, limit](Die* die, qint64) { static QHash explodePerDice; - if(Dice::CONDITION_STATE::ALWAYSTRUE - == m_validatorList->isValidRangeSize(std::make_pair(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(die->getBase())) - .arg(static_cast(die->getMaxValue())))); - } + auto validity + = m_validatorList->isValidRangeSize(std::make_pair(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(die->getBase())) + .arg(static_cast(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() { -- cgit v1.2.3-70-g09d2