Peoplemon  0.1.0
Peoplemon 3 game source documentation
Message.cpp
Go to the documentation of this file.
2 
3 namespace core
4 {
5 namespace battle
6 {
7 namespace cmd
8 {
9 using MovePair = std::pair<pplmn::MoveId, pplmn::MoveId>;
10 
12 : type(tp)
13 , data(Empty())
14 , forHost(true) {}
15 
17 : type(Type::Attack)
18 , data(mid)
19 , forHost(fh) {}
20 
22 : type(tp)
23 , data(Empty())
24 , forHost(b) {}
25 
27 : type(tp)
28 , data(ail)
29 , forHost(a) {}
30 
32 : type(tp)
33 , data(ail)
34 , forHost(a) {}
35 
37 : type(tp)
38 , data(stat)
39 , forHost(a) {}
40 
42 : type(tp)
43 , data(std::make_pair(og, nm))
44 , forHost(true) {}
45 
46 Message::Message(Type tp, std::int16_t ival, bool a)
47 : type(tp)
48 , data(ival)
49 , forHost(a) {}
50 
51 Message::Message(Type tp, std::uint8_t i, unsigned int iv, bool fh)
52 : type(tp)
53 , data(static_cast<std::uint16_t>(iv))
54 , forHost(fh)
55 , pplIndex(i) {}
56 
57 Message::Message(Type tp, std::uint8_t i, pplmn::MoveId m, bool fh)
58 : type(tp)
59 , data(m)
60 , forHost(fh)
61 , pplIndex(i) {}
62 
64 : type(tp)
65 , data(m)
66 , forHost(fh) {}
67 
68 Message::Message(Type tp, item::Id item, bool a)
69 : type(tp)
70 , data(item)
71 , forHost(a) {}
72 
73 Message::Message(Type tp, std::uint8_t i, item::Id item, bool fh)
74 : type(tp)
75 , data(item)
76 , forHost(fh)
77 , pplIndex(i) {}
78 
79 Message::Type Message::getType() const { return type; }
80 
82  const pplmn::MoveId* mid = std::get_if<pplmn::MoveId>(&data);
83  return mid ? *mid : pplmn::MoveId::Unknown;
84 }
85 
86 bool Message::forHostBattler() const { return forHost; }
87 
88 std::uint8_t Message::forIndex() const { return pplIndex; }
89 
91  const pplmn::Ailment* a = std::get_if<pplmn::Ailment>(&data);
92  return a ? *a : pplmn::Ailment::None;
93 }
94 
96  const pplmn::PassiveAilment* a = std::get_if<pplmn::PassiveAilment>(&data);
97  return a ? *a : pplmn::PassiveAilment::None;
98 }
99 
101  const pplmn::Stat* s = std::get_if<pplmn::Stat>(&data);
102  return s ? *s : pplmn::Stat::Attack;
103 }
104 
106  const MovePair* mp = std::get_if<MovePair>(&data);
107  return mp ? mp->first : pplmn::MoveId::Unknown;
108 }
109 
111  const MovePair* mp = std::get_if<MovePair>(&data);
112  return mp ? mp->second : pplmn::MoveId::Unknown;
113 }
114 
115 std::int16_t Message::getInt() const {
116  const std::int16_t* i = std::get_if<std::int16_t>(&data);
117  return i ? *i : 1;
118 }
119 
120 std::uint16_t Message::getUnsigned() const {
121  const std::uint16_t* i = std::get_if<std::uint16_t>(&data);
122  return i ? *i : 0;
123 }
124 
126  const item::Id* i = std::get_if<item::Id>(&data);
127  return i ? *i : item::Id::None;
128 }
129 
130 } // namespace cmd
131 } // namespace battle
132 } // namespace core
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
PassiveAilment
Represents a passive ailment a Peoplemon can have.
Stat
Represents a single stat. Used as an offset to access Stats as an array.
Definition: Stat.hpp:16
Ailment
Represents an ailment that a Peoplemon can have.
Definition: Ailment.hpp:16
MoveId
The id of a move.
Definition: MoveId.hpp:16
Core classes and functionality for both the editor and game.
std::pair< pplmn::MoveId, pplmn::MoveId > MovePair
Definition: Message.cpp:9
pplmn::MoveId getMoveId() const
Returns the move id of the message.
Definition: Message.cpp:81
Type
The type of message to display.
Definition: Message.hpp:32
Message(Type type)
Construct a new Message.
Definition: Message.cpp:11
std::uint16_t getUnsigned() const
Returns the unsigned int value stored in this message.
Definition: Message.cpp:120
item::Id getItem() const
Returns the item for this message.
Definition: Message.cpp:125
pplmn::MoveId getOriginalMove() const
Returns the original move for the message.
Definition: Message.cpp:105
std::int16_t getInt() const
Returns the integer bundled with this message.
Definition: Message.cpp:115
pplmn::Ailment getAilment() const
Returns the ailment for this message.
Definition: Message.cpp:90
pplmn::PassiveAilment getPassiveAilment() const
Returns the passive ailment for this message.
Definition: Message.cpp:95
pplmn::Stat getStat() const
Returns the stat for this message.
Definition: Message.cpp:100
std::uint8_t forIndex() const
Returns the peoplemon index the message is for.
Definition: Message.cpp:88
bool forHostBattler() const
Returns whether or not this message is for the active battler or not.
Definition: Message.cpp:86
Type getType() const
Returns the type of message this is.
Definition: Message.cpp:79
pplmn::MoveId getNewMove() const
Returns the new move for the message.
Definition: Message.cpp:110