From 0994c2713eb17a7568369bbb09ca73d4e4045028 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 27 Oct 2018 00:35:00 +0200 Subject: Commit before rebase. --- diceparser.cpp | 46 +++++++++++++++++++++++++++++++++------------- diceparser.h | 3 ++- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/diceparser.cpp b/diceparser.cpp index 0d41f4d..6182a89 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -492,6 +492,37 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias) return stringListResult; } + +void DiceParser::getDiceResultFromAllInstruction(QList& resultList) +{ + int i = 0; + for(auto start : m_startNodes) + { + ExecutionNode* next = getLeafNode(start); + Result* result=next->getResult(); + ExportedDiceResult nodeResult; + while(nullptr!=result) + { + if(result->hasResultOfType(Result::DICE_LIST)) + { + DiceResult* diceResult = dynamic_cast(result); + QList list; + quint64 faces = 0; + + for(Die* die : diceResult->getResultList()) + { + faces = die->getFaces(); + HighLightDice hlDice(die->getListValue(),die->isHighlighted(),die->getColor(), die->hasBeenDisplayed(),die->getFaces()); + list.append(hlDice); + } + nodeResult.insert(static_cast(faces),list); + } + result = result->getPrevious(); + } + resultList.append(nodeResult); + } +} + void DiceParser::getLastDiceResult(QList& diceValuesList,bool& homogeneous) { int i = 0; @@ -500,17 +531,13 @@ void DiceParser::getLastDiceResult(QList& diceValuesList,boo ExportedDiceResult diceValues; ExecutionNode* next = getLeafNode(start); Result* result=next->getResult(); - qDebug() << "tour:"<hasResultOfType(Result::DICE_LIST)) { - qDebug() << "has diceresult"<(result); if(nullptr!=diceResult) { - qDebug() << "cast diceresult"; if(homogeneous) { @@ -520,9 +547,8 @@ void DiceParser::getLastDiceResult(QList& diceValuesList,boo ListDiceResult listpair; for(Die* die : diceResult->getResultList()) { - // if(!die->hasBeenDisplayed()) + if(!die->hasBeenDisplayed()) { - qDebug() << "dice has NOT been displayed"; QList valuesResult; valuesResult.append(die->getValue()); die->displayed(); @@ -534,18 +560,12 @@ void DiceParser::getLastDiceResult(QList& diceValuesList,boo valuesResult.append(i); } } - HighLightDice hlDice(valuesResult,die->isHighlighted(),die->getColor()); - //QPair,bool> pair(valuesResult,die->isHighlighted()); + HighLightDice hlDice(valuesResult,die->isHighlighted(),die->getColor(), die->hasBeenDisplayed(),0); listpair.append(hlDice); } - // else - { - qDebug() << "dice has been displayed"; - } } if(!listpair.isEmpty()) { - qDebug() << "list pair not empty "; if(!diceValues.contains(face)) { diceValues.insert(face,listpair); diff --git a/diceparser.h b/diceparser.h index 2ede553..3d5ba8f 100644 --- a/diceparser.h +++ b/diceparser.h @@ -129,7 +129,7 @@ public: * @brief getLastDiceResult * @return */ - void getLastDiceResult(QList& diceValues,bool& homogeneous); + void getLastDiceResult(QList& diceValues, bool& homogeneous); /** * @brief hasIntegerResultNotInFirst * @return @@ -219,6 +219,7 @@ public: bool readOptionFromNull(QString &str, ExecutionNode *&node); bool readInstructionList(QString &str); + void getDiceResultFromAllInstruction(QList &resultList); protected: bool readParameterNode(QString &str, ExecutionNode *&node); private: -- cgit v1.2.3-70-g09d2