diff options
| author | 2019-07-12 21:00:42 +0000 | |
|---|---|---|
| committer | 2019-07-12 21:00:42 +0000 | |
| commit | 5c2fbf1edc7547333739d3d643c4abee5ce6f942 (patch) | |
| tree | 6e9f4a709fd497fed1cf7f24bb2c3db421eb8711 /node/dicerollernode.cpp | |
| parent | 4f495aaaecb3118b835504e9bc1347f934aa49d1 (diff) | |
| parent | a3c3551815845cbc4bdf891b5f01406414abd4d2 (diff) | |
| download | OneRoll-5c2fbf1edc7547333739d3d643c4abee5ce6f942.tar.gz OneRoll-5c2fbf1edc7547333739d3d643c4abee5ce6f942.zip | |
Merge branch 'new_operator_and_fix' into 'master'
Value list node and occurence improvements
See merge request kde/rolisteam-diceparser!1
Diffstat (limited to 'node/dicerollernode.cpp')
| -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; } |