Peoplemon  0.1.0
Peoplemon 3 game source documentation
Battler.hpp
Go to the documentation of this file.
1 #ifndef GAME_BATTLES_BATTLER_HPP
2 #define GAME_BATTLES_BATTLER_HPP
3 
7 #include <Core/Items/Id.hpp>
9 
10 namespace core
11 {
12 namespace battle
13 {
14 class BattleState;
15 class BattlerController;
16 
23 class Battler {
24 public:
29  Battler();
30 
37  void init(std::vector<core::pplmn::BattlePeoplemon>&& team,
38  std::unique_ptr<BattlerController>&& controller);
39 
44  void refresh();
45 
50  bool actionSelected() const;
51 
56  void pickAction();
57 
65  void pickPeoplemon(bool fromFaint, bool reviveOnly);
66 
71  TurnAction chosenAction() const;
72 
77  int chosenMove() const;
78 
83  core::item::Id chosenItem() const;
84 
89  std::uint8_t chosenPeoplemon() const;
90 
95  std::vector<core::pplmn::BattlePeoplemon>& peoplemon();
96 
102 
108  void setActivePeoplemon(unsigned int index);
109 
114  unsigned int outNowIndex() const;
115 
120  bool canFight() const;
121 
126  bool canSwitch() const;
127 
132  const std::string& name() const;
133 
140  unsigned int getPriority() const;
141 
147 
152  const BattlerSubstate& getSubstate() const;
153 
158  void notifyTurnBegin();
159 
164  void notifyTurnEnd();
165 
170  unsigned int selectRandomPeoplemon() const;
171 
176  bool shouldContinue() const;
177 
182  void startChooseToContinue();
183 
188  int prizeMoney() const;
189 
194  int xpEarnerCount() const;
195 
200  void resetXpEarners();
201 
206  int getFirstXpEarner() const;
207 
214  int getNextXpEarnerIndex(int ci);
215 
220  int getBroCount() const;
221 
228  bool removeItem(item::Id item);
229 
234  bool isHost() const;
235 
236 private:
237  BattlerSubstate substate;
238  std::unique_ptr<BattlerController> controller;
239  std::vector<core::pplmn::BattlePeoplemon> team;
240  std::uint8_t currentPeoplemon;
241 };
242 
243 } // namespace battle
244 } // namespace core
245 
246 #endif
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
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
Base class for battlers in the game. This provides storage for peoplemon and turn choices.
Definition: Battler.hpp:23
void notifyTurnEnd()
Notifies the battler that a turn has ended.
Definition: Battler.cpp:23
void startChooseToContinue()
Begins to decide whether or not to continue.
Definition: Battler.cpp:116
void init(std::vector< core::pplmn::BattlePeoplemon > &&team, std::unique_ptr< BattlerController > &&controller)
Initializes the battler with a team and a controller.
Definition: Battler.cpp:14
void pickPeoplemon(bool fromFaint, bool reviveOnly)
Initiates the process of selecting a replacement peoplemon if the current one faints.
Definition: Battler.cpp:37
unsigned int outNowIndex() const
Returns the index of the peoplemon that is out now.
Definition: Battler.cpp:66
void refresh()
Calls refresh on the controller. Should be called every update.
Definition: Battler.cpp:98
bool actionSelected() const
Returns whether or not the battler has chosen what to do on this turn.
Definition: Battler.cpp:25
bool removeItem(item::Id item)
Removes the given item from the battler's inventory.
Definition: Battler.cpp:162
Battler()
Creates an uninitialized battler.
Definition: Battler.cpp:11
int getNextXpEarnerIndex(int ci)
Returns the index of the next peoplemon that should earn XP.
Definition: Battler.cpp:145
bool shouldContinue() const
Returns whether or not the player has chosen to continue.
Definition: Battler.cpp:114
BattlerSubstate & getSubstate()
Returns the state of this battler.
Definition: Battler.cpp:100
bool canFight() const
Returns true if the battler has at least one non-fainted peoplemon.
Definition: Battler.cpp:84
core::pplmn::BattlePeoplemon & activePeoplemon()
Returns the peoplemon that is currently out.
Definition: Battler.cpp:59
bool isHost() const
Returns whether or not this battler is the host.
Definition: Battler.cpp:164
TurnAction chosenAction() const
Returns the action the battler is using this turn.
Definition: Battler.cpp:39
int xpEarnerCount() const
Returns how many of the current peoplemon should earn exp.
Definition: Battler.cpp:123
std::uint8_t chosenPeoplemon() const
Returns the peoplemon the battler is switching to this turn.
Definition: Battler.cpp:55
bool canSwitch() const
Returns whether or not the battler has another peoplemon besides the active one.
Definition: Battler.cpp:91
unsigned int selectRandomPeoplemon() const
Returns the index of a random, living Peoplemon that is not currently out.
Definition: Battler.cpp:104
int prizeMoney() const
Returns the amount of prize money awarded for defeating this battler.
Definition: Battler.cpp:118
int chosenMove() const
Returns the move the battler is using this turn.
Definition: Battler.cpp:46
core::item::Id chosenItem() const
Returns the item the battler is using this turn.
Definition: Battler.cpp:53
int getFirstXpEarner() const
Returns the index of the first peoplemon that should earn XP.
Definition: Battler.cpp:136
void pickAction()
Initiates the process of selecting what to do on this turn.
Definition: Battler.cpp:31
unsigned int getPriority() const
Returns the priority of the battler's action. Fight returns the move priority and other choices retur...
Definition: Battler.cpp:70
const std::string & name() const
Returns the name of the battler.
Definition: Battler.cpp:68
void resetXpEarners()
Resets who earns XP.
Definition: Battler.cpp:132
std::vector< core::pplmn::BattlePeoplemon > & peoplemon()
Returns all the peoplemon held by this battler.
Definition: Battler.cpp:57
int getBroCount() const
Returns the number of total bros in the party, excluding the active peoplemon.
Definition: Battler.cpp:154
void notifyTurnBegin()
Notifies the battler that a turn has began.
Definition: Battler.cpp:21
void setActivePeoplemon(unsigned int index)
Sets the Peoplemon that is out now.
Definition: Battler.cpp:61
Struct containing state specific to each battler. These states facilitate logic that takes place over...
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....