1 /* 2 * Copyright (C) 2011-2016 OpenDungeons Team 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef SEATDATA_H 19 #define SEATDATA_H 20 21 22 #include <OgreVector3.h> 23 #include <OgreColourValue.h> 24 #include <string> 25 #include <vector> 26 #include <iosfwd> 27 #include <cstdint> 28 29 class ODPacket; 30 31 enum class SkillType; 32 enum class RoomType; 33 34 //! \brief Base class for Seat that only embeds the data for the seat used through the network. It allows to use unit tests without having 35 //! to bring Seat dependencies (basically, the whole game) 36 class SeatData 37 { 38 public: 39 // Constructors 40 SeatData(); 41 setId(int id)42 inline void setId(int id) 43 { mId = id; } 44 getId()45 inline int getId() const 46 { return mId; } 47 getTeamId()48 inline int getTeamId() const 49 { return mTeamId; } 50 getNumClaimedTiles()51 inline unsigned int getNumClaimedTiles() const 52 { return mNumClaimedTiles; } 53 setNumClaimedTiles(const unsigned int & num)54 inline void setNumClaimedTiles(const unsigned int& num) 55 { mNumClaimedTiles = num; } 56 incrementNumClaimedTiles()57 inline void incrementNumClaimedTiles() 58 { ++mNumClaimedTiles; } 59 60 void setTeamId(int teamId); 61 getAvailableTeamIds()62 inline const std::vector<int>& getAvailableTeamIds() const 63 { return mAvailableTeamIds; } 64 getFaction()65 inline const std::string& getFaction() const 66 { return mFaction; } 67 setFaction(const std::string & faction)68 inline void setFaction(const std::string& faction) 69 { mFaction = faction; } 70 setColorId(const std::string & colorId)71 inline void setColorId(const std::string& colorId) 72 { mColorId = colorId; } 73 getColorId()74 inline const std::string& getColorId() const 75 { return mColorId; } 76 getGold()77 inline int getGold() const 78 { return mGold; } 79 getGoldMax()80 inline int getGoldMax() const 81 { return mGoldMax; } 82 getMana()83 inline double getMana() const 84 { return mMana; } 85 getManaDelta()86 inline double getManaDelta() const 87 { return mManaDelta; } 88 getNumCreaturesFighters()89 inline int getNumCreaturesFighters() const 90 { return mNumCreaturesFighters; } 91 getNumCreaturesFightersMax()92 inline int getNumCreaturesFightersMax() const 93 { return mNumCreaturesFightersMax; } 94 getNumCreaturesWorkers()95 inline int getNumCreaturesWorkers() const 96 { return mNumCreaturesWorkers; } 97 98 uint32_t getNbRooms(RoomType roomType) const; 99 getPlayerType()100 inline const std::string& getPlayerType() const 101 { return mPlayerType; } 102 setPlayerType(const std::string & playerType)103 inline void setPlayerType(const std::string& playerType) 104 { mPlayerType = playerType; } 105 getSkillNotAllowed()106 inline const std::vector<SkillType>& getSkillNotAllowed() const 107 { return mSkillNotAllowed; } 108 109 //! \brief functions to transfer Seat data through network. Note that they should not be overriden as 110 //! unit tests use them to get the data from the Seat (without having to take Seat and all its dependencies) 111 bool importFromPacket(ODPacket& is); 112 void exportToPacket(ODPacket& os) const; 113 bool importFromPacketForUpdate(ODPacket& is); 114 void exportToPacketForUpdate(ODPacket& os) const; 115 116 static std::string displayAsString(const SeatData* seat); 117 118 protected: 119 //! \brief The seat id. Allows to identify this seat. Must be unique per level file. 120 int mId; 121 122 //! \brief The team id of the player sitting in this seat. 123 int mTeamId; 124 125 //! \brief The type of player (can be Human or AI). 126 std::string mPlayerType; 127 128 //! \brief The name of the faction that this seat is playing as (can be Keeper or Hero). 129 std::string mFaction; 130 131 //! \brief The amount of 'keeper mana' the player has. 132 double mMana; 133 134 //! \brief The amount of 'keeper mana' the player gains/loses per turn, updated in GameMap::doTurn(). 135 double mManaDelta; 136 137 //! \brief The starting camera location (in tile coordinates) of this seat. 138 int mStartingX; 139 int mStartingY; 140 141 //! \brief The number of living creatures fighters under this seat's control 142 int mNumCreaturesFighters; 143 int mNumCreaturesFightersMax; 144 int mNumCreaturesWorkers; 145 146 //! \brief The actual color that this color index translates into. 147 std::string mColorId; 148 149 //! \brief Team ids this seat can use defined in the level file. 150 std::vector<int> mAvailableTeamIds; 151 152 //! \brief How many tiles have been claimed by this seat, updated in GameMap::doTurn(). 153 unsigned int mNumClaimedTiles; 154 155 bool mHasGoalsChanged; 156 157 //! \brief The total amount of gold coins in the keeper's treasury and in the dungeon heart. 158 int mGold; 159 160 //! \brief The total amount of gold coins that the keeper treasuries can have. 161 int mGoldMax; 162 163 //! \brief The number of rooms the player owns (room index being room type). 164 //! Useful to display the first free tile on client side for example 165 std::vector<uint32_t> mNbRooms; 166 167 //! \brief Skills not allowed. Used on server side only 168 std::vector<SkillType> mSkillNotAllowed; 169 170 //! \brief Progress for current skill. Allows to display the progressbar on the client side 171 SkillType mCurrentSkillType; 172 float mCurrentSkillProgress; 173 }; 174 175 #endif // SEATDATA_H 176