File indexing completed on 2024-05-12 05:39:27
0001 /*************************************************************************** 0002 * Copyright (C) 2015 by Renaud Guezennec * 0003 * http:://www.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 #ifndef IFNODE_H 0021 #define IFNODE_H 0022 0023 #include "executionnode.h" 0024 #include "result/diceresult.h" 0025 #include <diceparser/diceparserhelper.h> 0026 0027 class ValidatorList; 0028 class PartialDiceRollNode : public ExecutionNode 0029 { 0030 public: 0031 PartialDiceRollNode(); 0032 0033 void insertDie(Die* die); 0034 virtual void run(ExecutionNode* previous= nullptr) override; 0035 virtual qint64 getPriority() const override; 0036 virtual ExecutionNode* getCopy() const override; 0037 virtual QString toString(bool withLabel) const override; 0038 0039 private: 0040 DiceResult* m_diceResult; 0041 }; 0042 0043 /** 0044 * @brief The ifNode class explode dice while is valid by the validator. 0045 */ 0046 class IfNode : public ExecutionNode 0047 { 0048 public: 0049 /** 0050 * @brief IfNode 0051 */ 0052 IfNode(); 0053 /** 0054 * @brief ~IfNode 0055 */ 0056 virtual ~IfNode(); 0057 /** 0058 * @brief run 0059 * @param previous 0060 */ 0061 virtual void run(ExecutionNode* previous= nullptr); 0062 /** 0063 * @brief setValidator 0064 */ 0065 virtual void setValidatorList(ValidatorList*); 0066 /** 0067 * @brief setInstructionTrue 0068 */ 0069 virtual void setInstructionTrue(ExecutionNode*); 0070 /** 0071 * @brief setInstructionFalse 0072 */ 0073 virtual void setInstructionFalse(ExecutionNode*); 0074 /** 0075 * @brief toString 0076 * @return 0077 */ 0078 virtual QString toString(bool) const; 0079 /** 0080 * @brief getPriority 0081 * @return 0082 */ 0083 virtual qint64 getPriority() const; 0084 0085 /** 0086 * @brief generateDotTree 0087 */ 0088 virtual void generateDotTree(QString&); 0089 0090 /** 0091 * @brief getCopy 0092 * @return 0093 */ 0094 virtual ExecutionNode* getCopy() const; 0095 /** 0096 * @brief getConditionType 0097 * @return 0098 */ 0099 Dice::ConditionType getConditionType() const; 0100 0101 /** 0102 * @brief setConditionType 0103 * @param conditionType 0104 */ 0105 void setConditionType(const Dice::ConditionType& conditionType); 0106 0107 protected: 0108 ExecutionNode* getLeafNode(ExecutionNode* node); 0109 0110 protected: 0111 ValidatorList* m_validatorList= nullptr; 0112 Dice::ConditionType m_conditionType; 0113 0114 ExecutionNode* m_true; 0115 ExecutionNode* m_false; 0116 }; 0117 #endif