diff options
| -rw-r--r-- | diceparser.cpp | 11 | ||||
| -rw-r--r-- | diceparser.h | 2 | ||||
| -rw-r--r-- | die.cpp | 9 | ||||
| -rw-r--r-- | die.h | 6 | ||||
| -rw-r--r-- | node/dicerollernode.cpp | 2 | ||||
| -rw-r--r-- | node/keepdiceexecnode.cpp | 4 | ||||
| -rw-r--r-- | node/listsetrollnode.cpp | 2 | ||||
| -rw-r--r-- | node/splitnode.cpp | 3 | ||||
| -rw-r--r-- | node/variablenode.cpp | 7 | ||||
| -rw-r--r-- | node/variablenode.h | 2 | ||||
| -rw-r--r-- | parsingtoolbox.cpp | 2 | ||||
| -rw-r--r-- | result/scalarresult.cpp | 7 | ||||
| -rw-r--r-- | result/stringresult.cpp | 4 |
13 files changed, 29 insertions, 32 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index 24bf3c4..311b3a4 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -147,7 +147,7 @@ void DiceParser::insertAlias(DiceAlias* dice, int i) } } -bool DiceParser::parseLine(QString str) +bool DiceParser::parseLine(QString str, bool allowAlias) { m_errorMap.clear(); if(!m_startNodes.empty()) @@ -156,7 +156,10 @@ bool DiceParser::parseLine(QString str) m_startNodes.clear(); } m_currentTreeHasSeparator=false; - str = convertAlias(str); + if(allowAlias) + { + str = convertAlias(str); + } m_command = str; bool hasInstruction = readInstructionList(str); @@ -166,8 +169,8 @@ bool DiceParser::parseLine(QString str) } else { - m_errorMap.insert(ExecutionNode::NOTHING_UNDERSTOOD,QObject::tr("Nothing was understood. To roll dice: !1d6 - full documation:" - "https://github.com/Rolisteam/DiceParser/blob/master/HelpMe.md")); + m_errorMap.insert(ExecutionNode::NOTHING_UNDERSTOOD,QObject::tr("Nothing was understood. To roll dice: !1d6 - full documation: " + "<a href=\"https://github.com/Rolisteam/DiceParser/blob/master/HelpMe.md\">https://github.com/Rolisteam/DiceParser/blob/master/HelpMe.md</a>")); } return false; } diff --git a/diceparser.h b/diceparser.h index 91a653a..abe19a1 100644 --- a/diceparser.h +++ b/diceparser.h @@ -101,7 +101,7 @@ public: * @param str dice command * @return bool every thing is fine or not */ - bool parseLine(QString str); + bool parseLine(QString str, bool allowAlias = true); /** * @brief getStartNodeCount * @return @@ -155,11 +155,6 @@ quint64 Die::getFaces() const { return abs(m_maxValue-m_base)+1; } - -void Die::setFaces(quint64 face) -{ - //m_maxValue=m_base+face-1; -} qint64 Die::getLastRolledValue() { if(!m_rollResult.isEmpty()) @@ -190,6 +185,10 @@ void Die::setBase(qint64 base) { m_base = base; } +qint64 Die::getBase() +{ + return m_base; +} QString Die::getColor() const { return m_color; @@ -49,11 +49,6 @@ public: */ void setValue(qint64 r); /** - * @brief setFaces - * @param face - */ - void setFaces(quint64 face); - /** * @brief insertRollValue * @param r */ @@ -128,6 +123,7 @@ public: * @brief setBase */ void setBase(qint64); + qint64 getBase(); QString getColor() const; void setColor(const QString &color); diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index 1f501e5..70fd245 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -29,7 +29,7 @@ void DiceRollerNode::run(ExecutionNode* previous) { m_errors.insert(NO_DICE_TO_ROLL,QObject::tr("No dice to roll")); } - auto possibleValue = (m_max-m_min)+1; + auto possibleValue = static_cast<quint64>(abs((m_max-m_min)+1)); //qDebug() << possibleValue; if( possibleValue < m_diceCount && m_unique) { diff --git a/node/keepdiceexecnode.cpp b/node/keepdiceexecnode.cpp index a93cc11..547e343 100644 --- a/node/keepdiceexecnode.cpp +++ b/node/keepdiceexecnode.cpp @@ -49,7 +49,7 @@ void KeepDiceExecNode::run(ExecutionNode* previous) QList<Die*> diceList3= diceList.mid(0,m_numberOfDice); QList<Die*> diceList2; - foreach(Die* die,diceList3) + for(Die* die : diceList3) { Die* tmpdie = new Die(); *tmpdie=*die; @@ -59,7 +59,7 @@ void KeepDiceExecNode::run(ExecutionNode* previous) - if(m_numberOfDice > diceList.size()) + if(m_numberOfDice > static_cast<quint64>(diceList.size())) { m_errors.insert(TOO_MANY_DICE,QObject::tr(" You ask to keep %1 dice but the result only has %2").arg(m_numberOfDice).arg(diceList.size())); } diff --git a/node/listsetrollnode.cpp b/node/listsetrollnode.cpp index d7d4566..e6ffd00 100644 --- a/node/listsetrollnode.cpp +++ b/node/listsetrollnode.cpp @@ -65,7 +65,7 @@ void ListSetRollNode::run(ExecutionNode* previous) if(nullptr!=result) { quint64 diceCount = result->getResult(Result::SCALAR).toReal(); - if(diceCount > m_values.size() && m_unique) + if(diceCount > static_cast<quint64>(m_values.size()) && m_unique) { m_errors.insert(TOO_MANY_DICE,QObject::tr("More unique values asked than possible values (L operator)")); } diff --git a/node/splitnode.cpp b/node/splitnode.cpp index ed32fdd..d44bad5 100644 --- a/node/splitnode.cpp +++ b/node/splitnode.cpp @@ -47,7 +47,8 @@ void SplitNode::run(ExecutionNode* previous) { Die* tmpdie = new Die(); tmpdie->insertRollValue(value); - tmpdie->setFaces(oldDie->getFaces()); + tmpdie->setBase(oldDie->getBase()); + tmpdie->setMaxValue(oldDie->getMaxValue()); tmpdie->setValue(value); tmpdie->setOp(oldDie->getOp()); m_diceResult->insertResult(tmpdie); diff --git a/node/variablenode.cpp b/node/variablenode.cpp index f202246..9963af9 100644 --- a/node/variablenode.cpp +++ b/node/variablenode.cpp @@ -8,13 +8,6 @@ VariableNode::VariableNode() void VariableNode::run(ExecutionNode *previous) { m_previousNode = previous; - - if(m_index<0) - { - m_errors.insert(INVALID_INDEX,QObject::tr("Invalid index must be greater than 0 :%1").arg(m_index)); - return; - } - if(m_data->size()>m_index) { auto value= (*m_data)[m_index]; diff --git a/node/variablenode.h b/node/variablenode.h index 6e9cc78..1df9acd 100644 --- a/node/variablenode.h +++ b/node/variablenode.h @@ -26,7 +26,7 @@ public: void setData(std::vector<ExecutionNode *>* data); private: - qint64 m_index; + quint64 m_index; std::vector<ExecutionNode*>* m_data; }; diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 63c3001..37c998e 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -61,7 +61,7 @@ ParsingToolBox::ParsingToolBox() } -ParsingToolBox::ParsingToolBox(const ParsingToolBox& data) +ParsingToolBox::ParsingToolBox(const ParsingToolBox& ) { } diff --git a/result/scalarresult.cpp b/result/scalarresult.cpp index 67624ba..1722cd2 100644 --- a/result/scalarresult.cpp +++ b/result/scalarresult.cpp @@ -33,7 +33,12 @@ void ScalarResult::setValue(qreal i) } QVariant ScalarResult::getResult(Result::RESULT_TYPE type) { - return m_value; + if(SCALAR == type) + { + return m_value; + } + else + return {}; } QString ScalarResult::toString(bool wl) diff --git a/result/stringresult.cpp b/result/stringresult.cpp index 55df6a8..2d9214d 100644 --- a/result/stringresult.cpp +++ b/result/stringresult.cpp @@ -43,9 +43,9 @@ QVariant StringResult::getResult(RESULT_TYPE type) case SCALAR: return getText().toInt(); break; - + default: + return QVariant(); } - return QVariant(); } QString StringResult::toString(bool wl) { |