aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2019-09-05 00:40:40 +0200
committerRenaud G <renaud@rolisteam.org>2019-09-05 00:40:40 +0200
commit1c875b651df3afafe1df6b8ae412124d67e526a6 (patch)
treee79f03a998c10f9d546b4ece060af68956bacca4
parentb0ec3dfffda7991eee5775dcebb04731ba6a8389 (diff)
downloadOneRoll-1c875b651df3afafe1df6b8ae412124d67e526a6.tar.gz
OneRoll-1c875b651df3afafe1df6b8ae412124d67e526a6.zip
Copy die but prevent them to be displayed twice.
-rw-r--r--diceparser.cpp28
-rw-r--r--die.cpp14
-rw-r--r--die.h4
-rw-r--r--node/variablenode.cpp11
4 files changed, 42 insertions, 15 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index ea8f251..702c47f 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -539,6 +539,7 @@ void DiceParser::getDiceResultFromAllInstruction(QList<ExportedDiceResult>& resu
void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList, bool& homogeneous)
{
+ QStringList alreadySeenDice;
for(auto start : m_startNodes)
{
ExportedDiceResult diceValues;
@@ -559,23 +560,24 @@ void DiceParser::getLastDiceResult(QList<ExportedDiceResult>& diceValuesList, bo
ListDiceResult listpair;
for(auto& die : diceResult->getResultList())
{
- if(!die->hasBeenDisplayed())
+ if(die->hasBeenDisplayed() || alreadySeenDice.contains(die->getUuid()))
+ continue;
+
+ QList<qint64> valuesResult;
+ valuesResult.append(die->getValue());
+ die->displayed();
+ face= die->getFaces();
+ if(die->hasChildrenValue())
{
- QList<qint64> valuesResult;
- valuesResult.append(die->getValue());
- die->displayed();
- face= die->getFaces();
- if(die->hasChildrenValue())
+ for(qint64& i : die->getListValue())
{
- for(qint64& i : die->getListValue())
- {
- valuesResult.append(i);
- }
+ valuesResult.append(i);
}
- HighLightDice hlDice(valuesResult, die->isHighlighted(), die->getColor(),
- die->hasBeenDisplayed(), 0);
- listpair.append(hlDice);
}
+ HighLightDice hlDice(valuesResult, die->isHighlighted(), die->getColor(),
+ die->hasBeenDisplayed(), 0);
+ listpair.append(hlDice);
+ alreadySeenDice << die->getUuid();
}
if(!listpair.isEmpty())
{
diff --git a/die.cpp b/die.cpp
index 531853c..884472d 100644
--- a/die.cpp
+++ b/die.cpp
@@ -24,10 +24,12 @@
#include <QDateTime>
#include <QDebug>
+#include <QUuid>
#include <chrono>
Die::Die()
- : m_hasValue(false)
+ : m_uuid(QUuid::createUuid().toString(QUuid::WithoutBraces))
+ , m_hasValue(false)
, m_displayStatus(false)
, m_highlighted(true)
, m_base(1)
@@ -43,6 +45,7 @@ Die::Die(const Die& die)
m_rollResult= die.m_rollResult;
m_selected= die.m_selected;
m_hasValue= die.m_hasValue;
+ m_uuid= die.m_uuid;
m_displayStatus= die.m_displayStatus;
m_maxValue= die.m_maxValue;
m_highlighted= die.m_highlighted;
@@ -226,3 +229,12 @@ void Die::setOp(const Die::ArithmeticOperator& op)
{
m_op= op;
}
+QString Die::getUuid() const
+{
+ return m_uuid;
+}
+
+void Die::setUuid(const QString& uuid)
+{
+ m_uuid= uuid;
+}
diff --git a/die.h b/die.h
index eb43521..52ba7a2 100644
--- a/die.h
+++ b/die.h
@@ -144,7 +144,11 @@ public:
void setOp(const Die::ArithmeticOperator& op);
void setDisplayed(bool b);
+ QString getUuid() const;
+ void setUuid(const QString& uuid);
+
private:
+ QString m_uuid;
qint64 m_value= 0;
QList<qint64> m_rollResult;
bool m_selected= false;
diff --git a/node/variablenode.cpp b/node/variablenode.cpp
index e45214d..0f5a0b0 100644
--- a/node/variablenode.cpp
+++ b/node/variablenode.cpp
@@ -14,7 +14,16 @@ void VariableNode::run(ExecutionNode* previous)
auto result= value->getResult();
if(result)
{
- m_result= result->getCopy();
+ auto copy= result->getCopy();
+ auto diceResult= dynamic_cast<DiceResult*>(result);
+ if(nullptr != diceResult)
+ {
+ for(auto& die : diceResult->getResultList())
+ {
+ die->setDisplayed(false);
+ }
+ }
+ m_result= copy;
if(nullptr != m_nextNode)
{
m_nextNode->run(this);