diff options
| author | 2019-07-12 00:28:09 +0200 | |
|---|---|---|
| committer | 2019-07-12 22:06:40 +0200 | |
| commit | 3900611f9bc0b8e47f198587defd632403beaf90 (patch) | |
| tree | be0accd18b0f540f075db45629d49aa169f9f1b7 /node | |
| parent | 80bc5ef3c8276a33d0c3b1cb962939e7c252ae7c (diff) | |
| download | OneRoll-3900611f9bc0b8e47f198587defd632403beaf90.tar.gz OneRoll-3900611f9bc0b8e47f198587defd632403beaf90.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; } |