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 ++++++++++++++++++++++++++++++++++++++++++++++++ node/explodedicenode.h | 28 +++++++++++++++ node/explosedicenode.cpp | 91 ------------------------------------------------ node/explosedicenode.h | 28 --------------- node/ifnode.h | 2 +- node/node.pri | 4 +-- 6 files changed, 122 insertions(+), 122 deletions(-) create mode 100644 node/explodedicenode.cpp create mode 100644 node/explodedicenode.h delete mode 100644 node/explosedicenode.cpp delete mode 100644 node/explosedicenode.h (limited to 'node') 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; +} diff --git a/node/explodedicenode.h b/node/explodedicenode.h new file mode 100644 index 0000000..feea86f --- /dev/null +++ b/node/explodedicenode.h @@ -0,0 +1,28 @@ +#ifndef EXPLOSEDICENODE_H +#define EXPLOSEDICENODE_H + +#include "executionnode.h" +#include "result/diceresult.h" +#include "validator.h" +#include + +/** + * @brief The ExplodeDiceNode class explode dice while is valid by the validator. + */ +class ExplodeDiceNode : public ExecutionNode +{ +public: + ExplodeDiceNode(); + virtual ~ExplodeDiceNode(); + virtual void run(ExecutionNode* previous = nullptr); + virtual void setValidator(Validator* ); + virtual QString toString(bool )const; + virtual qint64 getPriority() const; + + virtual ExecutionNode *getCopy() const; +protected: + DiceResult* m_diceResult; + Validator* m_validator; +}; + +#endif // EXPLOSEDICENODE_H diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp deleted file mode 100644 index f818294..0000000 --- a/node/explosedicenode.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "explosedicenode.h" - -ExploseDiceNode::ExploseDiceNode() - : m_diceResult(new DiceResult()),m_validator(nullptr) -{ - m_result = m_diceResult; -} -void ExploseDiceNode::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!!"; - } - } -} -ExploseDiceNode::~ExploseDiceNode() -{ - if(nullptr!=m_validator) - { - delete m_validator; - } -} -void ExploseDiceNode::setValidator(Validator* val) -{ - m_validator = val; -} -QString ExploseDiceNode::toString(bool withlabel) const -{ - if(withlabel) - { - return QString("%1 [label=\"ExploseDiceNode %2\"]").arg(m_id).arg(m_validator->toString()); - } - else - { - return m_id; - } -} -qint64 ExploseDiceNode::getPriority() const -{ - qint64 priority=0; - if(nullptr!=m_previousNode) - { - priority = m_previousNode->getPriority(); - } - return priority; -} - -ExecutionNode* ExploseDiceNode::getCopy() const -{ - ExploseDiceNode* node = new ExploseDiceNode(); - if(nullptr!=m_validator) - { - node->setValidator(m_validator->getCopy()); - } - if(nullptr!=m_nextNode) - { - node->setNextNode(m_nextNode->getCopy()); - } - return node; -} diff --git a/node/explosedicenode.h b/node/explosedicenode.h deleted file mode 100644 index 6b582a3..0000000 --- a/node/explosedicenode.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef EXPLOSEDICENODE_H -#define EXPLOSEDICENODE_H - -#include "executionnode.h" -#include "result/diceresult.h" -#include "validator.h" -#include - -/** - * @brief The ExploseDiceNode class explose dice while is valid by the validator. - */ -class ExploseDiceNode : public ExecutionNode -{ -public: - ExploseDiceNode(); - virtual ~ExploseDiceNode(); - virtual void run(ExecutionNode* previous = nullptr); - virtual void setValidator(Validator* ); - virtual QString toString(bool )const; - virtual qint64 getPriority() const; - - virtual ExecutionNode *getCopy() const; -protected: - DiceResult* m_diceResult; - Validator* m_validator; -}; - -#endif // EXPLOSEDICENODE_H diff --git a/node/ifnode.h b/node/ifnode.h index 9205000..29fcec3 100644 --- a/node/ifnode.h +++ b/node/ifnode.h @@ -26,7 +26,7 @@ #include /** - * @brief The ifNode class explose dice while is valid by the validator. + * @brief The ifNode class explode dice while is valid by the validator. */ class IfNode : public ExecutionNode { diff --git a/node/node.pri b/node/node.pri index 1814a5d..6cf7005 100644 --- a/node/node.pri +++ b/node/node.pri @@ -8,7 +8,7 @@ HEADERS += \ $$PWD/sortresult.h \ $$PWD/keepdiceexecnode.h \ $$PWD/countexecutenode.h \ - $$PWD/explosedicenode.h \ + $$PWD/explodedicenode.h \ $$PWD/parenthesesnode.h \ $$PWD/helpnode.h \ $$PWD/jumpbackwardnode.h \ @@ -25,7 +25,7 @@ SOURCES += \ $$PWD/sortresult.cpp \ $$PWD/keepdiceexecnode.cpp \ $$PWD/countexecutenode.cpp \ - $$PWD/explosedicenode.cpp \ + $$PWD/explodedicenode.cpp \ $$PWD/parenthesesnode.cpp \ $$PWD/helpnode.cpp \ $$PWD/jumpbackwardnode.cpp \ -- cgit v1.2.3-70-g09d2