From 9698a39a46f736cf37e31f8940e7c1a0a164185b Mon Sep 17 00:00:00 2001 From: Renaud G Date: Wed, 10 Jul 2019 11:49:45 +0200 Subject: Add valueslistnode --- node/valueslistnode.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 node/valueslistnode.cpp (limited to 'node/valueslistnode.cpp') diff --git a/node/valueslistnode.cpp b/node/valueslistnode.cpp new file mode 100644 index 0000000..e022741 --- /dev/null +++ b/node/valueslistnode.cpp @@ -0,0 +1,58 @@ +#include "valueslistnode.h" + +ValuesListNode::ValuesListNode() : m_diceResult(new DiceResult()) +{ + m_result= m_diceResult; +} + +void ValuesListNode::run(ExecutionNode* previous) +{ + m_previousNode= previous; + for(auto node : m_data) + { + node->run(this); + auto result= node->getResult(); + if(!result) + continue; + auto val= result->getResult(Result::SCALAR).toInt(); + Die* die= new Die(); + die->displayed(); + die->insertRollValue(val); + m_diceResult->insertResult(die); + } + + if(nullptr != m_nextNode) + { + m_nextNode->run(this); + } +} + +void ValuesListNode::insertValue(ExecutionNode* value) +{ + m_data.push_back(value); +} +ExecutionNode* ValuesListNode::getCopy() const +{ + ValuesListNode* node= new ValuesListNode(); + if(nullptr != m_nextNode) + { + node->setNextNode(m_nextNode->getCopy()); + } + return node; +} +QString ValuesListNode::toString(bool wl) const +{ + if(wl) + { + return QString("%1 [label=\"ValuesListNode list:\"]").arg(m_id); + } + else + { + return m_id; + } +} +qint64 ValuesListNode::getPriority() const +{ + qint64 priority= 4; + return priority; +} -- cgit v1.2.3-70-g09d2