diff options
| author | 2019-07-12 00:28:09 +0200 | |
|---|---|---|
| committer | 2019-07-12 00:28:09 +0200 | |
| commit | d810aab9b7df705d325ee00f1909dfd835b9b97c (patch) | |
| tree | da832909c5fa45cf34e31f21d3817fb46f5d3026 /node | |
| parent | 8e8384b27f83d0375d381a86622b0afd4c42eacb (diff) | |
| download | OneRoll-d810aab9b7df705d325ee00f1909dfd835b9b97c.tar.gz OneRoll-d810aab9b7df705d325ee00f1909dfd835b9b97c.zip | |
Fix errors
Diffstat (limited to 'node')
| -rw-r--r-- | node/dicerollernode.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/node/dicerollernode.cpp b/node/dicerollernode.cpp index 44b9e0a..f57d3e3 100644 --- a/node/dicerollernode.cpp +++ b/node/dicerollernode.cpp @@ -19,18 +19,19 @@ void DiceRollerNode::run(ExecutionNode* previous) Result* result= previous->getResult(); if(nullptr != result) { - m_diceCount= static_cast<quint64>(result->getResult(Result::SCALAR).toReal()); - m_result->setPrevious(result); - - if(m_diceCount == 0) + auto num= result->getResult(Result::SCALAR).toReal(); + if(num <= 0) { m_errors.insert(NO_DICE_TO_ROLL, QObject::tr("No dice to roll")); } + m_diceCount= num > 0 ? static_cast<quint64>(num) : 0; + m_result->setPrevious(result); + auto possibleValue= static_cast<quint64>(std::abs((m_max - m_min) + 1)); if(possibleValue < m_diceCount && m_unique) { - m_errors.insert( - TOO_MANY_DICE, QObject::tr("More unique values asked than possible values (D operator)")); + m_errors.insert(TOO_MANY_DICE, + QObject::tr("More unique values asked than possible values (D operator)")); return; } |