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" --- HelpMe.md | 4 +-- README.md | 8 ++--- cli/CMakeLists.txt | 2 +- diceparser.cpp | 47 ++++++++++++++----------- diceparser.h | 8 ++--- diceparser.pri | 4 +-- irc/CMakeLists.txt | 2 +- mobile/CMakeLists.txt | 2 +- node/explodedicenode.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ node/explodedicenode.h | 28 +++++++++++++++ node/explosedicenode.cpp | 91 ------------------------------------------------ node/explosedicenode.h | 28 --------------- node/ifnode.h | 2 +- node/node.pri | 4 +-- webserver/CMakeLists.txt | 2 +- 15 files changed, 164 insertions(+), 159 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 diff --git a/HelpMe.md b/HelpMe.md index c4f067f..5692285 100644 --- a/HelpMe.md +++ b/HelpMe.md @@ -487,7 +487,7 @@ The scalar value sets the validator on eguality between the dice value and the v > 4d10e10 -This command means : roll 4 dice and they explose on 10. +This command means : roll 4 dice and they explode on 10. ### Range @@ -535,7 +535,7 @@ Roll 3 dice with 100 faces > 10D10e[=10]s -Roll 10 dice with 10 faces, 10 exploses, and sort the result. +Roll 10 dice with 10 faces, 10 explodes, and sort the result. > 100291D66666666s diff --git a/README.md b/README.md index c23ea6c..8ea3407 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Instruction =: Expression Expression =: number | number Dice DiceOperation | ScalarOperator Expression | string | variable Expression Dice =: DiceOperator Number(faces) | DiceOperator ListOfValues DiceOperator =: D | L -DiceOperation =: Keep | KeepAndExplose | Sort | Count | Reroll | If | Explose | RerollAndAdd | Jumpbackward | Merge | Filter | Split | Parenthese | Count | Paint | Group +DiceOperation =: Keep | KeepAndExplode | Sort | Count | Reroll | If | Explode | Jumpbackward | Merge | Filter | Split | Parenthese | Count | Paint | Group ScalarOperator =: [x,-,*,x,/] number =: [0-9]+ | constantValue constantValue =: ${id | label} @@ -29,7 +29,7 @@ BooleanValidator =: number | [operator number] | ListOfValue=: String[Range],ListOfValue | String[Range] String =: [A-z0-9]+ Keep =: k Number -KeepAndExplose =: K number +KeepAndExplode =: K number Reroll =: r Explosing =: e RerollOnceAndAdd =: a @@ -41,7 +41,7 @@ Sort =: s If =: i compareMethod [Validator] {Expression}[{Expression}] Paint =: p [ Count : color ] Group =: number -Explose =: e Validator +Explode =: e Validator Jumpbackward =: @DiceOperation Merge =: m | m Expression Filter =: f Validator @@ -57,7 +57,7 @@ Count =: c Validator Roll 3 dice with 100 faces ### 10D10e[=10]s -Roll 10 dice with 10 faces, 10 exploses, and sort the result. +Roll 10 dice with 10 faces, 10 explodes, and sort the result. ### 100291D66666666s roll 100291 dice with 66666666666 faces and sort result diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 748410c..4a085a3 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -80,7 +80,7 @@ SET( dice_sources ../node/countexecutenode.cpp ../node/dicerollernode.cpp ../node/executionnode.cpp - ../node/explosedicenode.cpp + ../node/explodedicenode.cpp ../node/helpnode.cpp ../node/mergenode.cpp ../node/jumpbackwardnode.cpp diff --git a/diceparser.cpp b/diceparser.cpp index 713864a..c37d572 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -33,7 +33,7 @@ #include "node/sortresult.h" #include "node/countexecutenode.h" #include "node/rerolldicenode.h" -#include "node/explosedicenode.h" +#include "node/explodedicenode.h" #include "node/parenthesesnode.h" #include "node/helpnode.h" #include "node/jumpbackwardnode.h" @@ -64,11 +64,11 @@ DiceParser::DiceParser() m_OptionOp = new QMap(); m_OptionOp->insert(QStringLiteral("k"),Keep); - m_OptionOp->insert(QStringLiteral("K"),KeepAndExplose); + m_OptionOp->insert(QStringLiteral("K"),KeepAndExplode); m_OptionOp->insert(QStringLiteral("s"),Sort); m_OptionOp->insert(QStringLiteral("c"),Count); m_OptionOp->insert(QStringLiteral("r"),Reroll); - m_OptionOp->insert(QStringLiteral("e"),Explosing); + m_OptionOp->insert(QStringLiteral("e"),Explode); m_OptionOp->insert(QStringLiteral("a"),RerollAndAdd); m_OptionOp->insert(QStringLiteral("m"),Merge); m_OptionOp->insert(QStringLiteral("i"),ifOperator); @@ -921,18 +921,18 @@ DiceRollerNode* DiceParser::addRollDiceNode(qint64 faces,ExecutionNode* previous previous->setNextNode(mydiceRoller); return mydiceRoller; } -ExploseDiceNode* DiceParser::addExploseDiceNode(qint64 value,ExecutionNode* previous) +ExplodeDiceNode* DiceParser::addExplodeDiceNode(qint64 value,ExecutionNode* previous) { - ExploseDiceNode* exploseDiceNode= new ExploseDiceNode(); + ExplodeDiceNode* explodeDiceNode= new ExplodeDiceNode(); NumberNode* node = new NumberNode(); node->setNumber(value); BooleanCondition* condition = new BooleanCondition(); condition->setValueNode(node); condition->setOperator(BooleanCondition::Equal); m_parsingToolbox->isValidValidator(previous,condition); - exploseDiceNode->setValidator(condition); - previous->setNextNode(exploseDiceNode); - return exploseDiceNode; + explodeDiceNode->setValidator(condition); + previous->setNextNode(explodeDiceNode); + return explodeDiceNode; } bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, { @@ -946,13 +946,13 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, for(int i = 0; ((ikeys().size())&&(!found));++i ) { - QString tmp =m_OptionOp->keys().at(i); + QString key =m_OptionOp->keys().at(i); - if(str.startsWith(tmp)) + if(str.startsWith(key)) { - str=str.remove(0,tmp.size()); - auto operatorName = m_OptionOp->value(tmp); + str=str.remove(0,key.size()); + auto operatorName = m_OptionOp->value(key); switch(operatorName) { case Keep: @@ -972,7 +972,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, } } break; - case KeepAndExplose: + case KeepAndExplode: { qint64 myNumber=0; bool ascending = m_parsingToolbox->readAscending(str); @@ -986,7 +986,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, if(nullptr!=nodeTmp) { - previous = addExploseDiceNode(nodeTmp->getFaces(),previous); + previous = addExplodeDiceNode(nodeTmp->getFaces(),previous); } node = m_parsingToolbox->addSort(previous,ascending); @@ -1064,7 +1064,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, { rerollNode->setInstruction(nodeParam); } - if(m_OptionOp->value(tmp)==RerollAndAdd) + if(m_OptionOp->value(key)==RerollAndAdd) { rerollNode->setAddingMode(true); } @@ -1076,12 +1076,17 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, } else { - m_errorMap.insert(ExecutionNode::BAD_SYNTAXE,QObject::tr("Validator is missing after the %1 operator. Please, change it").arg(m_OptionOp->value(tmp)==Reroll?QStringLiteral("r"):QStringLiteral("a"))); + m_errorMap.insert(ExecutionNode::BAD_SYNTAXE, + QObject::tr("Validator is missing after the %1 operator. Please, change it") + .arg(operatorName==Reroll? QStringLiteral("r") + :operatorName==RerollUntil? QStringLiteral("R") + :operatorName==RerollAndAdd? QStringLiteral("a") + :"")); } } break; - case Explosing: + case Explode: { Validator* validator = m_parsingToolbox->readCompositeValidator(str); if(nullptr!=validator) @@ -1090,10 +1095,10 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, { m_errorMap.insert(ExecutionNode::ENDLESS_LOOP_ERROR,QObject::tr("This condition %1 introduces an endless loop. Please, change it").arg(validator->toString())); } - ExploseDiceNode* explosedNode = new ExploseDiceNode(); - explosedNode->setValidator(validator); - previous->setNextNode(explosedNode); - node = explosedNode; + ExplodeDiceNode* explodedNode = new ExplodeDiceNode(); + explodedNode->setValidator(validator); + previous->setNextNode(explodedNode); + node = explodedNode; found = true; } diff --git a/diceparser.h b/diceparser.h index c3b5be2..eed2d06 100644 --- a/diceparser.h +++ b/diceparser.h @@ -38,7 +38,7 @@ typedef QList ListDiceResult; typedef QMap ExportedDiceResult; -class ExploseDiceNode; +class ExplodeDiceNode; /** * @page DiceParser Dice Parser * @@ -68,7 +68,7 @@ public: /** * @brief The OptionOperator enum gathering all options availables for result. */ - enum OptionOperator {KeepAndExplose,Keep,Reroll,Explosing,Sort,Count,RerollAndAdd,Merge,ifOperator,Painter,Filter,Split,Group}; + enum OptionOperator {KeepAndExplode,Keep,Reroll,RerollUntil,Explode,Sort,Count,RerollAndAdd,Merge,ifOperator,Painter,Filter,Split,Group}; /** * @brief The CommandOperator enum */ @@ -265,12 +265,12 @@ private: */ DiceRollerNode* addRollDiceNode(qint64 faces,ExecutionNode*); /** - * @brief addExploseDiceNode + * @brief addExplodeDiceNode * @param faces * @param previous * @return */ - ExploseDiceNode* addExploseDiceNode(qint64 faces,ExecutionNode* previous); + ExplodeDiceNode* addExplodeDiceNode(qint64 faces,ExecutionNode* previous); /** * @brief readOperand * @param node diff --git a/diceparser.pri b/diceparser.pri index b522965..22bcb30 100644 --- a/diceparser.pri +++ b/diceparser.pri @@ -29,7 +29,7 @@ SOURCES += $$PWD/diceparser.cpp \ $$PWD/node/sortresult.cpp \ $$PWD/node/keepdiceexecnode.cpp \ $$PWD/node/countexecutenode.cpp \ - $$PWD/node/explosedicenode.cpp \ + $$PWD/node/explodedicenode.cpp \ $$PWD/node/parenthesesnode.cpp \ $$PWD/node/helpnode.cpp \ $$PWD/node/jumpbackwardnode.cpp \ @@ -72,7 +72,7 @@ HEADERS += \ $$PWD/node/sortresult.h \ $$PWD/node/keepdiceexecnode.h \ $$PWD/node/countexecutenode.h \ - $$PWD/node/explosedicenode.h \ + $$PWD/node/explodedicenode.h \ $$PWD/node/parenthesesnode.h \ $$PWD/node/helpnode.h \ $$PWD/node/jumpbackwardnode.h \ diff --git a/irc/CMakeLists.txt b/irc/CMakeLists.txt index ce71373..6970005 100644 --- a/irc/CMakeLists.txt +++ b/irc/CMakeLists.txt @@ -53,7 +53,7 @@ add_executable( ../node/countexecutenode.cpp ../node/dicerollernode.cpp ../node/executionnode.cpp - ../node/explosedicenode.cpp + ../node/explodedicenode.cpp ../node/helpnode.cpp ../node/mergenode.cpp ../node/jumpbackwardnode.cpp diff --git a/mobile/CMakeLists.txt b/mobile/CMakeLists.txt index ed4259a..7dcfdef 100644 --- a/mobile/CMakeLists.txt +++ b/mobile/CMakeLists.txt @@ -73,7 +73,7 @@ SET( diceGui_sources ../node/countexecutenode.cpp ../node/dicerollernode.cpp ../node/executionnode.cpp - ../node/explosedicenode.cpp + ../node/explodedicenode.cpp ../node/helpnode.cpp ../node/mergenode.cpp ../node/jumpbackwardnode.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; +} 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 \ diff --git a/webserver/CMakeLists.txt b/webserver/CMakeLists.txt index 7bfa2d2..73aaf9b 100644 --- a/webserver/CMakeLists.txt +++ b/webserver/CMakeLists.txt @@ -47,7 +47,7 @@ SET( diceserver_sources ../node/countexecutenode.cpp ../node/dicerollernode.cpp ../node/executionnode.cpp - ../node/explosedicenode.cpp + ../node/explodedicenode.cpp ../node/helpnode.cpp ../node/mergenode.cpp ../node/jumpbackwardnode.cpp -- cgit v1.2.3-70-g09d2