aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node/scalaroperatornode.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2019-07-25 09:59:29 +0200
committerRenaud G <renaud@rolisteam.org>2019-07-25 09:59:29 +0200
commitbb6b87a2685c0d71b5c38be33c100f85ac0b9cee (patch)
tree81da599ceec1368e55fee5fd6a4dd0173fc39b5f /node/scalaroperatornode.cpp
parent6f499de159eeac37fe473f945042e13359dc2d40 (diff)
downloadOneRoll-bb6b87a2685c0d71b5c38be33c100f85ac0b9cee.tar.gz
OneRoll-bb6b87a2685c0d71b5c38be33c100f85ac0b9cee.zip
Rework of the component to be a proper lib
Diffstat (limited to 'node/scalaroperatornode.cpp')
-rw-r--r--node/scalaroperatornode.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index 3a26fc7..9edbcdc 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -69,28 +69,29 @@ void ScalarOperatorNode::run(ExecutionNode* previous)
switch(m_arithmeticOperator)
{
case Die::PLUS:
- m_scalarResult->setValue(add(previousResult->getResult(Result::SCALAR).toReal(),
- internalResult->getResult(Result::SCALAR).toReal()));
+ m_scalarResult->setValue(add(previousResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal(),
+ internalResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal()));
break;
case Die::MINUS:
- m_scalarResult->setValue(substract(previousResult->getResult(Result::SCALAR).toReal(),
- internalResult->getResult(Result::SCALAR).toReal()));
+ m_scalarResult->setValue(substract(previousResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal(),
+ internalResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal()));
break;
case Die::MULTIPLICATION:
- m_scalarResult->setValue(multiple(previousResult->getResult(Result::SCALAR).toReal(),
- internalResult->getResult(Result::SCALAR).toReal()));
+ m_scalarResult->setValue(multiple(previousResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal(),
+ internalResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal()));
break;
case Die::DIVIDE:
- m_scalarResult->setValue(divide(previousResult->getResult(Result::SCALAR).toReal(),
- internalResult->getResult(Result::SCALAR).toReal()));
+ m_scalarResult->setValue(divide(previousResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal(),
+ internalResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal()));
break;
case Die::INTEGER_DIVIDE:
- m_scalarResult->setValue(static_cast<int>(divide(previousResult->getResult(Result::SCALAR).toReal(),
- internalResult->getResult(Result::SCALAR).toReal())));
+ m_scalarResult->setValue(
+ static_cast<int>(divide(previousResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal(),
+ internalResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal())));
break;
case Die::POW:
- m_scalarResult->setValue(pow(previousResult->getResult(Result::SCALAR).toReal(),
- internalResult->getResult(Result::SCALAR).toReal()));
+ m_scalarResult->setValue(pow(previousResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal(),
+ internalResult->getResult(Dice::RESULT_TYPE::SCALAR).toReal()));
break;
}
}
@@ -128,7 +129,7 @@ qreal ScalarOperatorNode::divide(qreal a, qreal b)
{
if(qFuzzyCompare(b, 0))
{
- m_errors.insert(DIVIDE_BY_ZERO, QObject::tr("Division by zero"));
+ m_errors.insert(Dice::ERROR_CODE::DIVIDE_BY_ZERO, QObject::tr("Division by zero"));
return 0;
}
return static_cast<qreal>(a / b);
@@ -240,12 +241,12 @@ void ScalarOperatorNode::generateDotTree(QString& s)
}
s.append(str);
}
-QMap<ExecutionNode::DICE_ERROR_CODE, QString> ScalarOperatorNode::getExecutionErrorMap()
+QMap<Dice::ERROR_CODE, QString> ScalarOperatorNode::getExecutionErrorMap()
{
if(nullptr != m_internalNode)
{
auto keys= m_internalNode->getExecutionErrorMap().keys();
- for(ExecutionNode::DICE_ERROR_CODE& key : keys)
+ for(const auto& key : keys)
{
m_errors.insert(key, m_internalNode->getExecutionErrorMap().value(key));
}
@@ -253,7 +254,7 @@ QMap<ExecutionNode::DICE_ERROR_CODE, QString> ScalarOperatorNode::getExecutionEr
if(nullptr != m_nextNode)
{
auto keys= m_nextNode->getExecutionErrorMap().keys();
- for(ExecutionNode::DICE_ERROR_CODE& key : keys)
+ for(auto const& key : keys)
{
m_errors.insert(key, m_nextNode->getExecutionErrorMap().value(key));
}