Peoplemon  0.1.0
Peoplemon 3 game source documentation
BattleState.hpp
Go to the documentation of this file.
1 #ifndef GAME_BATTLES_BATTLESTATE_HPP
2 #define GAME_BATTLES_BATTLESTATE_HPP
3 
5 
6 namespace core
7 {
8 namespace battle
9 {
18 class BattleState {
19 public:
24  enum struct Stage : std::uint8_t {
25  // Battle intro
26  WildIntro = 0,
31 
32  // Turn and round flow
34  RoundStart,
35  TurnStart,
39  RoundEnd,
40 
41  // Use item
42  PreUseItem,
43  UsingItem,
51 
52  // Switch out
54  Switching,
56 
57  // Run
58  BeforeRun,
59  Running,
60  RunFailed,
61 
62  // Fight
63  Attacking,
66 
67  // Various switch states
74 
75  // Peoplemon defeated
76  Fainting,
79  CheckFaint,
83 
84  // XP and level up
87  XpAwarding,
88  LevelingUp,
91 
92  // Battle end
97  Whiteout,
98 
99  // Post peoplemon caught
102 
103  // Final states
104  Completed,
106  };
107 
114  BattleState(Stage initialState);
115 
121  void beginRound(bool playerIsFirst);
122 
128  Stage nextTurn();
129 
134  bool isFirstMover() const;
135 
140  Battler& localPlayer();
141 
146  Battler& enemy();
147 
153 
159 
164  Battler& hostBattler();
165 
171 
176  Stage currentStage() const;
177 
183  void setStage(Stage stage);
184 
185 private:
186  Stage stage;
187  Battler player;
188  Battler opponent; // TODO - some way to swap for network client?
189  std::uint8_t currentMover;
190  std::uint8_t firstMover;
191 };
192 
193 } // namespace battle
194 } // namespace core
195 
196 #endif
Core classes and functionality for both the editor and game.
Base class for battlers in the game. This provides storage for peoplemon and turn choices.
Definition: Battler.hpp:23
Stores and represents the current state of a battle. This is the base class for local and remote batt...
Definition: BattleState.hpp:18
Battler & inactiveBattler()
Returns the battler who is currently not resolving their turn.
Definition: BattleState.cpp:34
Stage currentStage() const
Returns the current stage the battle is in.
Definition: BattleState.cpp:42
Battler & hostBattler()
Returns the battler that is the host.
Definition: BattleState.cpp:38
Battler & enemy()
Returns the opponent Battler.
Definition: BattleState.cpp:28
void setStage(Stage stage)
Sets the current stage of the battle.
Definition: BattleState.cpp:44
void beginRound(bool playerIsFirst)
Begins the next round of turns and sets the battler order.
Definition: BattleState.cpp:14
bool isFirstMover() const
Returns whether the current mover is the first peoplemon to go this round.
Definition: BattleState.cpp:46
Battler & activeBattler()
Returns the battler that is current resolving their turn.
Definition: BattleState.cpp:30
BattleState(Stage initialState)
Creates a new BattleState.
Definition: BattleState.cpp:7
Battler & localPlayer()
Returns the local player Battler.
Definition: BattleState.cpp:26
Stage nextTurn()
Moves on to the next battler's turn. Returns the stage to transition to.
Definition: BattleState.cpp:21
Stage
Represents all possible states in a battle.
Definition: BattleState.hpp:24
Battler & nonHostBattler()
Returns the battler who is not the host.
Definition: BattleState.cpp:40