From 00b6a6a04b341d5a6332083425e3524349cef521 Mon Sep 17 00:00:00 2001 From: Robin Moussu Date: Sat, 26 May 2018 20:04:25 +0200 Subject: rename "exploSe" to "exploDe" --- node/explodedicenode.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 node/explodedicenode.cpp (limited to 'node/explodedicenode.cpp') diff --git a/node/explodedicenode.cpp b/node/explodedicenode.cpp new file mode 100644 index 0000000..d640eaa --- /dev/null +++ b/node/explodedicenode.cpp @@ -0,0 +1,91 @@ +#include "explodedicenode.h" + +ExplodeDiceNode::ExplodeDiceNode() + : m_diceResult(new DiceResult()),m_validator(nullptr) +{ + m_result = m_diceResult; +} +void ExplodeDiceNode::run(ExecutionNode* previous) +{ + m_previousNode = previous; + if((nullptr!=previous)&&(nullptr!=previous->getResult())) + { + DiceResult* previous_result = dynamic_cast(previous->getResult()); + m_result->setPrevious(previous_result); + if(nullptr!=previous_result) + { + for(Die* die: previous_result->getResultList()) + { + Die* tmpdie = new Die(); + *tmpdie=*die; + m_diceResult->insertResult(tmpdie); + die->displayed(); + } + + QList list = m_diceResult->getResultList(); + + for(Die* die: list) + { + while(m_validator->hasValid(die,false)) + { + die->roll(true); + } + } + // m_diceResult->setResultList(list); + + if(nullptr!=m_nextNode) + { + m_nextNode->run(this); + } + } + else + { + qDebug() << "test!!"; + } + } +} +ExplodeDiceNode::~ExplodeDiceNode() +{ + if(nullptr!=m_validator) + { + delete m_validator; + } +} +void ExplodeDiceNode::setValidator(Validator* val) +{ + m_validator = val; +} +QString ExplodeDiceNode::toString(bool withlabel) const +{ + if(withlabel) + { + return QString("%1 [label=\"ExplodeDiceNode %2\"]").arg(m_id).arg(m_validator->toString()); + } + else + { + return m_id; + } +} +qint64 ExplodeDiceNode::getPriority() const +{ + qint64 priority=0; + if(nullptr!=m_previousNode) + { + priority = m_previousNode->getPriority(); + } + return priority; +} + +ExecutionNode* ExplodeDiceNode::getCopy() const +{ + ExplodeDiceNode* node = new ExplodeDiceNode(); + if(nullptr!=m_validator) + { + node->setValidator(m_validator->getCopy()); + } + if(nullptr!=m_nextNode) + { + node->setNextNode(m_nextNode->getCopy()); + } + return node; +} -- cgit v1.2.3-70-g09d2