From 2f67beb05264e0f74250852efb3133e074309f71 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 22 Feb 2022 22:02:00 +0100 Subject: update switch --- node/switchcasenode.cpp | 57 ++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/node/switchcasenode.cpp b/node/switchcasenode.cpp index b118243..61938a9 100644 --- a/node/switchcasenode.cpp +++ b/node/switchcasenode.cpp @@ -54,37 +54,46 @@ void SwitchCaseNode::run(ExecutionNode* previous) return; } - QStringList resultList; - for(auto const& info : qAsConst(m_branchList)) + auto diceResult= dynamic_cast(previousResult); + + QSet alreadyValidDice; + QStringList finalResultList; + if(diceResult) { - if(m_stopAtFirst && !resultList.isEmpty()) - break; - if(info->validatorList) + for(auto die : diceResult->getResultList()) { - info->validatorList->validResult(previousResult, true, false, [&info, this, &resultList](Die*, qint64) { - info->node->run(m_previousNode); - auto lastNode= ParsingToolBox::getLeafNode(info->node); - if(lastNode && lastNode->getResult()) + QStringList resultList; + for(auto const& info : qAsConst(m_branchList)) + { + if(m_stopAtFirst && !resultList.isEmpty()) + break; + if(info->validatorList) { - resultList << lastNode->getResult()->getStringResult(); + if(info->validatorList->hasValid(die, true)) + { + auto lastNode= ParsingToolBox::getLeafNode(info->node); + if(lastNode && lastNode->getResult()) + { + resultList << lastNode->getResult()->getStringResult(); + } + } + } + else if(resultList.isEmpty()) + { + info->node->run(m_previousNode); + auto lastNode= ParsingToolBox::getLeafNode(info->node); + if(lastNode && lastNode->getResult()) + { + resultList << lastNode->getResult()->getStringResult(); + } + else + resultList << QString(); } - else - resultList << QString(); - }); - } - else if(resultList.isEmpty()) - { - info->node->run(m_previousNode); - auto lastNode= ParsingToolBox::getLeafNode(info->node); - if(lastNode && lastNode->getResult()) - { - resultList << lastNode->getResult()->getStringResult(); } - else - resultList << QString(); + finalResultList << resultList; } } - for(auto const& str : qAsConst(resultList)) + for(auto const& str : qAsConst(finalResultList)) m_stringResult->addText(str); if(m_stringResult->getText().isEmpty()) -- cgit v1.2.3-70-g09d2