File indexing completed on 2024-04-28 05:37:00

0001 /***************************************************************************
0002  *   Copyright (C) 2015 by Renaud Guezennec                                *
0003  *   https://rolisteam.org/contact                   *
0004  *                                                                         *
0005  *   rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #ifndef OPERATIONCONDITION_H
0022 #define OPERATIONCONDITION_H
0023 
0024 #include "booleancondition.h"
0025 #include "node/executionnode.h"
0026 #include "validator.h"
0027 #include <Qt>
0028 
0029 class OperationCondition : public Validator
0030 {
0031 public:
0032     OperationCondition();
0033     virtual ~OperationCondition() override;
0034 
0035     virtual qint64 hasValid(Die* b, bool recursive, bool unhighlight= false) const override;
0036 
0037     void setOperator(Dice::ConditionOperator m);
0038     // void setValue(qint64);
0039     void setValueNode(ExecutionNode* node);
0040     QString toString() override;
0041 
0042     virtual Dice::CONDITION_STATE isValidRangeSize(const std::pair<qint64, qint64>& range) const override;
0043 
0044     BooleanCondition* getBoolean() const;
0045     void setBoolean(BooleanCondition* boolean);
0046 
0047     virtual Validator* getCopy() const override;
0048 
0049     const std::set<qint64>& getPossibleValues(const std::pair<qint64, qint64>& range) override;
0050 
0051 private:
0052     qint64 valueToScalar() const;
0053 
0054 private:
0055     Dice::ConditionOperator m_operator{Dice::ConditionOperator::Modulo};
0056     BooleanCondition* m_boolean= nullptr;
0057     // qint64 m_value;
0058     ExecutionNode* m_value= nullptr;
0059 };
0060 
0061 #endif // OPERATIONCONDITION_H