File indexing completed on 2024-04-28 05:37:00
0001 /*************************************************************************** 0002 * Copyright (C) 2014 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * This file is part of DiceParser * 0006 * * 0007 * DiceParser is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 ***************************************************************************/ 0022 #ifndef DIE_H 0023 #define DIE_H 0024 0025 #include <QList> 0026 #include <QString> 0027 #include <random> 0028 0029 #include "diceparser/diceparserhelper.h" 0030 /** 0031 * @brief The Die class implements all methods required from a die. You must set the Faces first, then you can roll it 0032 * and roll it again, to add or replace the previous result. 0033 */ 0034 class Die 0035 { 0036 public: 0037 /** 0038 * @brief Die 0039 */ 0040 Die(); 0041 /** 0042 * @brief Die 0043 */ 0044 Die(const Die&); 0045 /** 0046 * @brief setValue 0047 * @param r 0048 */ 0049 void setValue(qint64 r); 0050 /** 0051 * @brief insertRollValue 0052 * @param r 0053 */ 0054 void insertRollValue(qint64 r); 0055 /** 0056 * @brief setSelected 0057 * @param b 0058 */ 0059 void setSelected(bool b); 0060 /** 0061 * @brief isSelected 0062 * @return 0063 */ 0064 bool isSelected() const; 0065 /** 0066 * @brief getValue 0067 * @return 0068 */ 0069 qint64 getValue() const; 0070 /** 0071 * @brief getListValue 0072 * @return 0073 */ 0074 QList<qint64> getListValue() const; 0075 /** 0076 * @brief hasChildrenValue 0077 * @return 0078 */ 0079 bool hasChildrenValue(); 0080 0081 /** 0082 * @brief roll 0083 * @param adding 0084 */ 0085 void roll(bool adding= false); 0086 /** 0087 * @brief replaceLastValue 0088 * @param value 0089 */ 0090 void replaceLastValue(qint64 value); 0091 0092 /** 0093 * @brief getLastRolledValue 0094 * @return 0095 */ 0096 qint64 getLastRolledValue(); 0097 /** 0098 * @brief getFaces 0099 * @return 0100 */ 0101 quint64 getFaces() const; 0102 /** 0103 * @brief hasBeenDisplayed 0104 * @return 0105 */ 0106 bool hasBeenDisplayed() const; 0107 /** 0108 * @brief displayed 0109 */ 0110 void displayed(); 0111 /** 0112 * @brief setHighlighted 0113 */ 0114 void setHighlighted(bool); 0115 /** 0116 * @brief isHighlighted 0117 * @return 0118 */ 0119 bool isHighlighted() const; 0120 0121 /** 0122 * @brief setBase 0123 */ 0124 void setBase(qint64); 0125 qint64 getBase(); 0126 0127 QString getColor() const; 0128 void setColor(const QString& color); 0129 0130 qint64 getMaxValue() const; 0131 void setMaxValue(const qint64& maxValue); 0132 0133 Dice::ArithmeticOperator getOp() const; 0134 void setOp(const Dice::ArithmeticOperator& op); 0135 void setDisplayed(bool b); 0136 0137 QString getUuid() const; 0138 void setUuid(const QString& uuid); 0139 0140 static void buildSeed(); 0141 0142 private: 0143 QString m_uuid; 0144 qint64 m_value{0}; 0145 QList<qint64> m_rollResult; 0146 bool m_selected{false}; 0147 bool m_hasValue{false}; 0148 bool m_displayStatus{false}; 0149 bool m_highlighted{true}; 0150 qint64 m_maxValue{0}; 0151 qint64 m_base{0}; 0152 qint64 m_occurence{1}; 0153 QString m_color; 0154 0155 Dice::ArithmeticOperator m_op; 0156 0157 static std::mt19937 s_rng; 0158 }; 0159 0160 #endif // DIE_H