1 /* 2 * Hedgewars, a free turn based strategy game 3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> 4 * Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; version 2 of the License 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef TEAM_H 21 #define TEAM_H 22 23 #include <QColor> 24 #include <QString> 25 #include "binds.h" 26 #include "achievements.h" 27 #include "hwconsts.h" 28 29 class HWForm; 30 class GameUIConfig; 31 32 class HWTeamConstructException 33 { 34 }; 35 36 // structure for customization and statistics of a single hedgehog 37 struct HWHog 38 { 39 QString Name; 40 QString Hat; 41 HWHogHWHog42 HWHog(){} 43 }; 44 45 // class representing a team 46 class HWTeam : public QObject 47 { 48 Q_OBJECT 49 50 public: 51 52 // constructors 53 HWTeam(const QString & teamname); 54 HWTeam(const QStringList& strLst); 55 HWTeam(); 56 HWTeam(const HWTeam & other); 57 58 // file operations 59 static HWTeam loadFromFile(const QString & teamName); 60 bool loadFromFile(); 61 bool deleteFile(); 62 bool saveToFile(); 63 bool fileExists(); 64 bool wouldOverwriteOtherFile(); 65 66 // attribute getters 67 int color() const; 68 QColor qcolor() const; 69 unsigned int difficulty() const; 70 QString flag() const; 71 QString fort() const; 72 QString grave() const; 73 const HWHog & hedgehog(unsigned int idx) const; 74 bool isNetTeam() const; 75 bool isMissionTeam() const; 76 QString keyBind(unsigned int idx) const; 77 QString name() const; 78 unsigned char numHedgehogs() const; 79 QString owner() const; 80 void setOwner(const QString & owner); 81 QString voicepack() const; 82 83 // attribute setters 84 void bindKey(unsigned int idx, const QString & key); 85 void setDifficulty(unsigned int level); 86 void setFlag(const QString & flag); 87 void setFort(const QString & fort); 88 void setGrave(const QString & grave); 89 void setHedgehog(unsigned int idx, HWHog hh); 90 void setName(const QString & name); 91 void setNumHedgehogs(unsigned char num); 92 void setVoicepack(const QString & voicepack); 93 void setNetTeam(bool isNetTeam); 94 void setMissionTeam(bool isMissionTeam); 95 96 // convert team info into strings for further computation 97 QStringList teamGameConfig(quint32 InitHealth) const; 98 99 // comparison operators 100 bool operator == (const HWTeam& t1) const; 101 bool operator < (const HWTeam& t1) const; 102 HWTeam & operator = (const HWTeam & other); 103 104 public slots: 105 void setColor(int color); 106 107 private: 108 109 QString OldTeamName; 110 111 // class members that contain the general team info and settings 112 QString m_name; 113 QString m_grave; 114 QString m_fort; 115 QString m_flag; 116 QString m_voicepack; 117 QList<HWHog> m_hedgehogs; 118 quint8 m_difficulty; 119 QList<BindAction> m_binds; 120 121 // class members that contain info for the current game setup 122 quint8 m_numHedgehogs; 123 int m_color; 124 bool m_isNetTeam; 125 bool m_isMissionTeam; 126 QString m_owner; 127 128 // class members that contain statistics, etc. 129 unsigned int AchievementProgress[MAX_ACHIEVEMENTS]; 130 }; 131 132 #endif 133