aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/countexecutenode.cpp18
-rw-r--r--node/dicerollernode.cpp2
-rw-r--r--node/executionnode.cpp2
-rw-r--r--node/explosedicenode.cpp16
-rw-r--r--node/filternode.cpp14
-rw-r--r--node/ifnode.cpp9
-rw-r--r--node/jumpbackwardnode.cpp2
-rw-r--r--node/keepdiceexecnode.cpp10
-rw-r--r--node/listaliasnode.cpp4
-rw-r--r--node/listsetrollnode.cpp4
-rw-r--r--node/paintnode.cpp2
-rw-r--r--node/rerolldicenode.cpp4
-rw-r--r--node/scalaroperatornode.cpp49
-rw-r--r--node/scalaroperatornode.h5
-rw-r--r--node/separatornode.cpp0
-rw-r--r--node/separatornode.h44
-rw-r--r--node/sortresult.cpp8
-rw-r--r--node/startingnode.cpp5
18 files changed, 77 insertions, 121 deletions
diff --git a/node/countexecutenode.cpp b/node/countexecutenode.cpp
index ca2c599..84946df 100644
--- a/node/countexecutenode.cpp
+++ b/node/countexecutenode.cpp
@@ -4,7 +4,7 @@
CountExecuteNode::CountExecuteNode()
- : m_scalarResult(new ScalarResult()),m_validator(nullptr)
+ : m_scalarResult(new ScalarResult()),m_validator(nullptr)
{
m_result = m_scalarResult;
}
@@ -14,7 +14,7 @@ void CountExecuteNode::setValidator(Validator* validator)
}
CountExecuteNode::~CountExecuteNode()
{
- if(nullptr!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
}
@@ -23,19 +23,19 @@ CountExecuteNode::~CountExecuteNode()
void CountExecuteNode::run(ExecutionNode *previous)
{
m_previousNode = previous;
- if(nullptr==previous)
+ if(nullptr==previous)
{
return;
}
DiceResult* previousResult = dynamic_cast<DiceResult*>(previous->getResult());
- if(NULL!=previousResult)
+ if(nullptr!=previousResult)
{
m_result->setPrevious(previousResult);
QList<Die*> diceList=previousResult->getResultList();
qint64 sum = 0;
foreach(Die* dice,diceList)
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
sum+=m_validator->hasValid(dice,true,true);
}
@@ -43,7 +43,7 @@ void CountExecuteNode::run(ExecutionNode *previous)
m_scalarResult->setValue(sum);
- if(nullptr!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -63,7 +63,7 @@ QString CountExecuteNode::toString(bool withlabel) const
qint64 CountExecuteNode::getPriority() const
{
qint64 priority=0;
- if(nullptr!=m_previousNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -75,11 +75,11 @@ qint64 CountExecuteNode::getPriority() const
ExecutionNode* CountExecuteNode::getCopy() const
{
CountExecuteNode* node = new CountExecuteNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp
index f2b002d..ed6d102 100644
--- a/node/dicerollernode.cpp
+++ b/node/dicerollernode.cpp
@@ -70,6 +70,8 @@ qint64 DiceRollerNode::getPriority() const
// {
// priority = m_nextNode->getPriority();
// }
+
+
return priority;
}
ExecutionNode* DiceRollerNode::getCopy() const
diff --git a/node/executionnode.cpp b/node/executionnode.cpp
index 94d0d46..84aa17c 100644
--- a/node/executionnode.cpp
+++ b/node/executionnode.cpp
@@ -41,7 +41,7 @@ QMap<ExecutionNode::DICE_ERROR_CODE,QString> ExecutionNode::getExecutionErrorMap
{
if(nullptr!=m_nextNode)
{
- for (const auto& key : m_nextNode->getExecutionErrorMap().keys())
+ foreach (ExecutionNode::DICE_ERROR_CODE key, m_nextNode->getExecutionErrorMap().keys())
{
m_errors.insert(key,m_nextNode->getExecutionErrorMap().value(key));
}
diff --git a/node/explosedicenode.cpp b/node/explosedicenode.cpp
index 81e80ee..96caaeb 100644
--- a/node/explosedicenode.cpp
+++ b/node/explosedicenode.cpp
@@ -1,18 +1,18 @@
#include "explosedicenode.h"
ExploseDiceNode::ExploseDiceNode()
- : m_diceResult(new DiceResult()),m_validator(nullptr)
+ : m_diceResult(new DiceResult()),m_validator(nullptr)
{
m_result = m_diceResult;
}
void ExploseDiceNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if((NULL!=previous)&&(NULL!=previous->getResult()))
+ if((nullptr!=previous)&&(nullptr!=previous->getResult()))
{
DiceResult* previous_result = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previous_result);
- if(NULL!=previous_result)
+ if(nullptr!=previous_result)
{
foreach(Die* die,previous_result->getResultList())
{
@@ -34,7 +34,7 @@ void ExploseDiceNode::run(ExecutionNode* previous)
}
// m_diceResult->setResultList(list);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -43,7 +43,7 @@ void ExploseDiceNode::run(ExecutionNode* previous)
}
ExploseDiceNode::~ExploseDiceNode()
{
- if(nullptr!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
}
@@ -66,7 +66,7 @@ QString ExploseDiceNode::toString(bool withlabel) const
qint64 ExploseDiceNode::getPriority() const
{
qint64 priority=0;
- if(nullptr!=m_previousNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -78,11 +78,11 @@ qint64 ExploseDiceNode::getPriority() const
ExecutionNode* ExploseDiceNode::getCopy() const
{
ExploseDiceNode* node = new ExploseDiceNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/filternode.cpp b/node/filternode.cpp
index 5153c79..462774b 100644
--- a/node/filternode.cpp
+++ b/node/filternode.cpp
@@ -8,7 +8,7 @@ FilterNode::FilterNode()
FilterNode::~FilterNode()
{
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
delete m_validator;
}
@@ -20,13 +20,13 @@ void FilterNode::setValidator(Validator* validator)
void FilterNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL==previous)
+ if(nullptr==previous)
{
return;
}
DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previousDiceResult);
- if(NULL!=previousDiceResult)
+ if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();
QList<Die*> diceList2;
@@ -48,7 +48,7 @@ void FilterNode::run(ExecutionNode* previous)
}
m_diceResult->setResultList(diceList2);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -69,7 +69,7 @@ QString FilterNode::toString(bool wl) const
qint64 FilterNode::getPriority() const
{
qint64 priority=0;
- if(nullptr!=m_previousNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -80,11 +80,11 @@ qint64 FilterNode::getPriority() const
ExecutionNode* FilterNode::getCopy() const
{
FilterNode* node = new FilterNode();
- if(NULL!=m_validator)
+ if(nullptr!=m_validator)
{
node->setValidator(m_validator->getCopy());
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/ifnode.cpp b/node/ifnode.cpp
index b15e203..b40ed82 100644
--- a/node/ifnode.cpp
+++ b/node/ifnode.cpp
@@ -60,7 +60,7 @@ void IfNode::run(ExecutionNode *previous)
for(Die* dice : diceList)
{
if(m_validator->hasValid(dice,true,true))
- {
+ {
nextNode = (nullptr==m_true) ? nullptr: m_true->getCopy();
}
else
@@ -245,12 +245,7 @@ QString IfNode::toString(bool wl) const
qint64 IfNode::getPriority() const
{
- qint64 priority=0;
- if(nullptr != getPreviousNode())
- {
- priority=getPreviousNode()->getPriority();
- }
- return priority;
+ return 4;
}
ExecutionNode* IfNode::getLeafNode(ExecutionNode* node)
diff --git a/node/jumpbackwardnode.cpp b/node/jumpbackwardnode.cpp
index e860f99..1309b3b 100644
--- a/node/jumpbackwardnode.cpp
+++ b/node/jumpbackwardnode.cpp
@@ -130,7 +130,7 @@ void JumpBackwardNode::run(ExecutionNode* previous)
DiceResult* diceResult = dynamic_cast<DiceResult*>(result);
if(nullptr!=diceResult)
{
- for(Die* die : diceResult->getResultList())
+ foreach(Die* die,diceResult->getResultList())
{
Die* tmpdie = new Die();
*tmpdie=*die;
diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp
index 6167632..a93cc11 100644
--- a/node/keepdiceexecnode.cpp
+++ b/node/keepdiceexecnode.cpp
@@ -36,13 +36,13 @@ KeepDiceExecNode::~KeepDiceExecNode()
void KeepDiceExecNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL==previous)
+ if(nullptr==previous)
{
return;
}
DiceResult* previousDiceResult = static_cast<DiceResult*>(previous->getResult());
m_result->setPrevious(previousDiceResult);
- if(NULL!=previousDiceResult)
+ if(nullptr!=previousDiceResult)
{
QList<Die*> diceList=previousDiceResult->getResultList();
@@ -70,7 +70,7 @@ void KeepDiceExecNode::run(ExecutionNode* previous)
}
m_diceResult->setResultList(diceList2);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -94,7 +94,7 @@ QString KeepDiceExecNode::toString(bool wl) const
qint64 KeepDiceExecNode::getPriority() const
{
qint64 priority=0;
- if(nullptr!=m_previousNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -107,7 +107,7 @@ ExecutionNode* KeepDiceExecNode::getCopy() const
{
KeepDiceExecNode* node = new KeepDiceExecNode();
node->setDiceKeepNumber(m_numberOfDice);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/listaliasnode.cpp b/node/listaliasnode.cpp
index 4c9f9f2..642f601 100644
--- a/node/listaliasnode.cpp
+++ b/node/listaliasnode.cpp
@@ -53,7 +53,7 @@ void ListAliasNode::run(ExecutionNode* previous )
QString ListAliasNode::buildList() const
{
QString result(QObject::tr("List of Alias:\n"));
- for(DiceAlias* key : *m_aliasList)
+ foreach(DiceAlias* key, *m_aliasList)
{
result+=QString("%1 : %2\n").arg(key->getCommand()).arg(key->getValue());
}
@@ -62,7 +62,7 @@ QString ListAliasNode::buildList() const
QString ListAliasNode::toString(bool wl) const
{
QStringList resultList;
- for(DiceAlias* key : *m_aliasList)
+ foreach(DiceAlias* key, *m_aliasList)
{
resultList << "{" <<key->getCommand() << key->getValue()<< "}";
}
diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp
index 8f86332..21d5403 100644
--- a/node/listsetrollnode.cpp
+++ b/node/listsetrollnode.cpp
@@ -106,7 +106,7 @@ void ListSetRollNode::computeFacesNumber(Die* die)
Q_ASSERT(m_values.size() == m_rangeList.size());
qint64 max;
int i=0;
- for(Range range: m_rangeList)
+ foreach(Range range, m_rangeList)
{
if(((i==0)||(max<range.getEnd()))&&(range.isFullyDefined()))
{
@@ -133,7 +133,7 @@ void ListSetRollNode::getValueFromDie(Die* die,QStringList& rollResult)
{
Q_ASSERT(m_values.size() == m_rangeList.size());
int i=0;
- for (Range range: m_rangeList)
+ foreach (Range range, m_rangeList)
{
if(range.hasValid(die,false))
{
diff --git a/node/paintnode.cpp b/node/paintnode.cpp
index 035334e..2770891 100644
--- a/node/paintnode.cpp
+++ b/node/paintnode.cpp
@@ -78,7 +78,7 @@ void PainterNode::run(ExecutionNode* previous)
{
QList<Die*> diceList=previousDiceResult->getResultList();
int pastDice=0;
- for(ColorItem item: m_colors)
+ foreach(ColorItem item, m_colors)
{
int current=item.colorNumber();
QList<Die*>::iterator it;
diff --git a/node/rerolldicenode.cpp b/node/rerolldicenode.cpp
index 8e8be2c..1f8cd7e 100644
--- a/node/rerolldicenode.cpp
+++ b/node/rerolldicenode.cpp
@@ -23,7 +23,7 @@ void RerollDiceNode::run(ExecutionNode* previous)
m_result->setPrevious(previous_result);
if(nullptr!=previous_result)
{
- for(Die* die : previous_result->getResultList())
+ foreach(Die* die,previous_result->getResultList())
{
Die* tmpdie = new Die();
*tmpdie=*die;
@@ -34,7 +34,7 @@ void RerollDiceNode::run(ExecutionNode* previous)
QList<Die*> list = m_diceResult->getResultList();
- for(Die* die: list)
+ foreach(Die* die, list)
{
if(m_validator->hasValid(die,false))
{
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index f4884c8..a9a19e3 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -38,37 +38,44 @@ ScalarOperatorNode::ScalarOperatorNode()
}
ScalarOperatorNode::~ScalarOperatorNode()
{
- if(nullptr!=m_internalNode)
- {
- delete m_internalNode;
- m_internalNode = nullptr;
- }
+ if(nullptr!=m_internalNode)
+ {
+ delete m_internalNode;
+ m_internalNode = nullptr;
+ }
}
void ScalarOperatorNode::run(ExecutionNode* previous)
{
m_previousNode = previous;
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
m_internalNode->run(this);
}
- if(NULL!=previous)
+ if(nullptr!=previous)
{
DiceResult* previousResult = static_cast<DiceResult*>(previous->getResult());
- if(NULL!=previousResult)
+ if(nullptr!=previousResult)
{
ExecutionNode* internal = m_internalNode;
- if(NULL != internal)
+ if(nullptr != internal)
{
- while(nullptr != internal->getNextNode() )
- {
+ while(nullptr != internal->getNextNode() )
+ {
internal = internal->getNextNode();
}
- switch(m_arithmeticOperator)
- {
+ Result* internalResult = internal->getResult();
+ m_result->setPrevious(internalResult);
+ if(nullptr!=m_internalNode->getResult())
+ {
+ m_internalNode->getResult()->setPrevious(previousResult);
+ }
+
+ switch(m_arithmeticOperator)
+ {
case Die::PLUS:
m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),internalResult->getResult(Result::SCALAR).toReal()));
break;
@@ -87,7 +94,7 @@ void ScalarOperatorNode::run(ExecutionNode* previous)
}
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -186,7 +193,7 @@ void ScalarOperatorNode::generateDotTree(QString& s)
s.append(toString(true));
s.append(";\n");
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
s.append(toString(false));
s.append(" -> ");
@@ -198,12 +205,12 @@ void ScalarOperatorNode::generateDotTree(QString& s)
{
s.append(toString(false));
s.append(" -> ");
- s.append("nullptr");
- s.append(" [label=\"nextNode\"];\n");
+ s.append("nullptr");
+ s.append(" [label=\"nextNode\"];\n");
}
QString str;
str.append("\n");
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
str.append(toString(false));
str.append(" -> ");
@@ -215,14 +222,14 @@ void ScalarOperatorNode::generateDotTree(QString& s)
}
QMap<ExecutionNode::DICE_ERROR_CODE,QString> ScalarOperatorNode::getExecutionErrorMap()
{
- if(NULL!=m_internalNode)
+ if(nullptr!=m_internalNode)
{
for (ExecutionNode::DICE_ERROR_CODE key: m_internalNode->getExecutionErrorMap().keys())
{
m_errors.insert(key,m_internalNode->getExecutionErrorMap().value(key));
}
}
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
for (ExecutionNode::DICE_ERROR_CODE key: m_nextNode->getExecutionErrorMap().keys())
{
@@ -236,7 +243,7 @@ ExecutionNode* ScalarOperatorNode::getCopy() const
ScalarOperatorNode* node = new ScalarOperatorNode();
node->setInternalNode(m_internalNode->getCopy());
node->setArithmeticOperator(m_arithmeticOperator);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h
index 7753a6f..0855a4c 100644
--- a/node/scalaroperatornode.h
+++ b/node/scalaroperatornode.h
@@ -115,11 +115,6 @@ private:
* @return
*/
static qint64 multiple(qint64,qint64);
- /**
- * @brief power
- * @return
- */
- static qint64 power(qint64,qint64);
private:
ExecutionNode* m_internalNode;
diff --git a/node/separatornode.cpp b/node/separatornode.cpp
deleted file mode 100644
index e69de29..0000000
--- a/node/separatornode.cpp
+++ /dev/null
diff --git a/node/separatornode.h b/node/separatornode.h
deleted file mode 100644
index 0820429..0000000
--- a/node/separatornode.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/***************************************************************************
-* Copyright (C) 2017 by Renaud Guezennec *
-* http://www.rolisteam.org/contact *
-* *
-* This file is part of DiceParser *
-* *
-* DiceParser is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, *
-* but WITHOUT ANY WARRANTY; without even the implied warranty of *
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
-* GNU General Public License for more details. *
-* *
-* You should have received a copy of the GNU General Public License *
-* along with this program; if not, write to the *
-* Free Software Foundation, Inc., *
-* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
-***************************************************************************/
-#ifndef SEPARATORNODE_H
-#define SEPARATORNODE_H
-
-#include "node/executionnode.h"
-#include "result/diceresult.h"
-
-/**
- * @brief The MergeNode class is an ExecutionNode. It is dedicated to merge result of several commands.
- */
-class SeparatorNode : public ExecutionNode
-{
-public:
- SeparatorNode();
- void run(ExecutionNode* previous);
- virtual QString toString(bool withLabel)const;
- virtual qint64 getPriority() const;
- virtual ExecutionNode *getCopy() const;
-private:
- DiceResult* m_diceResult;
- ExecutionNode* m_;
-};
-
-#endif // SEPARATORNODE_H
diff --git a/node/sortresult.cpp b/node/sortresult.cpp
index 062e1d2..5406eb6 100644
--- a/node/sortresult.cpp
+++ b/node/sortresult.cpp
@@ -57,7 +57,7 @@ void SortResultNode::run(ExecutionNode* node)
bool found = false;
int start = 0;
int end = diceList2.size();
- Die* tmp2 = NULL;
+ Die* tmp2 = nullptr;
while(!found)
{
int distance = end-start;
@@ -92,7 +92,7 @@ void SortResultNode::run(ExecutionNode* node)
}
m_diceResult->setResultList(diceList2);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
}
@@ -123,7 +123,7 @@ QString SortResultNode::toString(bool wl) const
qint64 SortResultNode::getPriority() const
{
qint64 priority=0;
- if(nullptr != m_previousNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -135,7 +135,7 @@ ExecutionNode* SortResultNode::getCopy() const
{
SortResultNode* node = new SortResultNode();
node->setSortAscending(m_ascending);
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}
diff --git a/node/startingnode.cpp b/node/startingnode.cpp
index 43a0dd7..670dc7d 100644
--- a/node/startingnode.cpp
+++ b/node/startingnode.cpp
@@ -26,6 +26,7 @@ StartingNode::StartingNode()
}
void StartingNode::run(ExecutionNode*)
{
+ m_previousNode = nullptr;
if(nullptr!=m_nextNode)
{
m_nextNode->run(this);
@@ -47,7 +48,7 @@ QString StartingNode::toString(bool withlabel) const
qint64 StartingNode::getPriority() const
{
qint64 priority=0;
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
priority = m_nextNode->getPriority();
}
@@ -56,7 +57,7 @@ qint64 StartingNode::getPriority() const
ExecutionNode* StartingNode::getCopy() const
{
StartingNode* node = new StartingNode();
- if(NULL!=m_nextNode)
+ if(nullptr!=m_nextNode)
{
node->setNextNode(m_nextNode->getCopy());
}