aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2022-01-22 00:11:13 +0100
committerRenaud G <renaud@rolisteam.org>2022-01-22 00:19:30 +0100
commit187774c338c35864a2d3ad1c95ad06e9685c8427 (patch)
treea7a7a23b00afd3c7ad489d4f5610ee305e7217be
parent82eb7c25f863c930d3138cdcbc95fb797cc77600 (diff)
downloadOneRoll-187774c338c35864a2d3ad1c95ad06e9685c8427.tar.gz
OneRoll-187774c338c35864a2d3ad1c95ad06e9685c8427.zip
Fix valueslist with variable values.
-rw-r--r--node/valueslistnode.cpp2
-rw-r--r--node/variablenode.cpp53
-rw-r--r--node/variablenode.h2
3 files changed, 37 insertions, 20 deletions
diff --git a/node/valueslistnode.cpp b/node/valueslistnode.cpp
index d378350..33a347d 100644
--- a/node/valueslistnode.cpp
+++ b/node/valueslistnode.cpp
@@ -20,7 +20,7 @@ void ValuesListNode::run(ExecutionNode* previous)
Die* die= new Die();
auto dyna= dynamic_cast<VariableNode*>(node);
if(nullptr != dyna)
- die->displayed();
+ dyna->setDisplayed();
die->insertRollValue(val);
m_diceResult->insertResult(die);
}
diff --git a/node/variablenode.cpp b/node/variablenode.cpp
index f48c254..416be86 100644
--- a/node/variablenode.cpp
+++ b/node/variablenode.cpp
@@ -9,26 +9,27 @@ void VariableNode::run(ExecutionNode* previous)
{
auto value= (*m_data)[m_index];
value= ParsingToolBox::getLeafNode(value);
- if(nullptr != value)
+ if(nullptr == value)
+ return;
+
+ auto result= value->getResult();
+ if(!result)
+ return;
+
+ auto copy= result->getCopy();
+ auto diceResult= dynamic_cast<DiceResult*>(result);
+ if(nullptr == diceResult)
+ return;
+
+ for(auto& die : diceResult->getResultList())
+ {
+ die->setDisplayed(false);
+ }
+
+ m_result= copy;
+ if(nullptr != m_nextNode)
{
- auto result= value->getResult();
- if(result)
- {
- 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);
- }
- }
+ m_nextNode->run(this);
}
}
else
@@ -37,6 +38,20 @@ void VariableNode::run(ExecutionNode* previous)
}
}
+void VariableNode::setDisplayed()
+{
+ if(!m_result)
+ return;
+ auto diceResult= dynamic_cast<DiceResult*>(m_result);
+ if(nullptr == diceResult)
+ return;
+
+ for(auto& die : diceResult->getResultList())
+ {
+ die->setDisplayed(true);
+ }
+}
+
QString VariableNode::toString(bool withLabel) const
{
if(withLabel)
diff --git a/node/variablenode.h b/node/variablenode.h
index 5306ddb..8bf1cb1 100644
--- a/node/variablenode.h
+++ b/node/variablenode.h
@@ -25,6 +25,8 @@ public:
std::vector<ExecutionNode*>* getData() const;
void setData(std::vector<ExecutionNode*>* data);
+ void setDisplayed();
+
private:
quint64 m_index;
std::vector<ExecutionNode*>* m_data= nullptr;