Peoplemon  0.1.0
Peoplemon 3 game source documentation
OwnedPeoplemon.hpp
Go to the documentation of this file.
1 #ifndef CORE_PEOPLEMON_OWNEDPEOPLEMON_HPP
2 #define CORE_PEOPLEMON_OWNEDPEOPLEMON_HPP
3 
4 #include <BLIB/Serialization.hpp>
5 #include <Core/Items/Id.hpp>
7 #include <Core/Peoplemon/Id.hpp>
10 #include <Core/Peoplemon/Stats.hpp>
11 #include <Core/Peoplemon/Type.hpp>
12 #include <string>
13 
14 namespace editor
15 {
16 namespace component
17 {
18 class OwnedPeoplemonWindow;
19 }
20 } // namespace editor
21 
22 namespace core
23 {
24 namespace pplmn
25 {
26 class OwnedPeoplemon;
27 } // namespace pplmn
28 } // namespace core
29 
30 namespace core
31 {
32 namespace pplmn
33 {
34 struct WildPeoplemon;
35 class BattlePeoplemon;
36 
45 public:
51 
58  OwnedPeoplemon(Id id, unsigned int level);
59 
66  bool loadLegacyFile(const std::string& file);
67 
73  Id id() const;
74 
79  void evolve();
80 
85  const std::string& name() const;
86 
92  void setCustomName(const std::string& name);
93 
98  Type type() const;
99 
104  unsigned int currentLevel() const;
105 
110  unsigned int evolveLevel() const;
111 
116  Id evolvesInto() const;
117 
122  bool& pendingEvolution();
123 
128  bool pendingEvolution() const;
129 
134  unsigned int currentXP() const;
135 
140  unsigned int nextLevelXP() const;
141 
149  unsigned int awardXP(unsigned int xp);
150 
156  MoveId levelUp();
157 
163  Stats currentStats() const;
164 
169  const Stats& currentEVs() const;
170 
175  const Stats& currentIVs() const;
176 
181  std::uint16_t& currentHp();
182 
187  std::uint16_t currentHp() const;
188 
194  void applyDamage(int dmg);
195 
201  void giveHealth(int hp);
202 
208  void awardEVs(const Stats& evs);
209 
215 
220  Ailment currentAilment() const;
221 
226  item::Id& holdItem();
227 
232  item::Id holdItem() const;
233 
239  SpecialAbility ability() const;
240 
245  const OwnedMove* knownMoves() const;
246 
252 
259  bool knowsMove(MoveId move) const;
260 
267  void learnMove(MoveId move, unsigned int i);
268 
275  bool gainMove(MoveId move);
276 
281  void heal();
282 
287  bool hasExpShare() const;
288 
295  unsigned int xpYield(bool isTrainer) const;
296 
304 
313  bool shakePasses(item::Id ball, int turnNumber, unsigned int opLevel);
314 
319  bool canClone() const;
320 
321 private:
322  Id _id;
323  std::string customName;
324  std::uint16_t level;
325  std::uint32_t xp;
326  std::uint16_t hp;
327  Stats ivs;
328  Stats evs;
329  OwnedMove moves[4];
330  Ailment ailment;
331  item::Id item;
332  bool pendingEvolve;
333 
334  friend struct WildPeoplemon;
335  friend class BattlePeoplemon;
336  friend struct bl::serial::SerializableObject<OwnedPeoplemon>;
338 };
339 
340 } // namespace pplmn
341 } // namespace core
342 
343 namespace bl
344 {
345 namespace serial
346 {
347 template<>
348 struct SerializableObject<core::pplmn::OwnedPeoplemon> : public SerializableObjectBase {
355 
356  SerializableField<1, OP, Id> id;
357  SerializableField<2, OP, std::string> customName;
358  SerializableField<3, OP, std::uint16_t> level;
359  SerializableField<4, OP, std::uint32_t> xp;
360  SerializableField<5, OP, std::uint16_t> hp;
361  SerializableField<6, OP, Stats> ivs;
362  SerializableField<7, OP, Stats> evs;
363  SerializableField<8, OP, Move[4]> moves;
364  SerializableField<9, OP, Ail> ailment;
365  SerializableField<10, OP, Item> item;
366 
368  : SerializableObjectBase("OwnedPeoplemon")
369  , id("id", *this, &OP::_id, SerializableFieldBase::Required{})
370  , customName("name", *this, &OP::customName, SerializableFieldBase::Required{})
371  , level("level", *this, &OP::level, SerializableFieldBase::Required{})
372  , xp("xp", *this, &OP::xp, SerializableFieldBase::Required{})
373  , hp("hp", *this, &OP::hp, SerializableFieldBase::Required{})
374  , ivs("ivs", *this, &OP::ivs, SerializableFieldBase::Required{})
375  , evs("evs", *this, &OP::evs, SerializableFieldBase::Required{})
376  , moves("moves", *this, &OP::moves, SerializableFieldBase::Required{})
377  , ailment("ailment", *this, &OP::ailment, SerializableFieldBase::Required{})
378  , item("item", *this, &OP::item, SerializableFieldBase::Required{}) {}
379 };
380 
381 } // namespace serial
382 } // namespace bl
383 
384 #endif
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
Ailment
Represents an ailment that a Peoplemon can have.
Definition: Ailment.hpp:16
Type
Represents a type that a move or Peoplemon can be. Types may be combined.
Definition: Type.hpp:18
MoveId
The id of a move.
Definition: MoveId.hpp:16
SpecialAbility
Represents a special ability that a Peoplemon may have.
Id
The id of a peoplemon.
Definition: Id.hpp:16
Core classes and functionality for both the editor and game.
All classes and functionality used for implementing the game editor.
Definition: Tile.hpp:11
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....
Represents a move owned by a peoplemon.
Definition: OwnedMove.hpp:17
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
const Stats & currentEVs() const
Returns the current EVs of this peoplemon.
void evolve()
Changes this Peoplemon into it's evolved form if it has one.
Type type() const
Returns the type of the peoplemon.
bool loadLegacyFile(const std::string &file)
Loads the peoplemon from a legacy file.
bool & pendingEvolution()
Flag set by battle controller when this people is able to evolve after battle.
OwnedMove * findMove(MoveId id)
Returns the OwnedMove for the given move.
Ailment & currentAilment()
Access the current ailment of this peoplemon.
unsigned int awardXP(unsigned int xp)
Award XP to this peoplemon. A return of 0 indicates that all XP has been awarded. Non zero indicates ...
SpecialAbility ability() const
Returns the special ability of this peoplemon.
void applyDamage(int dmg)
Applies damage to the peoplemon. Ensures that the hp does not go negative.
unsigned int nextLevelXP() const
Returns the xp required to level up.
void setCustomName(const std::string &name)
Sets a custom name for this peoplemon.
bool canClone() const
Returns whether or not this peoplemon can be cloned.
std::uint16_t & currentHp()
Access the current HP.
MoveId levelUp()
Levels up the peoplemon.
OwnedPeoplemon()
Makes an empty peoplemon with id Unknown.
unsigned int currentLevel() const
Returns the current level of this peoplemon.
const Stats & currentIVs() const
Returns the current IVs of this peoplemon.
bool gainMove(MoveId move)
Attempts to learn the given move if there is an open slot.
void awardEVs(const Stats &evs)
Award EVs to this peoplemon.
Stats currentStats() const
Returns the computed stats for the peoplemon. Does not take into account changes during battle.
Id id() const
Returns the id of this peoplemon.
bool hasExpShare() const
Returns whether or not this peoplemon has an EXP share.
bool knowsMove(MoveId move) const
Returns whether or not this peoplemon knows the given move.
bool shakePasses(item::Id ball, int turnNumber, unsigned int opLevel)
Performs the check that a shake would occur with the given peopleball.
void learnMove(MoveId move, unsigned int i)
Teaches the peoplemon the given move, potentially replacing an existing one.
unsigned int currentXP() const
Returns the current XP of this peoplemon.
unsigned int xpYield(bool isTrainer) const
Returns the XP awarded by defeating this peoplemon.
unsigned int evolveLevel() const
Returns the level that this people can evolve at.
void giveHealth(int hp)
Restores HP and ensures it does not go over max HP.
Id evolvesInto() const
Returns the people that this evolves into. Returns Unknown if no evolution.
const OwnedMove * knownMoves() const
Returns the moves known by this Peoplemon.
item::Id & holdItem()
Access the current hold item of this peoplemon.
void heal()
Restores HP and removes ailments.
const std::string & name() const
Returns the name of this peoplemon, custom or defualt.
Stats for Peoplemon. This struct is used for base stats, EVs, IVs, battle increases/decreases,...
Definition: Stats.hpp:19
Template struct to generate OwnedPeoplemon for random encounters.
Window for editing owned Peoplemon.