aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2022-02-22 22:02:00 +0100
committerRenaud Guezennec <renaud@rolisteam.org>2022-03-03 13:14:59 +0000
commit2f67beb05264e0f74250852efb3133e074309f71 (patch)
treec965d3d21ef8a2916cbf1bf4b1401167e7f81049 /node
parentc31f3d09f2f886147b6f1fef605075d3be1cf5a6 (diff)
downloadOneRoll-2f67beb05264e0f74250852efb3133e074309f71.tar.gz
OneRoll-2f67beb05264e0f74250852efb3133e074309f71.zip
update switch
Diffstat (limited to 'node')
-rw-r--r--node/switchcasenode.cpp57
1 files 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<DiceResult*>(previousResult);
+
+ QSet<QString> 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())