Peoplemon  0.1.0
Peoplemon 3 game source documentation
BattlerSubstate.cpp
Go to the documentation of this file.
2 
3 #include <BLIB/Util/Random.hpp>
4 
5 namespace core
6 {
7 namespace battle
8 {
10 : lastMoveIndex(-1)
11 , lastMoveUsed(pplmn::MoveId::Unknown)
12 , isProtected(false)
13 , substituteHp(0)
14 , turnsGuarded(0)
15 , chargingMove(-1)
16 , encoreMove(-1)
17 , encoreTurnsLeft(0)
18 , deathCounter(-1)
19 , ballBlocked(false)
20 , ballBumped(false)
21 , ballSet(false)
22 , ballSpiked(false)
23 , ballSwiped(false)
24 , noOneToGetBall(false)
25 , ballUpTurns(-1)
26 , enduringThisTurn(false)
27 , enduredLastTurn(false)
28 , spikesOut(0)
29 , healNext(-1)
30 , move64Hit(false)
31 , copyStatsFrom(-1)
32 , ailments(pplmn::PassiveAilment::None)
33 , turnsConfused(-1)
34 , koReviveHp(-1)
35 , lastMoveHitWith(pplmn::MoveId::Unknown)
36 , lastDamageTaken(0)
37 , faintHandled(false)
38 , trainer(nullptr)
39 , turnsSticky(0)
40 , lastMoveSuperEffective(pplmn::MoveId::Unknown)
41 , preserveLastSuper(true)
42 , totalMomIndex(-1)
43 , gotBaked(false) {}
44 
46  isProtected = false;
47  noOneToGetBall = false;
48  move64Hit = false;
50  lastDamageTaken = 0;
51  faintHandled = false;
52 }
53 
56  if (turnsGuarded > 0) { turnsGuarded -= 1; }
57  if (encoreTurnsLeft > 0) {
58  encoreTurnsLeft -= 1;
59  if (encoreTurnsLeft == 0) { encoreMove = -1; }
60  }
61  if (deathCounter > 0) { deathCounter -= 1; }
62  if (ballUpTurns >= 0) { ballUpTurns += 1; }
64  enduringThisTurn = false;
65  if (healNext >= 0) { healNext += 1; }
66 
68  else {
69  turnsConfused = -1;
70  }
71  if (outNow.turnsUntilAwake() > 0) { outNow.turnsUntilAwake() -= 1; }
73  if (outNow.hasAilment(pplmn::Ailment::Sticky)) { turnsSticky += 1; }
74  else {
75  turnsSticky = 0;
76  }
77  if (preserveLastSuper) { preserveLastSuper = false; }
78  else {
80  }
81  gotBaked = false;
82 }
83 
85  lastMoveIndex = -1;
86  substituteHp = 0;
87  chargingMove = -1;
89  encoreTurnsLeft = 0;
90  encoreMove = -1;
91  deathCounter = -1;
92  enduringThisTurn = false;
93  enduredLastTurn = false;
95  lastDamageTaken = 0;
96  turnsConfused = -1;
98  copyStatsFrom = -1;
99  koReviveHp = -1;
100  turnsSticky = 0;
102  preserveLastSuper = false;
103  totalMomIndex = -1;
104  gotBaked = false;
105 }
106 
108  using T = std::underlying_type_t<pplmn::PassiveAilment>;
109  ailments = static_cast<pplmn::PassiveAilment>(static_cast<T>(ail) | static_cast<T>(ailments));
110 }
111 
113  using T = std::underlying_type_t<pplmn::PassiveAilment>;
114  return (static_cast<T>(ailments) & static_cast<T>(ail)) != 0;
115 }
116 
118  using T = std::underlying_type_t<pplmn::PassiveAilment>;
119  const T neg = ~static_cast<T>(ail);
120  ailments = static_cast<pplmn::PassiveAilment>(static_cast<T>(ailments) & neg);
121  if (ail == pplmn::PassiveAilment::Confused) {
122  turnsConfused = bl::util::Random::get<int>(2, 4);
123  }
124 }
125 
126 } // namespace battle
127 } // namespace core
PassiveAilment
Represents a passive ailment a Peoplemon can have.
MoveId
The id of a move.
Definition: MoveId.hpp:16
Core classes and functionality for both the editor and game.
TurnAction
Represents an action that a battler may take on their turn.
Definition: TurnAction.hpp:16
bool hasAilment(pplmn::PassiveAilment ail) const
Returns true if the peoplemon has the specific ailment.
void notifyTurnBegin()
Resets and updates part of the state that depend on turns elapsing.
void notifyTurnEnd(TurnAction action, pplmn::BattlePeoplemon &outNow)
Resets and updates part of the state that depend on turns elapsing.
void notifySwitch()
Updates state that is unique to the currently out Peoplemon.
void giveAilment(pplmn::PassiveAilment ail)
Gives the peoplemon a passive ailment.
pplmn::PassiveAilment ailments
BattlerSubstate()
Construct a new Battler State object with proper defaults.
void clearAilment(pplmn::PassiveAilment ail)
Clear the given passive ailment.
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....
std::int8_t & turnsUntilAwake()
The number of turns until the peoplemon wakes up.
bool hasAilment(const battle::BattlerSubstate &state) const
Returns whether or not the peoplemon has an ailment of any kind.