Argentum Online - Servidor
command_handler.h
1 #ifndef COMMAND_HANDLER_H
2 #define COMMAND_HANDLER_H
3 
4 #include <functional>
5 #include <string>
6 
7 #include "../../include/blocking_th_event_handler.h"
8 #include "../../include/event.h"
9 #include "../../include/types.h"
10 #include "../game/position.h"
11 
12 class CommandHandler;
13 
14 typedef struct command_case {
15  std::string cmd;
16  std::function<bool(const std::vector<std::string>&)> condition;
17  std::string help;
18  void (CommandHandler::*handle)(ClientId client_id, position_t target,
19  SlotId slot);
21 
23  private:
24  static const command_case_t whisper;
25  static const command_case_t message;
26  static const std::vector<command_case_t> commands;
27  size_t space;
28  command_case_t current_command;
29  std::vector<std::string> cmd;
30 
31  void parse_line(const std::string& cmd);
32 
33  protected:
34  void handle(Event& ev) override;
35 
36  public:
38  ~CommandHandler();
39 
40  void cmd_whisper(ClientId client_id, position_t target, SlotId slot);
41 
42  void cmd_message(ClientId client_id, position_t target, SlotId slot);
43 
44  void cmd_help(ClientId client_id, position_t target, SlotId slot);
45 
46  void cmd_disconnect(ClientId client_id, position_t target, SlotId slot);
47 
48  void cmd_pickup(ClientId client_id, position_t target, SlotId slot);
49 
50  void cmd_drop(ClientId client_id, position_t target, SlotId slot);
51 
52  void cmd_resuscitate(ClientId client_id, position_t target, SlotId slot);
53 
54  void cmd_heal(ClientId client_id, position_t target, SlotId slot);
55 
56  void cmd_unequip_all(ClientId client_id, position_t target, SlotId slot);
57 
58  void cmd_list(ClientId client_id, position_t target, SlotId slot);
59 
60  void cmd_buy(ClientId client_id, position_t target, SlotId slot);
61 
62  void cmd_sell(ClientId client_id, position_t target, SlotId slot);
63 
64  void cmd_deposit_item(ClientId client_id, position_t target, SlotId slot);
65 
66  void cmd_withdraw_item(ClientId client_id, position_t target, SlotId slot);
67 
68  void cmd_deposit_gold(ClientId client_id, position_t target, SlotId slot);
69 
70  void cmd_withdraw_gold(ClientId client_id, position_t target, SlotId slot);
71 
72  void cmd_meditate(ClientId client_id, position_t target, SlotId slot);
73 };
74 
75 #endif // COMMAND_HANDLER_H
CommandHandler
Definition: command_handler.h:22
Event
Definition: event.h:55
BlockingThEventHandler
Definition: blocking_th_event_handler.h:22
command_case
Definition: command_handler.h:14
position
Definition: position.h:8