From 2b16ecf755a088c83dad3313dbddce5c0190baa0 Mon Sep 17 00:00:00 2001 From: rguezennec Date: Fri, 28 Apr 2017 11:36:53 +0200 Subject: [PATCH 1/4] -add operator on dice with range --- diceparser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/diceparser.cpp b/diceparser.cpp index 31bcf59e..796850f6 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -644,6 +644,11 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node) // qint64 face = abs(num - end); //qDebug() << face << end; DiceRollerNode* drNode = new DiceRollerNode(max,min); + + if(hasOp) + { + drNode->setOperator(op); + } node = drNode; ExecutionNode* current = drNode; while(readOption(str,current)) From 544102b02edb5de07547f5f15d2e3827b73a5005 Mon Sep 17 00:00:00 2001 From: rguezennec Date: Fri, 28 Apr 2017 11:37:38 +0200 Subject: [PATCH 2/4] -passing operator to diceResult --- node/dicerollernode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index 9ca0d357..fd92b937 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -92,4 +92,5 @@ Die::ArithmeticOperator DiceRollerNode::getOperator() const void DiceRollerNode::setOperator(const Die::ArithmeticOperator &dieOperator) { m_operator = dieOperator; + m_diceResult->setOperator(dieOperator); } From 30872dd11a375878d5eb7390ec6a3b255eba89f6 Mon Sep 17 00:00:00 2001 From: rguezennec Date: Fri, 28 Apr 2017 11:37:55 +0200 Subject: [PATCH 3/4] -NULL to nullptr --- node/ifnode.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/node/ifnode.cpp b/node/ifnode.cpp index 91ad1997..da852b3e 100644 --- a/node/ifnode.cpp +++ b/node/ifnode.cpp @@ -34,48 +34,57 @@ IfNode::~IfNode() void IfNode::run(ExecutionNode *previous) { m_previousNode = previous; - if(NULL==previous) + if(nullptr==previous) { return; } ExecutionNode* previousLoop = previous; - ExecutionNode* nextNode = NULL; - bool runNext = (NULL==m_nextNode) ? false : true; + ExecutionNode* nextNode = nullptr; + bool runNext = (nullptr==m_nextNode) ? false : true; Result* previousResult = previous->getResult(); m_result = previousResult; - if(NULL!=m_result) + if(nullptr!=m_result) { qreal value = previousResult->getResult(Result::SCALAR).toReal(); - if(NULL!=m_validator) + if(nullptr!=m_validator) { DiceResult* previousDiceResult = dynamic_cast(previousResult); - if(NULL!=previousDiceResult) + if(nullptr!=previousDiceResult) { QList diceList=previousDiceResult->getResultList(); + if(m_conditionType == OnEach) { for(Die* dice : diceList) { + qDebug()<< "dice value:" << dice->getValue(); if(m_validator->hasValid(dice,true,true)) { - nextNode = (NULL==m_true) ? NULL: m_true->getCopy(); + qDebug()<< "true"; + nextNode = (nullptr==m_true) ? nullptr: m_true->getCopy(); } else { - nextNode = (NULL==m_false) ? NULL: m_false->getCopy(); + qDebug()<< "false"; + nextNode = (nullptr==m_false) ? nullptr: m_false->getCopy(); } - if(NULL!=nextNode) + qDebug()<< "dice value:" << dice->getValue() << "next node" << nextNode << "m_true" << m_true; + + if(nullptr!=nextNode) { - if(NULL==previousLoop->getNextNode()) + if(nullptr==previousLoop->getNextNode()) { + qDebug() << "iniside loop"; previousLoop->setNextNode(nextNode); } - if(NULL==m_nextNode) + if(nullptr==m_nextNode) { + qDebug() << "next node" ; m_nextNode = nextNode; } + qDebug() << "before run"; nextNode->run(previousLoop); previousLoop = getLeafNode(nextNode); } From 29c80721f858f84bb737a10e7cd012e4a9795399 Mon Sep 17 00:00:00 2001 From: rguezennec Date: Fri, 28 Apr 2017 11:38:13 +0200 Subject: [PATCH 4/4] -fix dice value copy --- node/splitnode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/node/splitnode.cpp b/node/splitnode.cpp index 7c019101..a0742481 100644 --- a/node/splitnode.cpp +++ b/node/splitnode.cpp @@ -46,6 +46,7 @@ void SplitNode::run(ExecutionNode* previous) for(qint64 value : oldDie->getListValue()) { Die* tmpdie = new Die(); + tmpdie->insertRollValue(value); tmpdie->setFaces(oldDie->getFaces()); tmpdie->setValue(value); tmpdie->setOp(oldDie->getOp());