diff options
| author | 2019-02-12 23:59:24 +0100 | |
|---|---|---|
| committer | 2019-02-12 23:59:24 +0100 | |
| commit | f2051fb35b1ad49c4d940e6fbba2acc98b216e13 (patch) | |
| tree | 03117f493191d35104ac37eba72e916d41c849f2 /booleancondition.cpp | |
| parent | 210a222b894caa3c8af38ccb6653db0fd8491f6e (diff) | |
| download | OneRoll-f2051fb35b1ad49c4d940e6fbba2acc98b216e13.tar.gz OneRoll-f2051fb35b1ad49c4d940e6fbba2acc98b216e13.zip | |
clang format
Diffstat (limited to 'booleancondition.cpp')
| -rw-r--r-- | booleancondition.cpp | 90 |
1 files changed, 44 insertions, 46 deletions
diff --git a/booleancondition.cpp b/booleancondition.cpp index 8652e8b..f62c900 100644 --- a/booleancondition.cpp +++ b/booleancondition.cpp @@ -1,37 +1,35 @@ /*************************************************************************** -* Copyright (C) 2014 by Renaud Guezennec * -* http://www.rolisteam.org/contact * -* * -* This file is part of DiceParser * -* * -* DiceParser is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ + * Copyright (C) 2014 by Renaud Guezennec * + * http://www.rolisteam.org/contact * + * * + * This file is part of DiceParser * + * * + * DiceParser is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #include "booleancondition.h" #include <QDebug> -BooleanCondition::BooleanCondition() : m_operator(Equal) -{ -} +BooleanCondition::BooleanCondition() : m_operator(Equal) {} BooleanCondition::~BooleanCondition() { if(m_value != nullptr) { delete m_value; - m_value = nullptr; + m_value= nullptr; } } qint64 BooleanCondition::hasValid(Die* b, bool recursive, bool unhighlight) const @@ -39,36 +37,36 @@ qint64 BooleanCondition::hasValid(Die* b, bool recursive, bool unhighlight) cons QList<qint64> listValues; if(recursive) { - listValues = b->getListValue(); + listValues= b->getListValue(); } else { listValues.append(b->getLastRolledValue()); } - qint64 sum = 0; - auto valueScalar = valueToScalar(); + qint64 sum= 0; + auto valueScalar= valueToScalar(); for(qint64& value : listValues) { switch(m_operator) { case Equal: - sum += (value == valueScalar) ? 1 : 0; + sum+= (value == valueScalar) ? 1 : 0; break; case GreaterThan: - sum += (value > valueScalar) ? 1 : 0; + sum+= (value > valueScalar) ? 1 : 0; break; case LesserThan: - sum += (value < valueScalar) ? 1 : 0; + sum+= (value < valueScalar) ? 1 : 0; break; case GreaterOrEqual: - sum += (value >= valueScalar) ? 1 : 0; + sum+= (value >= valueScalar) ? 1 : 0; break; case LesserOrEqual: - sum += (value <= valueScalar) ? 1 : 0; + sum+= (value <= valueScalar) ? 1 : 0; break; case Different: - sum += (value != valueScalar) ? 1 : 0; + sum+= (value != valueScalar) ? 1 : 0; break; } } @@ -86,12 +84,12 @@ qint64 BooleanCondition::hasValid(Die* b, bool recursive, bool unhighlight) cons void BooleanCondition::setOperator(LogicOperator m) { - m_operator = m; + m_operator= m; } void BooleanCondition::setValueNode(ExecutionNode* v) { - m_value = v; + m_value= v; } QString BooleanCondition::toString() { @@ -121,35 +119,35 @@ QString BooleanCondition::toString() } bool BooleanCondition::isValidRangeSize(std::pair<qint64, qint64> range) const { - bool isValid = false; - auto valueScalar = valueToScalar(); - qint64 boundValue = qBound(range.first,valueScalar,range.second); + bool isValid= false; + auto valueScalar= valueToScalar(); + qint64 boundValue= qBound(range.first, valueScalar, range.second); switch(m_operator) { case Equal: - isValid = (boundValue == valueScalar); + isValid= (boundValue == valueScalar); break; case GreaterThan: - isValid = range.first<=valueScalar; + isValid= range.first <= valueScalar; break; case LesserThan: - isValid = range.second>=valueScalar; + isValid= range.second >= valueScalar; break; case GreaterOrEqual: - isValid = range.first<valueScalar; + isValid= range.first < valueScalar; break; case LesserOrEqual: - isValid = range.second>valueScalar; + isValid= range.second > valueScalar; break; case Different: - isValid = (boundValue == valueScalar); + isValid= (boundValue == valueScalar); break; } return isValid; } Validator* BooleanCondition::getCopy() const { - BooleanCondition* val = new BooleanCondition(); + BooleanCondition* val= new BooleanCondition(); val->setOperator(m_operator); val->setValueNode(m_value); return val; @@ -160,6 +158,6 @@ qint64 BooleanCondition::valueToScalar() const return 0; m_value->run(nullptr); - auto result = m_value->getResult(); + auto result= m_value->getResult(); return result->getResult(Result::SCALAR).toInt(); } |