1 #ifndef BLANK_SHARED_CLICONTEXT_HPP_
2 #define BLANK_SHARED_CLICONTEXT_HPP_
15 /// Create context with optional player and entity
16 /// entity defaults to the player's if given
17 /// Associated player or entity can be changed during
18 /// the context's lifetime and will assume the original
19 /// values when reset.
20 explicit CLIContext(Player *p = nullptr, Entity *e = nullptr);
22 /// check if this context associates a player
23 bool HasPlayer() { return effective_player; }
24 /// get the player responsible for all this
25 /// only valid if HasPlayer() returns true
26 Player &GetPlayer() { return *effective_player; }
27 /// change the effective player of this context
28 /// note that this will *not* change the effective entity
29 void SetPlayer(Player &p) { effective_player = &p; }
31 /// check if this context associates an entity
32 bool HasEntity() { return effective_entity; }
33 /// get the entity on which operations should be performed
34 /// only valid if HasPlayer() returns true
35 Entity &GetEntity() { return *effective_entity; }
36 /// change the effective player of this context
37 void SetEntity(Entity &e) { effective_entity = &e; }
39 /// reset effective player and entity to their original values
41 effective_player = original_player;
42 effective_player = original_player;
45 /// an error has happened and the player should be notified
46 virtual void Error(const std::string &) = 0;
49 /// use this for output concerning the originator of a command
50 virtual void Message(const std::string &) = 0;
52 /// send a status message to all players
53 /// use this to announce stuff which may be interesting to anyone
54 virtual void Broadcast(const std::string &) = 0;
57 Player *original_player;
58 Player *effective_player;
59 Entity *original_entity;
60 Entity *effective_entity;