File indexing completed on 2024-05-12 05:39:27
0001 #ifndef DICEROLLERNODE_H 0002 #define DICEROLLERNODE_H 0003 0004 #include <Qt> 0005 0006 #include "executionnode.h" 0007 #include "result/diceresult.h" 0008 #include <utility> 0009 /** 0010 * @brief The DiceRollerNode class rolls dice of one kind. 0011 */ 0012 class DiceRollerNode : public ExecutionNode 0013 { 0014 public: 0015 /** 0016 * @brief DiceRollerNode builds an instance 0017 * @param faces, number of faces of dices 0018 * @param offset, first value of dice. 0019 */ 0020 DiceRollerNode(qint64 max, qint64 min= 1); 0021 0022 /** 0023 * @brief run - starts to roll dice. 0024 */ 0025 virtual void run(ExecutionNode*); 0026 /** 0027 * @brief getFaces accessor 0028 * @return the face count 0029 */ 0030 quint64 getFaces() const; 0031 std::pair<qint64, qint64> getRange() const; 0032 0033 /** 0034 * @brief toString 0035 * @param wl 0036 * @return use to generate dot tree; 0037 */ 0038 virtual QString toString(bool wl) const; 0039 /** 0040 * @brief getPriority 0041 * @return priority for dice roll: 4 (higher) 0042 */ 0043 virtual qint64 getPriority() const; 0044 0045 virtual ExecutionNode* getCopy() const; 0046 0047 // private members 0048 Dice::ArithmeticOperator getOperator() const; 0049 void setOperator(const Dice::ArithmeticOperator& dieOperator); 0050 0051 bool getUnique() const; 0052 void setUnique(bool unique); 0053 0054 private: 0055 quint64 m_diceCount; 0056 qint64 m_max; /// faces 0057 DiceResult* m_diceResult{nullptr}; 0058 qint64 m_min; 0059 Dice::ArithmeticOperator m_operator; 0060 bool m_unique{false}; 0061 }; 0062 0063 #endif // DICEROLLERNODE_H