Peoplemon  0.1.0
Peoplemon 3 game source documentation
Command.cpp
Go to the documentation of this file.
2 
3 namespace core
4 {
5 namespace battle
6 {
8 : type(t)
9 , data(Empty()) {}
10 
12 : type(t)
13 , data(b) {}
14 
16 : type(Type::DisplayMessage)
17 , data(std::forward<cmd::Message>(s)) {}
18 
20 : type(Type::PlayAnimation)
21 , data(std::forward<cmd::Animation>(a)) {}
22 
23 Command::Type Command::getType() const { return type; }
24 
26  static const cmd::Message empty(cmd::Message::Type::_ERROR);
27  const cmd::Message* m = std::get_if<cmd::Message>(&data);
28  return m ? *m : empty;
29 }
30 
32  static const cmd::Animation empty(cmd::Animation::Type::_ERROR);
33  const cmd::Animation* a = std::get_if<cmd::Animation>(&data);
34  return a ? *a : empty;
35 }
36 
37 bool Command::forHost() const {
38  const bool* b = std::get_if<bool>(&data);
39  return b ? *b : true;
40 }
41 
42 } // namespace battle
43 } // namespace core
Core classes and functionality for both the editor and game.
Represents a type of animation that can be played in battle.
Definition: Animation.hpp:25
bool forHost() const
Returns whether or not this command is for the active battler.
Definition: Command.cpp:37
const cmd::Message & getMessage() const
Returns the message if this command is a message.
Definition: Command.cpp:25
Type
The type the command is.
Definition: Command.hpp:28
Type getType() const
Returns the type of this command.
Definition: Command.cpp:23
Command(Type type)
Creates a new command of the given type with no data.
Definition: Command.cpp:7
const cmd::Animation & getAnimation() const
Returns the animation if this command is an animation.
Definition: Command.cpp:31
Represents a message to be displayed. The actual message text is generated by the battle controller.
Definition: Message.hpp:26