Peoplemon  0.1.0
Peoplemon 3 game source documentation
BattlerController.hpp
Go to the documentation of this file.
1 #ifndef GAME_BATTLES_BATTLERCONTROLLERS_BATTLERCONTROLLER_HPP
2 #define GAME_BATTLES_BATTLERCONTROLLERS_BATTLERCONTROLLER_HPP
3 
5 #include <Core/Items/Id.hpp>
7 
8 namespace core
9 {
10 namespace battle
11 {
12 class Battler;
13 
21 public:
26  virtual ~BattlerController() = default;
27 
33  void setOwner(Battler& owner);
34 
39  virtual const std::string& name() const = 0;
40 
45  virtual void refresh() = 0;
46 
51  bool actionSelected() const;
52 
57  void pickAction();
58 
66  void pickPeoplemon(bool fromFaint, bool reviveOnly);
67 
72  TurnAction chosenAction() const;
73 
78  int chosenMove() const;
79 
84  core::item::Id chosenItem() const;
85 
90  std::uint8_t chosenPeoplemon() const;
91 
96  bool shouldContinue() const;
97 
102  void chooseToContinue();
103 
110  virtual bool removeItem(item::Id item) = 0;
111 
116  virtual bool isHost() const = 0;
117 
118 protected:
120 
127 
132  virtual void startChooseAction() = 0;
133 
142  virtual void startChoosePeoplemon(bool fromFaint, bool reviveOnly) = 0;
143 
148  virtual void startChooseToContinue() = 0;
149 
155  void chooseMove(int move);
156 
162  void choosePeoplemon(std::uint8_t i);
163 
170  void chooseItem(std::uint8_t pplIndex, core::item::Id item);
171 
176  void chooseRun();
177 
183  void chooseGiveUp(bool yes);
184 
185 private:
186  TurnAction action;
187  union {
189  int move;
191  };
192  std::uint8_t switchIndex;
193  bool subActionPicked;
194 };
195 
196 } // namespace battle
197 } // namespace core
198 
199 #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
Base class for battlers in the game. This provides storage for peoplemon and turn choices.
virtual bool isHost() const =0
Return whether or not the controlled battler is the host.
bool shouldContinue() const
Returns whether or not the player has chosen to continue.
int chosenMove() const
Returns the move the battler is using this turn.
virtual const std::string & name() const =0
Returns the name of the battler.
void setOwner(Battler &owner)
Sets the owner of this controller.
TurnAction chosenAction() const
Returns the action the battler is using this turn.
void pickAction()
Initiates the process of selecting what to do on this turn.
virtual ~BattlerController()=default
Destroy the Battler Controller object.
void chooseGiveUp(bool yes)
Choose whether to give up or not.
bool actionSelected() const
Returns whether or not the battler has chosen what to do on this turn.
void chooseMove(int move)
Selects the move to use this turn when fighting.
virtual void refresh()=0
Method that allows controllers to poll status from non-callback based sources.
virtual void startChooseToContinue()=0
Prompts the player to continue or not.
void choosePeoplemon(std::uint8_t i)
Selects the peoplemon to switch to.
virtual bool removeItem(item::Id item)=0
Removes the item from the battler's inventory.
std::uint8_t chosenPeoplemon() const
Returns the peoplemon the battler is switching to this turn.
void chooseItem(std::uint8_t pplIndex, core::item::Id item)
Selects the item to use.
void chooseRun()
Chooses to run away.
void chooseToContinue()
Prompts the player to continue or not.
core::item::Id chosenItem() const
Returns the item the battler is using this turn.
BattlerController()
Initializes the battler with the peoplemon available to it.
void pickPeoplemon(bool fromFaint, bool reviveOnly)
Initiates the process of selecting a replacement peoplemon if the current one faints.
virtual void startChoosePeoplemon(bool fromFaint, bool reviveOnly)=0
Base classes may override this to perform specific logic when a peoplemon must be picked.
virtual void startChooseAction()=0
Base classes may override this to perform specific logic to occur when a turn is made.