File indexing completed on 2024-05-12 05:39:29

0001 #include "valueslistnode.h"
0002 
0003 #include "variablenode.h"
0004 
0005 ValuesListNode::ValuesListNode() : m_diceResult(new DiceResult())
0006 {
0007     m_result= m_diceResult;
0008 }
0009 
0010 void ValuesListNode::run(ExecutionNode* previous)
0011 {
0012     m_previousNode= previous;
0013     for(auto node : m_data)
0014     {
0015         node->run(this);
0016         auto result= node->getResult();
0017         if(!result)
0018             continue;
0019         auto val= result->getResult(Dice::RESULT_TYPE::SCALAR).toInt();
0020         Die* die= new Die();
0021         auto dyna= dynamic_cast<VariableNode*>(node);
0022         if(nullptr != dyna)
0023             dyna->setDisplayed();
0024         die->insertRollValue(val);
0025         m_diceResult->insertResult(die);
0026     }
0027 
0028     if(nullptr != m_nextNode)
0029     {
0030         m_nextNode->run(this);
0031     }
0032 }
0033 
0034 void ValuesListNode::insertValue(ExecutionNode* value)
0035 {
0036     m_data.push_back(value);
0037 }
0038 ExecutionNode* ValuesListNode::getCopy() const
0039 {
0040     ValuesListNode* node= new ValuesListNode();
0041     if(nullptr != m_nextNode)
0042     {
0043         node->setNextNode(m_nextNode->getCopy());
0044     }
0045     return node;
0046 }
0047 QString ValuesListNode::toString(bool wl) const
0048 {
0049     if(wl)
0050     {
0051         return QString("%1 [label=\"ValuesListNode list:\"]").arg(m_id);
0052     }
0053     else
0054     {
0055         return m_id;
0056     }
0057 }
0058 qint64 ValuesListNode::getPriority() const
0059 {
0060     qint64 priority= 4;
0061     return priority;
0062 }