diff options
| author | 2018-12-08 21:14:43 +0100 | |
|---|---|---|
| committer | 2018-12-08 21:14:43 +0100 | |
| commit | bb47c33763d250cc424216a1dd0fedefa80532a3 (patch) | |
| tree | 3e60a84a8cd963d828299d49256ed6cd7c1bdd6f /diceparser.cpp | |
| parent | b28b096d2fe3ddfed099ee8cc33c8caa504d7c83 (diff) | |
| parent | 48de810db56b728726ec8b499b9a12c687b53795 (diff) | |
| download | OneRoll-bb47c33763d250cc424216a1dd0fedefa80532a3.tar.gz OneRoll-bb47c33763d250cc424216a1dd0fedefa80532a3.zip | |
Merge branch 'master' of github.com:Rolisteam/DiceParser
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index 41a91e5..3e90fe8 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -24,6 +24,7 @@ #include <QStringList> #include <QObject> #include <QFile> +#include <functional> #include "node/startingnode.h" #include "node/scalaroperatornode.h" @@ -48,7 +49,6 @@ #include "node/variablenode.h" #include "node/bind.h" - #define DEFAULT_FACES_NUMBER 10 DiceParser::DiceParser() @@ -492,6 +492,36 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias) return stringListResult; } + +void DiceParser::getDiceResultFromAllInstruction(QList<ExportedDiceResult>& resultList) +{ + 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<DiceResult*>(result); + QList<HighLightDice> 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<int>(faces),list); + } + result = result->getPrevious(); + } + resultList.append(nodeResult); + } +} + void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,bool& homogeneous) { for(auto start : m_startNodes) @@ -499,7 +529,6 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo ExportedDiceResult diceValues; ExecutionNode* next = getLeafNode(start); Result* result=next->getResult(); - while(nullptr!=result) { if(result->hasResultOfType(Result::DICE_LIST)) @@ -529,8 +558,7 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo valuesResult.append(i); } } - HighLightDice hlDice(valuesResult,die->isHighlighted(),die->getColor()); - //QPair<QList<quint64>,bool> pair(valuesResult,die->isHighlighted()); + HighLightDice hlDice(valuesResult,die->isHighlighted(),die->getColor(), die->hasBeenDisplayed(),0); listpair.append(hlDice); } } |