diff options
| author | 2018-05-26 20:04:25 +0200 | |
|---|---|---|
| committer | 2018-06-01 13:51:59 +0200 | |
| commit | 00b6a6a04b341d5a6332083425e3524349cef521 (patch) | |
| tree | db53bd3f8532a702177458423fede3e3dd521f8e /node/explodedicenode.cpp | |
| parent | a16c3814e81502f1ff97b68ecf8ab5498bca7095 (diff) | |
| download | OneRoll-00b6a6a04b341d5a6332083425e3524349cef521.tar.gz OneRoll-00b6a6a04b341d5a6332083425e3524349cef521.zip | |
rename "exploSe" to "exploDe"
Diffstat (limited to 'node/explodedicenode.cpp')
| -rw-r--r-- | node/explodedicenode.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
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<DiceResult*>(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<Die*> 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; +} |