47
48
//! The xml tag of this object in a saved-game file.
48
49
static std::string d_tag;
50
//! Gets the singleton instance or creates a new one.
51
static Playerlist* getInstance();
54
* Load all Players in the Playerlist from a saved-game file.
56
* @param helper The opened saved-game file to read from.
58
* @return The loaded Playerlist.
60
//! Loads the playerlist from a saved-game file.
61
static Playerlist* getInstance(XML_Helper* helper);
63
//! Explicitly deletes the singleton instance.
64
static void deleteInstance();
66
//! Returns the active player (the Player whose turn it is).
67
static Player* getActiveplayer() {return d_activeplayer;}
53
//! Set the winning human player.
54
void setWinningPlayer(Player *winner);
56
//! Set the player who's turn it is. should only be used by the editor.
57
void setActiveplayer(Player *p) {d_activeplayer = p;};
59
//! set the player who is looking at the bigmap and smallmap.
60
void setViewingplayer(Player *p) {viewingplayer = p;};
64
//! Returns the neutral player.
65
Player* getNeutral() const {return d_neutral;}
67
//! Return the player with the highest score.
68
Player *getWinningPlayer() const;
71
// Methods that operate on the class data and modify the class.
69
73
//! Sets the active player to the next player in the order.
89
93
//! Set the neutral player.
90
94
void setNeutral(Player* neutral) {d_neutral = neutral;}
92
//! Returns the neutral player.
93
Player* getNeutral() const {return d_neutral;}
96
* Scan the list of players for a Player with a given name.
98
* @param name The name of the Player to lookup.
100
* @return A pointer to the Player if it is found, or NULL if it isn't.
102
//! Lookup a Player by it's name.
103
Player* getPlayer(std::string name) const;
106
* Scan the list of players for a Player with a given Id.
108
* @param id The id of the Player to lookup.
110
* @return A pointer to the Player if it is found, or NULL if it isn't.
112
//! Lookup a Player by it's Id.
113
Player* getPlayer(guint32 id) const;
115
//! Returns the number of living players (neutral player excluded.)
116
guint32 getNoOfPlayers() const;
119
* Scan the list of players for the first Player that is alive.
120
* This method is used to determine the beginning of a round.
122
* @return A pointer to the first living Player.
124
//! Return the first living Player in the list.
125
Player* getFirstLiving() const;
128
97
* Swap out a player from the list and replace it with a new one.
129
98
* Specical care is taken to remove all references to the original
139
108
//! Replace a Player in the list with a new Player.
140
109
void swap(Player *old_player, Player *new_player);
142
//! Saves the playerlist to an opened saved-game file.
143
bool save(XML_Helper* helper) const;
146
112
* Erase a Player from the list, and free the contents of the Player.
173
139
//! Callback method to process all players at the start of a round.
174
140
void nextRound(bool diplomacy, bool *surrender_already_offered);
176
//! Return the number of human players left alive in the list.
177
guint32 countHumanPlayersAlive();
179
//! Return the number of players left alive, not including neutral.
180
guint32 countPlayersAlive();
183
143
* The purpose of randomzing the Playerlist is to implement
208
168
//! Sync the given player with the playerlist
209
169
void syncPlayer(GameParameters::Player player);
171
//! Converts all of the human players into network players.
172
void turnHumansIntoNetworkPlayers();
174
//! Converts a given number of the human players into a type of player.
175
void turnHumansInto(Player::Type type, int num_players = -1);
177
//! Reorder the list according to the given order.
178
void reorder(std::list<guint32> order);
180
//! Perform the surrender of all computer players.
183
//! Add a player to the list. Use this instead of push_back.
184
void add(Player *player);
187
// Methods that operate on the class data but do not modify it.
190
* Scan the list of players for a Player with a given name.
192
* @param name The name of the Player to lookup.
194
* @return A pointer to the Player if it is found, or NULL if it isn't.
196
//! Lookup a Player by it's name.
197
Player* getPlayer(std::string name) const;
200
* Scan the list of players for a Player with a given Id.
202
* @param id The id of the Player to lookup.
204
* @return A pointer to the Player if it is found, or NULL if it isn't.
206
//! Lookup a Player by it's Id.
207
Player* getPlayer(guint32 id) const;
209
//! Returns the number of living players (neutral player excluded.)
210
guint32 getNoOfPlayers() const;
213
* Scan the list of players for the first Player that is alive.
214
* This method is used to determine the beginning of a round.
216
* @return A pointer to the first living Player.
218
//! Return the first living Player in the list.
219
Player* getFirstLiving() const;
221
//! Saves the playerlist to an opened saved-game file.
222
bool save(XML_Helper* helper) const;
224
//! Return the number of human players left alive in the list.
225
guint32 countHumanPlayersAlive() const;
227
//! Return the number of players left alive, not including neutral.
228
guint32 countPlayersAlive() const;
231
//! Return the list of activities that the given hero has accomplished.
232
std::list<History *>getHistoryForHeroId(guint32 id) const;
235
\brief Check to see if this is the end of the round or not.
237
bool isEndOfRound() const;
212
243
* @param player The player who has died.
223
254
//! Emitted when a surrender is offered.
224
255
sigc::signal<void, Player*> ssurrender;
226
void turnHumansIntoNetworkPlayers();
227
void turnHumansInto(Player::Type type, int num_players = -1);
228
void reorder(std::list<guint32> order);
230
std::list<History *>getHistoryForHeroId(guint32 id);
235
\brief Check to see if this is the end of the round or not.
239
void setWinningPlayer(Player *winner);
260
//! Gets the singleton instance or creates a new one.
261
static Playerlist* getInstance();
264
* Load all Players in the Playerlist from a saved-game file.
266
* @param helper The opened saved-game file to read from.
268
* @return The loaded Playerlist.
270
//! Loads the playerlist from a saved-game file.
271
static Playerlist* getInstance(XML_Helper* helper);
273
//! Explicitly deletes the singleton instance.
274
static void deleteInstance();
276
//! Returns the active player (the Player whose turn it is).
277
static Player* getActiveplayer() {return d_activeplayer;}
279
//! Returns the viewing player (the Player who is looking at maps).
280
static Player *getViewingplayer() {return viewingplayer;}
283
int countFightsThisTurn() const;
284
int countMovesThisTurn() const;
242
287
//! Default constructor.
244
290
//! Loading constructor.
245
291
Playerlist(XML_Helper* helper);
266
313
void negotiateDiplomacy();
269
317
//! The pointer to the player whose turn it is in the list.
270
318
static Player* d_activeplayer;
320
//! The player that the smallmap and bigmap are being viewed as.
321
static Player *viewingplayer;
272
323
//! The pointer to the neutral player in the list.
273
324
Player* d_neutral;
326
typedef std::map<guint32, Player*> IdMap;
275
329
//! A static pointer for the singleton instance.
276
330
static Playerlist* s_instance;