Peoplemon  0.1.0
Peoplemon 3 game source documentation
LocalBattleController.hpp
Go to the documentation of this file.
1 #ifndef CORE_BATTLES_LOCALBATTLECONTROLLER_HPP
2 #define CORE_BATTLES_LOCALBATTLECONTROLLER_HPP
3 
7 
8 namespace core
9 {
10 namespace battle
11 {
19 public:
25 
30  virtual ~LocalBattleController() = default;
31 
32 protected:
39  void updateBattleState(bool viewSynced, bool queueEmpty);
40 
41 private:
42  bool currentStageInitialized;
43  bool finalEffectsApplied;
44  Battler* currentFainter;
45  Battler* midturnSwitcher;
46  unsigned int xpAward;
47  unsigned int xpAwardRemaining;
48  int xpAwardIndex;
49  pplmn::MoveId learnMove;
50  bool firstTurn;
51  int runCount;
52 
53  // for attack phases
54  pplmn::MoveId usedMove;
55  pplmn::MoveEffect effect;
56  int damage;
57  bool switchAfterMove;
58 
59  // peopleballs
60  int turnCounter;
61  int curShake;
62 
63  // peopledex
64  std::unordered_set<pplmn::BattlePeoplemon*> seenPeoplemon;
65 
66  virtual void onCommandQueued(const Command& cmd) override;
67  virtual void onCommandProcessed(const Command& cmd) override;
68  virtual void onUpdate(bool viewSynced, bool queueEmpty) override;
69 
70  void setBattleState(BattleState::Stage nextState);
71  void initCurrentStage();
72  void checkCurrentStage(bool viewSynced, bool queueEmpty);
73  BattleState::Stage getNextStage(BattleState::Stage ns);
74  int getPriority(Battler& battler);
75  int getSpeed(Battler& battler);
76 
77  void startUseMove(Battler& user, int index);
78  void checkAbilitiesAfterMove(Battler& user);
79  void handleMoveEffect(Battler& user);
80  float getEffectivenessMultiplier(pplmn::BattlePeoplemon& attacker,
81  pplmn::BattlePeoplemon& defender, pplmn::MoveId move,
82  pplmn::Type moveType);
83  bool checkMoveCancelled(Battler& user, Battler& victim, int i, pplmn::MoveId move, int pwr,
84  pplmn::Type moveType, pplmn::MoveEffect effect,
85  bool isChargeSecondTurn);
86  void applyDamageWithChecks(Battler& owner, pplmn::BattlePeoplemon& victim, pplmn::MoveId move,
87  int dmg);
88  void applyAilmentFromMove(Battler& owner, pplmn::BattlePeoplemon& victim,
89  pplmn::Ailment ailment);
90  void applyAilmentFromMove(Battler& owner, pplmn::BattlePeoplemon& victim,
91  pplmn::PassiveAilment ailment);
92  void doStatChange(pplmn::BattlePeoplemon& recv, pplmn::Stat stat, int amt,
93  bool playAnim = true);
94  void doRoar(Battler& victim);
95 
96  void handleBattlerTurnStart(Battler& battler);
97  void handleBattlerRoundEnd(Battler& battler);
98 
99  bool canSwitch(Battler& battler);
100  bool tryMidturnSwitch(Battler& battler);
101  void startSwitch(Battler& battler);
102  void doSwitch(Battler& battler, unsigned int newPP);
103  void postSwitch(Battler& battler);
104 
105  bool isFainter(Battler& battler) const;
106  void preFaint(Battler& fainter);
107 
108  void checkKlutz(Battler& battler);
109 
110  static bool teachThisTurn(Battler& battler);
111 };
112 
113 } // namespace battle
114 } // namespace core
115 
116 #endif
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
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
MoveEffect
Represents an effect that a move can have. Copied verbatim from Peoplemon 2, may refactor later when ...
Definition: MoveEffect.hpp:17
Core classes and functionality for both the editor and game.
Interface for battle controllers. Battle controllers manage the flow of state and interaction for bat...
Battle controller for local battles against peoplemon or trainers.
virtual ~LocalBattleController()=default
Destroy the Local Battle Controller.
void updateBattleState(bool viewSynced, bool queueEmpty)
Updates the battle state based on the previous state, view state, and queue state.
LocalBattleController()
Construct a new Local Battle Controller.
Base class for battlers in the game. This provides storage for peoplemon and turn choices.
Definition: Battler.hpp:23
Stage
Represents all possible states in a battle.
Definition: BattleState.hpp:24
Emitted by the BattleFSM. All UI is handled via a queue of commands. Commands are resolved in the ord...
Definition: Command.hpp:22
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....