From ae8b7dc596f7498dbf8153c735d096ae194acf51 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Wed, 12 May 2021 18:48:03 +0200 Subject: Make sure k operator can read value from variable. --- node/keepdiceexecnode.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'node/keepdiceexecnode.cpp') diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp index 3966c3f..8748a3b 100644 --- a/node/keepdiceexecnode.cpp +++ b/node/keepdiceexecnode.cpp @@ -23,7 +23,8 @@ #include "keepdiceexecnode.h" #include "parsingtoolbox.h" -KeepDiceExecNode::KeepDiceExecNode() : m_diceResult(new DiceResult()) +KeepDiceExecNode::KeepDiceExecNode() + : m_diceResult(new DiceResult()) { m_result= m_diceResult; } @@ -36,16 +37,16 @@ void KeepDiceExecNode::run(ExecutionNode* previous) return; } m_numberOfDiceNode->run(previous); - auto lastnode = ParsingToolBox::getLatestNode(m_numberOfDiceNode); + auto lastnode = ParsingToolBox::getLeafNode(m_numberOfDiceNode); if(nullptr == lastnode) return; auto result = lastnode->getResult(); if(nullptr == result) return; - if(!result->hasResultOfType(Result::SCALAR)) + if(!result->hasResultOfType(Dice::RESULT_TYPE::SCALAR)) return; - auto numberOfDice = result->getResult(Result::SCALAR).toInt(); + auto numberOfDice = result->getResult(Dice::RESULT_TYPE::SCALAR).toInt(); DiceResult* previousDiceResult = dynamic_cast(previous->getResult()); m_result->setPrevious(previousDiceResult); @@ -61,15 +62,15 @@ void KeepDiceExecNode::run(ExecutionNode* previous) QList diceList3= diceList.mid(0, static_cast(numberOfDice)); QList diceList2; - for(Die* die : diceList3) + for(Die* die : qAsConst(diceList3)) { Die* tmpdie= new Die(*die); - //*tmpdie= *die; diceList2.append(tmpdie); die->displayed(); + die->setSelected(false); } - if(numberOfDice > static_cast(diceList.size())) + if(numberOfDice > static_cast(diceList.size())) { m_errors.insert(Dice::ERROR_CODE::TOO_MANY_DICE, QObject::tr(" You ask to keep %1 dice but the result only has %2") @@ -99,7 +100,7 @@ QString KeepDiceExecNode::toString(bool wl) const if(wl) { auto param = m_numberOfDiceNode->toString(wl); - return QString("%1 [label=\"KeepDiceExecNode %2\"]").arg(m_id).arg(param); + return QString("%1 [label=\"KeepDiceExecNode %2\"]").arg(m_id, param); } else { -- cgit v1.2.3-70-g09d2