| 1 |
// Copyright © 2001-2003 Rob Kaper <[email protected]>, |
| 2 |
// 2001 Erik Bourget <[email protected]> |
| 3 |
// 2010-2015 Sylvain Rochet <[email protected]> |
| 4 |
// |
| 5 |
// This program is free software; you can redistribute it and/or |
| 6 |
// modify it under the terms of the GNU General Public License |
| 7 |
// version 2 as published by the Free Software Foundation. |
| 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 GNU |
| 12 |
// 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; see the file COPYING. If not, see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
#ifndef MONOP_GAMEOBJECT_H |
| 19 |
#define MONOP_GAMEOBJECT_H |
| 20 |
|
| 21 |
#include <string> |
| 22 |
#include <vector> |
| 23 |
|
| 24 |
class GameIntProperty; |
| 25 |
class GameStringProperty; |
| 26 |
class GameBoolProperty; |
| 27 |
class Game; |
| 28 |
class GameObject; |
| 29 |
|
| 30 |
class GameObject |
| 31 |
{ |
| 32 |
public: |
| 33 |
// We can abuse a Money object with its id as amount in trades. |
| 34 |
enum Type { Unknown = 0, GGame, GCard, GEstate, GEstateGroup, GPlayer, Money, ConfigOption }; |
| 35 |
|
| 36 |
GameObject(int id, Type type = Unknown, Game *game = 0); |
| 37 |
~GameObject(); |
| 38 |
|
| 39 |
void setId(int id) { m_id = id; } |
| 40 |
int id(); |
| 41 |
std::string name(); |
| 42 |
enum Type type(); |
| 43 |
Game *game(); |
| 44 |
|
| 45 |
void setProperty(const std::string &key, const std::string &value, GameObject *scope = 0); |
| 46 |
void setProperty(const std::string &key, int value, GameObject *scope = 0); |
| 47 |
void setBoolProperty(const std::string &key, const bool &value, GameObject *scope = 0); |
| 48 |
std::string getStringProperty(const std::string &key); |
| 49 |
bool hasIntProperty(const std::string &key); |
| 50 |
int getIntProperty(const std::string &key); |
| 51 |
bool getBoolProperty(const std::string &key); |
| 52 |
|
| 53 |
void removeProperty(const std::string &key); |
| 54 |
|
| 55 |
void unsetPropertiesChanged(); |
| 56 |
bool propertiesChanged() const; |
| 57 |
|
| 58 |
void addToScope(GameObject *object); |
| 59 |
bool hasInScope(GameObject *object); |
| 60 |
void removeFromScope(GameObject *object); |
| 61 |
|
| 62 |
bool propertiesChanged(GameObject *target); |
| 63 |
std::string oldXMLUpdate(GameObject *target, const bool &fullUpdate = false); |
| 64 |
std::string xmlUpdate(GameObject *target, const bool &fullUpdate = false); |
| 65 |
|
| 66 |
protected: |
| 67 |
int m_id; |
| 68 |
Type m_type; |
| 69 |
Game *m_game; |
| 70 |
|
| 71 |
private: |
| 72 |
std::vector<GameStringProperty *> m_stringProperties; |
| 73 |
std::vector<GameIntProperty *> m_intProperties; |
| 74 |
std::vector<GameBoolProperty *> m_boolProperties; |
| 75 |
std::vector<GameObject *> m_scope; |
| 76 |
}; |
| 77 |
|
| 78 |
#endif |