diff options
| author | 2019-07-12 21:00:42 +0000 | |
|---|---|---|
| committer | 2019-07-12 21:00:42 +0000 | |
| commit | 5c2fbf1edc7547333739d3d643c4abee5ce6f942 (patch) | |
| tree | 6e9f4a709fd497fed1cf7f24bb2c3db421eb8711 /node/valueslistnode.cpp | |
| parent | 4f495aaaecb3118b835504e9bc1347f934aa49d1 (diff) | |
| parent | a3c3551815845cbc4bdf891b5f01406414abd4d2 (diff) | |
| download | OneRoll-5c2fbf1edc7547333739d3d643c4abee5ce6f942.tar.gz OneRoll-5c2fbf1edc7547333739d3d643c4abee5ce6f942.zip | |
Merge branch 'new_operator_and_fix' into 'master'
Value list node and occurence improvements
See merge request kde/rolisteam-diceparser!1
Diffstat (limited to 'node/valueslistnode.cpp')
| -rw-r--r-- | node/valueslistnode.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/node/valueslistnode.cpp b/node/valueslistnode.cpp new file mode 100644 index 0000000..b31ee84 --- /dev/null +++ b/node/valueslistnode.cpp @@ -0,0 +1,62 @@ +#include "valueslistnode.h" + +#include "variablenode.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(); + auto dyna= dynamic_cast<VariableNode*>(node); + if(nullptr != dyna) + 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; +} |