Planeshift

gmeventmanager.h

Go to the documentation of this file.
00001 
00019 #ifndef __GMEVENTMANAGER_H__
00020 #define __GMEVENTMANAGER_H__
00021 //=============================================================================
00022 // Crystal Space Includes
00023 //=============================================================================
00024 #include <csutil/ref.h>
00025 #include <csutil/csstring.h>
00026 #include <csutil/array.h>
00027 
00028 //=============================================================================
00029 // Project Includes
00030 //=============================================================================
00031 
00032 //=============================================================================
00033 // Local Includes
00034 //=============================================================================
00035 #include "msgmanager.h"
00036 
00041 #define MAX_PLAYERS_PER_EVENT 100
00042 #define MAX_EVENT_NAME_LENGTH 40
00043 #define MAX_REGISTER_RANGE    100.0
00044 #define EVAL_LOCKOUT_TIME 24*60*60*1000 ///< how much time the player should be allowed to evalute an event (24 hours here)
00045 
00046 #define UNDEFINED_GMID        0
00047 
00048 #define SUPPORT_GM_LEVEL      GM_LEVEL_4
00049 
00050 class psItemStats;
00051 class psRewardData;
00052 
00053 enum GMEventStatus
00054 {
00055     EMPTY = 0,                 
00056     RUNNING,                   
00057     COMPLETED                  
00058 };
00059 
00060 #define NO_RANGE -1.0
00061 
00062 enum RangeSpecifier
00063 {
00064     ALL,
00065     IN_RANGE,
00066     INDIVIDUAL
00067 };
00068 
00072 class GMEventManager : public MessageManager<GMEventManager>
00073 {
00074 public:
00075     GMEventManager();
00076     ~GMEventManager();
00077 
00078     bool Initialise(void);
00079 
00088     bool AddNewGMEvent(Client* client, csString eventName, csString eventDescription);
00089 
00097     bool RegisterPlayerInGMEvent(Client* client, Client* target);
00098 
00106     bool RegisterPlayersInRangeInGMEvent(Client* client, float range);
00107 
00116     bool CompleteGMEvent(Client* client, PID gmID, bool byTheControllerGM = true);
00117 
00125     bool CompleteGMEvent(Client* client, csString eventName);
00126 
00133     bool ListGMEvents(Client* client);
00134 
00144     bool RemovePlayerFromGMEvent(Client* client, Client* target);
00145 
00158     bool RewardPlayersInGMEvent(Client* client,
00159                                 RangeSpecifier rewardRecipient,
00160                                 float range,
00161                                 Client* target,
00162                                 psRewardData* reward);
00163 
00173     int GetAllGMEventsForPlayer(PID playerID,
00174                                 csArray<int> &completedEvents,
00175                                 int &runningEventAsGM,
00176                                 csArray<int> &completedEventsAsGM);
00177 
00186     GMEventStatus GetGMEventDetailsByID(int id,
00187                                         csString &name,
00188                                         csString &description);
00189 
00191     virtual void HandleGMEventCommand(MsgEntry* me, Client* client);
00192 
00199     bool RemovePlayerFromGMEvents(PID playerID);
00200 
00208     bool AssumeControlOfGMEvent(Client* client, csString eventName);
00209 
00217     bool EraseGMEvent(Client* client, csString eventName);
00218 
00219 private:
00220 
00221     int nextEventID;
00222 
00223     struct PlayerData
00224     {
00225         PID PlayerID; 
00226         bool CanEvaluate; 
00227     };
00228 
00229     struct GMEvent
00230     {
00231         int id; 
00232         GMEventStatus status; 
00233         PID gmID; 
00234         csTicks EndTime; 
00235         csString eventName; 
00236         csString eventDescription; 
00237         csArray<PlayerData> Player; 
00238     };
00239     csArray<GMEvent*> gmEvents;    
00240 
00247     GMEvent* GetGMEventByID(int id);
00248 
00257     GMEvent* GetGMEventByGM(PID gmID, GMEventStatus status, int &startIndex);
00258 
00267     GMEvent* GetGMEventByName(csString eventName, GMEventStatus status, int &startIndex);
00268 
00281     GMEvent* GetGMEventByPlayer(PID playerID, GMEventStatus status, int &startIndex);
00282 
00290     size_t GetPlayerFromEvent(PID &PlayerID, GMEvent* Event);
00291 
00301     bool CheckEvalStatus(PID PlayerID, GMEvent* Event);
00302 
00311     void SetEvalStatus(PID PlayerID, GMEvent* Event, bool NewStatus);
00312 
00316     int GetNextEventID(void);
00317 
00324     void DiscardGMEvent(Client* client, int eventID);
00325 
00334     bool RemovePlayerRefFromGMEvent(GMEvent* gmEvent, Client* client, PID playerID);
00335 
00343     bool EraseGMEvent(Client* client, GMEvent* gmEvent);
00344 
00353     void WriteGMEventEvaluation(Client* client, GMEvent* Event, csString XmlStr);
00354 };
00355 
00358 #endif
00359