From eef188c6cc953fcff9cf4491b0ae8256608caa14 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Tue, 23 Oct 2018 20:01:40 +0200 Subject: first draft for diceresult --- diceparser.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index 41a91e5..0d41f4d 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -494,19 +494,23 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias) } void DiceParser::getLastDiceResult(QList& diceValuesList,bool& homogeneous) { + int i = 0; for(auto start : m_startNodes) { 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) { @@ -516,8 +520,9 @@ 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(); @@ -533,9 +538,14 @@ void DiceParser::getLastDiceResult(QList& diceValuesList,boo //QPair,bool> pair(valuesResult,die->isHighlighted()); 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); -- cgit v1.2.3-70-g09d2 From bd4a0c837bd5e3b4dbf9d3dcef892850d04ec6ac Mon Sep 17 00:00:00 2001 From: Renaud Guezennec Date: Wed, 7 Nov 2018 09:25:23 +0000 Subject: fix compilation --- diceparser.cpp | 2 +- result/diceresult.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index 41a91e5..6108eb8 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #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() diff --git a/result/diceresult.h b/result/diceresult.h index 8ff041f..8ea807a 100644 --- a/result/diceresult.h +++ b/result/diceresult.h @@ -22,6 +22,7 @@ #ifndef DICERESULT_H #define DICERESULT_H #include +#include #include "die.h" #include "result.h" -- cgit v1.2.3-70-g09d2 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(-) (limited to 'diceparser.cpp') 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 From 1d8bd391b1df4fd2f2f274828db14c9ce695eb8b Mon Sep 17 00:00:00 2001 From: Renaud G Date: Fri, 9 Nov 2018 23:47:26 +0100 Subject: fix some warnings --- diceparser.cpp | 2 -- result/diceresult.cpp | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index 6182a89..daa8d9d 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -495,7 +495,6 @@ QStringList DiceParser::getAllDiceResult(bool& hasAlias) void DiceParser::getDiceResultFromAllInstruction(QList& resultList) { - int i = 0; for(auto start : m_startNodes) { ExecutionNode* next = getLeafNode(start); @@ -525,7 +524,6 @@ void DiceParser::getDiceResultFromAllInstruction(QList& resu void DiceParser::getLastDiceResult(QList& diceValuesList,bool& homogeneous) { - int i = 0; for(auto start : m_startNodes) { ExportedDiceResult diceValues; diff --git a/result/diceresult.cpp b/result/diceresult.cpp index 7894b60..c1089dd 100644 --- a/result/diceresult.cpp +++ b/result/diceresult.cpp @@ -114,6 +114,9 @@ qreal DiceResult::getScalarResult() case Die::MINUS: scalar-=tmp->getValue(); break; + case Die::POW: + scalar=static_cast(pow(static_cast(scalar),static_cast(tmp->getValue()))); + break; case Die::DIVIDE: case Die::INTEGER_DIVIDE: if(tmp->getValue()!=0) @@ -135,8 +138,6 @@ qreal DiceResult::getScalarResult() } return scalar; } - - return 0; } Die::ArithmeticOperator DiceResult::getOperator() const -- cgit v1.2.3-70-g09d2