aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2018-10-27 00:35:00 +0200
committerRenaud G <renaud@rolisteam.org>2018-11-09 23:47:36 +0100
commit0994c2713eb17a7568369bbb09ca73d4e4045028 (patch)
treecb1e34362ff6399fefa39febe0e3b81548fc33e2
parentc98b88063b0edd45c240902a767804f232af9a43 (diff)
downloadOneRoll-0994c2713eb17a7568369bbb09ca73d4e4045028.tar.gz
OneRoll-0994c2713eb17a7568369bbb09ca73d4e4045028.zip
Commit before rebase.
-rw-r--r--diceparser.cpp46
-rw-r--r--diceparser.h3
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<ExportedDiceResult>& 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<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)
{
int i = 0;
@@ -500,17 +531,13 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
ExportedDiceResult diceValues;
ExecutionNode* next = getLeafNode(start);
Result* result=next->getResult();
- qDebug() << "tour:"<<i++;
while(nullptr!=result)
{
- qDebug()<< "result is not null"<<i;
if(result->hasResultOfType(Result::DICE_LIST))
{
- qDebug() << "has diceresult"<<i;
DiceResult* diceResult = dynamic_cast<DiceResult*>(result);
if(nullptr!=diceResult)
{
- qDebug() << "cast diceresult";
if(homogeneous)
{
@@ -520,9 +547,8 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList,boo
ListDiceResult listpair;
for(Die* die : diceResult->getResultList())
{
- // if(!die->hasBeenDisplayed())
+ if(!die->hasBeenDisplayed())
{
- qDebug() << "dice has NOT been displayed";
QList<qint64> valuesResult;
valuesResult.append(die->getValue());
die->displayed();
@@ -534,18 +560,12 @@ 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);
}
- // 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<ExportedDiceResult>& diceValues,bool& homogeneous);
+ void getLastDiceResult(QList<ExportedDiceResult>& diceValues, bool& homogeneous);
/**
* @brief hasIntegerResultNotInFirst
* @return
@@ -219,6 +219,7 @@ public:
bool readOptionFromNull(QString &str, ExecutionNode *&node);
bool readInstructionList(QString &str);
+ void getDiceResultFromAllInstruction(QList<ExportedDiceResult> &resultList);
protected:
bool readParameterNode(QString &str, ExecutionNode *&node);
private: