Mania++
 All Classes Functions Variables Pages
EventManager.h
1 #ifndef EVENTMANAGER_H_
2 #define EVENTMANAGER_H_
3 
4 #include <vector>
5 #include <functional>
6 
7 #include "Structs.h"
8 #include "../Objects/Map.h"
9 #include "../Objects/Player.h"
10 
11 //* EventManager
16 {
17 public:
21  EventManager();
22 
30  int RegisterEverySecond(std::vector<std::function<void()>> functions);
31 
39  int RegisterEveryMinute(std::vector<std::function<void()>> functions);
40 
48  int RegisterPlayerConnect(std::vector<std::function<void(Player)>> functions);
49 
57  int RegisterPlayerDisconnect(std::vector<std::function<void(Player)>> functions);
58 
66  int RegisterPlayerChat(std::vector<std::function<void(Player, std::string)>> functions);
67 
75  int RegisterPlayerManialinkPageAnswer(std::vector<std::function<void(Player, std::string, std::vector<EntryVal>)>> functions);
76 
84  int RegisterEcho(std::vector<std::function<void(std::string, std::string)>> functions);
85 
93  int RegisterBeginMatch(std::vector<std::function<void()>> functions);
94 
102  int RegisterEndMatch(std::vector<std::function<void(std::vector<PlayerRanking>, int)>> functions);
103 
111  int RegisterBeginMap(std::vector<std::function<void(Map)>> functions);
112 
120  int RegisterEndMap(std::vector<std::function<void(Map)>> functions);
121 
129  int RegisterStatusChanged(std::vector<std::function<void(int, std::string)>> functions);
130 
138  int RegisterPlayerCheckpoint(std::vector<std::function<void(Player, int, int, int)>> functions);
139 
147  int RegisterPlayerFinish(std::vector<std::function<void(Player, int)>> functions);
148 
156  int RegisterPlayerIncoherence(std::vector<std::function<void(Player)>> functions);
157 
165  int RegisterBillUpdated(std::vector<std::function<void(int, int, std::string, int)>> functions);
166 
174  int RegisterMapListModified(std::vector<std::function<void(int, int, bool)>> functions);
175 
183  int RegisterPlayerInfoChanged(std::vector<std::function<void(Player)>> functions);
184 
192  int RegisterVoteUpdated(std::vector<std::function<void(std::string, std::string, std::string, std::string)>> functions);
193 
197  void CallEverySecond();
198 
202  void CallEveryMinute();
203 
209  void CallPlayerConnect(Player player);
210 
216  void CallPlayerDisconnect(Player player);
217 
225  void CallPlayerChat(Player player, std::string text, bool isRegisteredCommand);
226 
234  void CallPlayerManialinkPageAnswer(Player player, std::string answer, std::vector<EntryVal> entries);
235 
242  void CallEcho(std::string internal, std::string publicEcho);
243 
247  void CallBeginMatch();
248 
255  void CallEndMatch(std::vector<PlayerRanking> rankings, int winnerTeam);
256 
262  void CallBeginMap(Map map);
263 
269  void CallEndMap(Map map);
270 
277  void CallStatusChanged(int statusCode, std::string statusName);
278 
287  void CallPlayerCheckpoint(Player player, int time, int currentLap, int checkpointIndex);
288 
295  void CallPlayerFinish(Player player, int time);
296 
302  void CallPlayerIncoherence(Player player);
303 
312  void CallBillUpdated(int billId, int state, std::string stateName, int transactionId);
313 
321  void CallMapListModified(int currentMap, int nextMap, bool listModified);
322 
328  void CallPlayerInfoChanged(Player player);
329 
338  void CallVoteUpdated(std::string stateName, std::string login, std::string commandName, std::string commandParam);
339 
340 private:
341  std::vector<std::function<void()>> methodsEverySecond;
342  std::vector<std::function<void()>> methodsEveryMinute;
344  std::vector<std::function<void(Player)>> methodsPlayerConnect;
345  std::vector<std::function<void(Player)>> methodsPlayerDisconnect;
346  std::vector<std::function<void(Player, std::string)>> methodsPlayerChat;
347  std::vector<std::function<void(Player, std::string, std::vector<EntryVal>)>> methodsPlayerManialinkPageAnswer;
348  std::vector<std::function<void(std::string, std::string)>> methodsEcho;
349  std::vector<std::function<void()>> methodsBeginMatch;
350  std::vector<std::function<void(std::vector<PlayerRanking>, int)>> methodsEndMatch;
351  std::vector<std::function<void(Map)>> methodsBeginMap;
352  std::vector<std::function<void(Map)>> methodsEndMap;
353  std::vector<std::function<void(int, std::string)>> methodsStatusChanged;
354  std::vector<std::function<void(Player, int, int, int)>> methodsPlayerCheckpoint;
355  std::vector<std::function<void(Player, int)>> methodsPlayerFinish;
356  std::vector<std::function<void(Player)>> methodsPlayerIncoherence;
357  std::vector<std::function<void(int, int, std::string, int)>> methodsBillUpdated;
358  std::vector<std::function<void(int, int, bool)>> methodsMapListModified;
359  std::vector<std::function<void(Player)>> methodsPlayerInfoChanged;
360  std::vector<std::function<void(std::string, std::string, std::string, std::string)>> methodsVoteUpdated;
361 };
362 
363 #endif // EVENTMANAGER_H_
std::vector< std::function< void(Player)> > methodsPlayerConnect
Vector with functions for the PlayerConnect event.
Definition: EventManager.h:344
void CallMapListModified(int currentMap, int nextMap, bool listModified)
Calls all functions which are subscribed to the MapListModified event.
Definition: EventManager.cpp:380
void CallBeginMap(Map map)
Calls all functions which are subscribed to the EndMatch event.
Definition: EventManager.cpp:317
int RegisterBeginMatch(std::vector< std::function< void()>> functions)
Register functions for the BeginMatch callback.
Definition: EventManager.cpp:104
int RegisterMapListModified(std::vector< std::function< void(int, int, bool)>> functions)
Register functions for the MapListModified callback.
Definition: EventManager.cpp:203
int RegisterEndMap(std::vector< std::function< void(Map)>> functions)
Register functions for the EndMap callback.
Definition: EventManager.cpp:137
std::vector< std::function< void(Player, std::string)> > methodsPlayerChat
Vector with functions for the PlayerChat event.
Definition: EventManager.h:346
void CallPlayerManialinkPageAnswer(Player player, std::string answer, std::vector< EntryVal > entries)
Calls all functions which are subscribed to the PlayerManialinkPageAnswer event.
Definition: EventManager.cpp:281
void CallStatusChanged(int statusCode, std::string statusName)
Calls all functions which are subscribed to the StatusChanged event.
Definition: EventManager.cpp:335
EventManager()
Definition: EventManager.cpp:3
int RegisterPlayerIncoherence(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerIncoherence callback.
Definition: EventManager.cpp:181
Contains all information about a player in easy-to-use format.
Definition: Player.h:11
std::vector< std::function< void()> > methodsBeginMatch
Vector with functions for the BeginMatch event.
Definition: EventManager.h:349
void CallPlayerFinish(Player player, int time)
Calls all functions which are subscribed to the PlayerFinish event.
Definition: EventManager.cpp:353
int RegisterEcho(std::vector< std::function< void(std::string, std::string)>> functions)
Register functions for the Echo callback.
Definition: EventManager.cpp:93
int RegisterPlayerConnect(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerConnect callback.
Definition: EventManager.cpp:49
int RegisterStatusChanged(std::vector< std::function< void(int, std::string)>> functions)
Register functions for the StatusChanged callback.
Definition: EventManager.cpp:148
std::vector< std::function< void(Player)> > methodsPlayerIncoherence
Vector with functions for the PlayerIncoherence event.
Definition: EventManager.h:356
std::vector< std::function< void(int, int, std::string, int)> > methodsBillUpdated
Vector with functions for the BillUpdated event.
Definition: EventManager.h:357
void CallPlayerConnect(Player player)
Calls all functions which are subscribed to the PlayerConnect event.
Definition: EventManager.cpp:254
std::vector< std::function< void(Player, std::string, std::vector< EntryVal >)> > methodsPlayerManialinkPageAnswer
Vector with functions for the PlayerManialinkPageAnswer event.
Definition: EventManager.h:347
void CallPlayerCheckpoint(Player player, int time, int currentLap, int checkpointIndex)
Calls all functions which are subscribed to the PlayerCheckpoint event.
Definition: EventManager.cpp:344
std::vector< std::function< void(Player)> > methodsPlayerDisconnect
Vector with functions for the PlayerDisconnect event.
Definition: EventManager.h:345
std::vector< std::function< void(std::string, std::string)> > methodsEcho
Vector with functions for the Echo event.
Definition: EventManager.h:348
Contains all information about a map in easy-to-use format.
Definition: Map.h:14
void CallBeginMatch()
Calls all functions which are subscribed to the BeginMatch event.
Definition: EventManager.cpp:299
int RegisterPlayerDisconnect(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerDisconnect callback.
Definition: EventManager.cpp:60
int RegisterPlayerManialinkPageAnswer(std::vector< std::function< void(Player, std::string, std::vector< EntryVal >)>> functions)
Register functions for the PlayerManialinkPageAnswer callback.
Definition: EventManager.cpp:82
std::vector< std::function< void(Player, int, int, int)> > methodsPlayerCheckpoint
Vector with functions for the PlayerCheckpoint event.
Definition: EventManager.h:354
void CallVoteUpdated(std::string stateName, std::string login, std::string commandName, std::string commandParam)
Calls all functions which are subscribed to the VoteUpdated event.
Definition: EventManager.cpp:398
void CallPlayerInfoChanged(Player player)
Calls all functions which are subscribed to the PlayerInfoChanged event.
Definition: EventManager.cpp:389
std::vector< std::function< void(Player, int)> > methodsPlayerFinish
Vector with functions for the PlayerFinish event.
Definition: EventManager.h:355
std::vector< std::function< void()> > methodsEveryMinute
Vector with functions for the EveryMinute event.
Definition: EventManager.h:342
std::vector< std::function< void(std::vector< PlayerRanking >, int)> > methodsEndMatch
Vector with functions for the EndMatch event.
Definition: EventManager.h:350
std::vector< std::function< void(int, int, bool)> > methodsMapListModified
Vector with functions for the MapListModified event.
Definition: EventManager.h:358
std::vector< std::function< void(Player)> > methodsPlayerInfoChanged
Vector with functions for the PlayerInfoChanged event.
Definition: EventManager.h:359
int RegisterBeginMap(std::vector< std::function< void(Map)>> functions)
Register functions for the BeginMap callback.
Definition: EventManager.cpp:126
void CallEndMap(Map map)
Calls all functions which are subscribed to the EndMap event.
Definition: EventManager.cpp:326
std::vector< std::function< void(std::string, std::string, std::string, std::string)> > methodsVoteUpdated
Vector with functions for the VoteUpdated event.
Definition: EventManager.h:360
int RegisterPlayerCheckpoint(std::vector< std::function< void(Player, int, int, int)>> functions)
Register functions for the PlayerCheckpoint callback.
Definition: EventManager.cpp:159
void CallEveryMinute()
Calls all functions which are subscribed to the EveryMinute event.
Definition: EventManager.cpp:245
void CallEverySecond()
Calls all functions which are subscribed to the EverySecond event.
Definition: EventManager.cpp:236
int RegisterPlayerInfoChanged(std::vector< std::function< void(Player)>> functions)
Register functions for the PlayerInfoChanged callback.
Definition: EventManager.cpp:214
int RegisterEndMatch(std::vector< std::function< void(std::vector< PlayerRanking >, int)>> functions)
Register functions for the EndMatch callback.
Definition: EventManager.cpp:115
std::vector< std::function< void(Map)> > methodsBeginMap
Vector with functions for the BeginMap event.
Definition: EventManager.h:351
void CallPlayerDisconnect(Player player)
Calls all functions which are subscribed to the PlayerDisconnect event.
Definition: EventManager.cpp:263
int RegisterBillUpdated(std::vector< std::function< void(int, int, std::string, int)>> functions)
Register functions for the BillUpdated callback.
Definition: EventManager.cpp:192
std::vector< std::function< void(int, std::string)> > methodsStatusChanged
Vector with functions for the StatusChanged event.
Definition: EventManager.h:353
int RegisterPlayerChat(std::vector< std::function< void(Player, std::string)>> functions)
Register functions for the PlayerChat callback.
Definition: EventManager.cpp:71
std::vector< std::function< void(Map)> > methodsEndMap
Vector with functions for the EndMap event.
Definition: EventManager.h:352
void CallEcho(std::string internal, std::string publicEcho)
Calls all functions which are subscribed to the Echo event.
Definition: EventManager.cpp:290
void CallBillUpdated(int billId, int state, std::string stateName, int transactionId)
Calls all functions which are subscribed to the BillUpdated event.
Definition: EventManager.cpp:371
int RegisterEverySecond(std::vector< std::function< void()>> functions)
Register functions for the EverySecond callback (from controller).
Definition: EventManager.cpp:27
std::vector< std::function< void()> > methodsEverySecond
Vector with functions for the EverySecond event.
Definition: EventManager.h:341
void CallPlayerChat(Player player, std::string text, bool isRegisteredCommand)
Calls all functions which are subscribed to the PlayerChat event.
Definition: EventManager.cpp:272
int RegisterVoteUpdated(std::vector< std::function< void(std::string, std::string, std::string, std::string)>> functions)
Register functions for the VoteUpdated callback.
Definition: EventManager.cpp:225
void CallPlayerIncoherence(Player player)
Calls all functions which are subscribed to the PlayerIncoherence event.
Definition: EventManager.cpp:362
void CallEndMatch(std::vector< PlayerRanking > rankings, int winnerTeam)
Calls all functions which are subscribed to the EndMatch event.
Definition: EventManager.cpp:308
Handles events (callbacks) from server to plugins.
Definition: EventManager.h:15
int RegisterEveryMinute(std::vector< std::function< void()>> functions)
Register functions for the EveryMinute callback (from controller).
Definition: EventManager.cpp:38
int RegisterPlayerFinish(std::vector< std::function< void(Player, int)>> functions)
Register functions for the PlayerFinish callback.
Definition: EventManager.cpp:170