Peoplemon  0.1.0
Peoplemon 3 game source documentation
BattleState.cpp
Go to the documentation of this file.
2 
3 namespace core
4 {
5 namespace battle
6 {
8 : stage(state)
9 , player()
10 , opponent()
11 , currentMover(0)
12 , firstMover(0) {}
13 
14 void BattleState::beginRound(bool pf) {
15  currentMover = pf ? 0 : 1;
16  firstMover = currentMover;
17  player.notifyTurnBegin();
18  opponent.notifyTurnBegin();
19 }
20 
22  currentMover = (currentMover + 1) % 2;
23  return currentMover == firstMover ? Stage::RoundFinalEffectsPlayer : Stage::TurnStart;
24 }
25 
26 Battler& BattleState::localPlayer() { return player; }
27 
28 Battler& BattleState::enemy() { return opponent; }
29 
31  return currentMover == 0 ? hostBattler() : nonHostBattler();
32 }
33 
35  return currentMover == 1 ? hostBattler() : nonHostBattler();
36 }
37 
38 Battler& BattleState::hostBattler() { return player.isHost() ? player : opponent; }
39 
40 Battler& BattleState::nonHostBattler() { return player.isHost() ? opponent : player; }
41 
43 
44 void BattleState::setStage(Stage s) { stage = s; }
45 
46 bool BattleState::isFirstMover() const { return currentMover == firstMover; }
47 
48 } // namespace battle
49 } // namespace core
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
bool isHost() const
Returns whether or not this battler is the host.
Definition: Battler.cpp:164
void notifyTurnBegin()
Notifies the battler that a turn has began.
Definition: Battler.cpp:21
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