Planeshift
gmeventmanager.h
Go to the documentation of this file.
1 
19 #ifndef __GMEVENTMANAGER_H__
20 #define __GMEVENTMANAGER_H__
21 //=============================================================================
22 // Crystal Space Includes
23 //=============================================================================
24 #include <csutil/ref.h>
25 #include <csutil/csstring.h>
26 #include <csutil/array.h>
27 
28 //=============================================================================
29 // Project Includes
30 //=============================================================================
31 
32 //=============================================================================
33 // Local Includes
34 //=============================================================================
35 #include "msgmanager.h"
36 
41 #define MAX_PLAYERS_PER_EVENT 100
42 #define MAX_EVENT_NAME_LENGTH 40
43 #define MAX_REGISTER_RANGE 100.0
44 #define EVAL_LOCKOUT_TIME 24*60*60*1000
45 
46 #define UNDEFINED_GMID 0
47 
48 #define SUPPORT_GM_LEVEL GM_LEVEL_4
49 
50 class psItemStats;
51 class psRewardData;
52 
54 {
55  EMPTY = 0,
58 };
59 
60 #define NO_RANGE -1.0
61 
63 {
64  ALL,
67 };
68 
72 class GMEventManager : public MessageManager<GMEventManager>
73 {
74 public:
77 
78  bool Initialise(void);
79 
88  bool AddNewGMEvent(Client* client, csString eventName, csString eventDescription);
89 
97  bool RegisterPlayerInGMEvent(Client* client, Client* target);
98 
106  bool RegisterPlayersInRangeInGMEvent(Client* client, float range);
107 
116  bool CompleteGMEvent(Client* client, PID gmID, bool byTheControllerGM = true);
117 
125  bool CompleteGMEvent(Client* client, csString eventName);
126 
133  bool ListGMEvents(Client* client);
134 
144  bool RemovePlayerFromGMEvent(Client* client, Client* target);
145 
158  bool RewardPlayersInGMEvent(Client* client,
159  RangeSpecifier rewardRecipient,
160  float range,
161  Client* target,
162  psRewardData* reward);
163 
173  int GetAllGMEventsForPlayer(PID playerID,
174  csArray<int> &completedEvents,
175  int &runningEventAsGM,
176  csArray<int> &completedEventsAsGM);
177 
187  csString &name,
188  csString &description);
189 
191  virtual void HandleGMEventCommand(MsgEntry* me, Client* client);
192 
199  bool RemovePlayerFromGMEvents(PID playerID);
200 
208  bool AssumeControlOfGMEvent(Client* client, csString eventName);
209 
217  bool EraseGMEvent(Client* client, csString eventName);
218 
219 private:
220 
221  int nextEventID;
222 
223  struct PlayerData
224  {
225  PID PlayerID;
226  bool CanEvaluate;
227  };
228 
229  struct GMEvent
230  {
231  int id;
232  GMEventStatus status;
233  PID gmID;
234  csTicks EndTime;
235  csString eventName;
236  csString eventDescription;
237  csArray<PlayerData> Player;
238  };
239  csArray<GMEvent*> gmEvents;
240 
247  GMEvent* GetGMEventByID(int id);
248 
257  GMEvent* GetGMEventByGM(PID gmID, GMEventStatus status, int &startIndex);
258 
267  GMEvent* GetGMEventByName(csString eventName, GMEventStatus status, int &startIndex);
268 
281  GMEvent* GetGMEventByPlayer(PID playerID, GMEventStatus status, int &startIndex);
282 
290  size_t GetPlayerFromEvent(PID &PlayerID, GMEvent* Event);
291 
301  bool CheckEvalStatus(PID PlayerID, GMEvent* Event);
302 
311  void SetEvalStatus(PID PlayerID, GMEvent* Event, bool NewStatus);
312 
316  int GetNextEventID(void);
317 
324  void DiscardGMEvent(Client* client, int eventID);
325 
334  bool RemovePlayerRefFromGMEvent(GMEvent* gmEvent, Client* client, PID playerID);
335 
343  bool EraseGMEvent(Client* client, GMEvent* gmEvent);
344 
353  void WriteGMEventEvaluation(Client* client, GMEvent* Event, csString XmlStr);
354 };
355 
358 #endif
359 
bool EraseGMEvent(Client *client, csString eventName)
GM discards an event of theirs by name; participants are removed, and it is wiped from the DB...
GM event is complete.
bool RemovePlayerFromGMEvent(Client *client, Client *target)
A player is removed from a running event.
bool RegisterPlayersInRangeInGMEvent(Client *client, float range)
GM registers all players in range.
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
bool RemovePlayerFromGMEvents(PID playerID)
Removes a player from any GM event they maybe involved with (eg player being deleted) ...
GMEventStatus
bool CompleteGMEvent(Client *client, PID gmID, bool byTheControllerGM=true)
A player completes an event.
GameMaster Events manager class.
int GetAllGMEventsForPlayer(PID playerID, csArray< int > &completedEvents, int &runningEventAsGM, csArray< int > &completedEventsAsGM)
Returns all events for a player.
bool RegisterPlayerInGMEvent(Client *client, Client *target)
GM registers player into his/her event.
RangeSpecifier
bool AssumeControlOfGMEvent(Client *client, csString eventName)
GM attempts to assume control of an event, after originator has absconded.
This class collects data of a netclient.
Definition: client.h:95
GMEventStatus GetGMEventDetailsByID(int id, csString &name, csString &description)
Returns event details for a particular event.
bool ListGMEvents(Client *client)
Sends a list of all events to client.
GM event is running.
bool Initialise(void)
bool AddNewGMEvent(Client *client, csString eventName, csString eventDescription)
GM attempts to add new event.
bool RewardPlayersInGMEvent(Client *client, RangeSpecifier rewardRecipient, float range, Client *target, psRewardData *reward)
Reward players who complete an event.
This huge class stores all the properties of any object a player can have in the game.
Definition: psitemstats.h:463
virtual void HandleGMEventCommand(MsgEntry *me, Client *client)
handle message from client
no GM event
Reward Data is an abstract structure for all kinds of rewards.
Definition: adminmanager.h:89
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106