Peoplemon  0.1.0
Peoplemon 3 game source documentation
Public Member Functions | List of all members
core::battle::Battler Class Reference

Base class for battlers in the game. This provides storage for peoplemon and turn choices. More...

#include <Battler.hpp>

Public Member Functions

 Battler ()
 Creates an uninitialized battler. More...
 
void init (std::vector< core::pplmn::BattlePeoplemon > &&team, std::unique_ptr< BattlerController > &&controller)
 Initializes the battler with a team and a controller. More...
 
void refresh ()
 Calls refresh on the controller. Should be called every update. More...
 
bool actionSelected () const
 Returns whether or not the battler has chosen what to do on this turn. More...
 
void pickAction ()
 Initiates the process of selecting what to do on this turn. More...
 
void pickPeoplemon (bool fromFaint, bool reviveOnly)
 Initiates the process of selecting a replacement peoplemon if the current one faints. More...
 
TurnAction chosenAction () const
 Returns the action the battler is using this turn. More...
 
int chosenMove () const
 Returns the move the battler is using this turn. More...
 
core::item::Id chosenItem () const
 Returns the item the battler is using this turn. More...
 
std::uint8_t chosenPeoplemon () const
 Returns the peoplemon the battler is switching to this turn. More...
 
std::vector< core::pplmn::BattlePeoplemon > & peoplemon ()
 Returns all the peoplemon held by this battler. More...
 
core::pplmn::BattlePeoplemonactivePeoplemon ()
 Returns the peoplemon that is currently out. More...
 
void setActivePeoplemon (unsigned int index)
 Sets the Peoplemon that is out now. More...
 
unsigned int outNowIndex () const
 Returns the index of the peoplemon that is out now. More...
 
bool canFight () const
 Returns true if the battler has at least one non-fainted peoplemon. More...
 
bool canSwitch () const
 Returns whether or not the battler has another peoplemon besides the active one. More...
 
const std::string & name () const
 Returns the name of the battler. More...
 
unsigned int getPriority () const
 Returns the priority of the battler's action. Fight returns the move priority and other choices return 1000. Player goes first in case of tie. More...
 
BattlerSubstategetSubstate ()
 Returns the state of this battler. More...
 
const BattlerSubstategetSubstate () const
 Returns the state of this battler. More...
 
void notifyTurnBegin ()
 Notifies the battler that a turn has began. More...
 
void notifyTurnEnd ()
 Notifies the battler that a turn has ended. More...
 
unsigned int selectRandomPeoplemon () const
 Returns the index of a random, living Peoplemon that is not currently out. More...
 
bool shouldContinue () const
 Returns whether or not the player has chosen to continue. More...
 
void startChooseToContinue ()
 Begins to decide whether or not to continue. More...
 
int prizeMoney () const
 Returns the amount of prize money awarded for defeating this battler. More...
 
int xpEarnerCount () const
 Returns how many of the current peoplemon should earn exp. More...
 
void resetXpEarners ()
 Resets who earns XP. More...
 
int getFirstXpEarner () const
 Returns the index of the first peoplemon that should earn XP. More...
 
int getNextXpEarnerIndex (int ci)
 Returns the index of the next peoplemon that should earn XP. More...
 
int getBroCount () const
 Returns the number of total bros in the party, excluding the active peoplemon. More...
 
bool removeItem (item::Id item)
 Removes the given item from the battler's inventory. More...
 
bool isHost () const
 Returns whether or not this battler is the host. More...
 

Detailed Description

Base class for battlers in the game. This provides storage for peoplemon and turn choices.

Definition at line 23 of file Battler.hpp.

Constructor & Destructor Documentation

◆ Battler()

core::battle::Battler::Battler ( )

Creates an uninitialized battler.

Definition at line 11 of file Battler.cpp.

Member Function Documentation

◆ actionSelected()

bool core::battle::Battler::actionSelected ( ) const

Returns whether or not the battler has chosen what to do on this turn.

Definition at line 25 of file Battler.cpp.

◆ activePeoplemon()

core::pplmn::BattlePeoplemon & core::battle::Battler::activePeoplemon ( )

Returns the peoplemon that is currently out.

Definition at line 59 of file Battler.cpp.

◆ canFight()

bool core::battle::Battler::canFight ( ) const

Returns true if the battler has at least one non-fainted peoplemon.

Definition at line 84 of file Battler.cpp.

◆ canSwitch()

bool core::battle::Battler::canSwitch ( ) const

Returns whether or not the battler has another peoplemon besides the active one.

Definition at line 91 of file Battler.cpp.

◆ chosenAction()

TurnAction core::battle::Battler::chosenAction ( ) const

Returns the action the battler is using this turn.

Definition at line 39 of file Battler.cpp.

◆ chosenItem()

core::item::Id core::battle::Battler::chosenItem ( ) const

Returns the item the battler is using this turn.

Definition at line 53 of file Battler.cpp.

◆ chosenMove()

int core::battle::Battler::chosenMove ( ) const

Returns the move the battler is using this turn.

Definition at line 46 of file Battler.cpp.

◆ chosenPeoplemon()

std::uint8_t core::battle::Battler::chosenPeoplemon ( ) const

Returns the peoplemon the battler is switching to this turn.

Definition at line 55 of file Battler.cpp.

◆ getBroCount()

int core::battle::Battler::getBroCount ( ) const

Returns the number of total bros in the party, excluding the active peoplemon.

Definition at line 154 of file Battler.cpp.

◆ getFirstXpEarner()

int core::battle::Battler::getFirstXpEarner ( ) const

Returns the index of the first peoplemon that should earn XP.

Definition at line 136 of file Battler.cpp.

◆ getNextXpEarnerIndex()

int core::battle::Battler::getNextXpEarnerIndex ( int  ci)

Returns the index of the next peoplemon that should earn XP.

Parameters
ciThe current index XP earner
Returns
int The next index, or -1 when done

Definition at line 145 of file Battler.cpp.

◆ getPriority()

unsigned int core::battle::Battler::getPriority ( ) const

Returns the priority of the battler's action. Fight returns the move priority and other choices return 1000. Player goes first in case of tie.

Returns
unsigned int The priority of the battler's turn

Definition at line 70 of file Battler.cpp.

◆ getSubstate() [1/2]

BattlerSubstate & core::battle::Battler::getSubstate ( )

Returns the state of this battler.

Definition at line 100 of file Battler.cpp.

◆ getSubstate() [2/2]

const BattlerSubstate & core::battle::Battler::getSubstate ( ) const

Returns the state of this battler.

Definition at line 102 of file Battler.cpp.

◆ init()

void core::battle::Battler::init ( std::vector< core::pplmn::BattlePeoplemon > &&  team,
std::unique_ptr< BattlerController > &&  controller 
)

Initializes the battler with a team and a controller.

Parameters
teamThe team of peoplemon to use
controllerThe controller to make decisions

Definition at line 14 of file Battler.cpp.

◆ isHost()

bool core::battle::Battler::isHost ( ) const

Returns whether or not this battler is the host.

Definition at line 164 of file Battler.cpp.

◆ name()

const std::string & core::battle::Battler::name ( ) const

Returns the name of the battler.

Definition at line 68 of file Battler.cpp.

◆ notifyTurnBegin()

void core::battle::Battler::notifyTurnBegin ( )

Notifies the battler that a turn has began.

Definition at line 21 of file Battler.cpp.

◆ notifyTurnEnd()

void core::battle::Battler::notifyTurnEnd ( )

Notifies the battler that a turn has ended.

Definition at line 23 of file Battler.cpp.

◆ outNowIndex()

unsigned int core::battle::Battler::outNowIndex ( ) const

Returns the index of the peoplemon that is out now.

Definition at line 66 of file Battler.cpp.

◆ peoplemon()

std::vector< core::pplmn::BattlePeoplemon > & core::battle::Battler::peoplemon ( )

Returns all the peoplemon held by this battler.

Definition at line 57 of file Battler.cpp.

◆ pickAction()

void core::battle::Battler::pickAction ( )

Initiates the process of selecting what to do on this turn.

Definition at line 31 of file Battler.cpp.

◆ pickPeoplemon()

void core::battle::Battler::pickPeoplemon ( bool  fromFaint,
bool  reviveOnly 
)

Initiates the process of selecting a replacement peoplemon if the current one faints.

Parameters
fromFaintTrue if the current has fainted, false if the switch is for another reason
reviveOnlyTrue if fainted peoplemon must be selected

Definition at line 37 of file Battler.cpp.

◆ prizeMoney()

int core::battle::Battler::prizeMoney ( ) const

Returns the amount of prize money awarded for defeating this battler.

Definition at line 118 of file Battler.cpp.

◆ refresh()

void core::battle::Battler::refresh ( )

Calls refresh on the controller. Should be called every update.

Definition at line 98 of file Battler.cpp.

◆ removeItem()

bool core::battle::Battler::removeItem ( item::Id  item)

Removes the given item from the battler's inventory.

Parameters
itemThe item to remove
Returns
True if the item was removed, false otherwise

Definition at line 162 of file Battler.cpp.

◆ resetXpEarners()

void core::battle::Battler::resetXpEarners ( )

Resets who earns XP.

Definition at line 132 of file Battler.cpp.

◆ selectRandomPeoplemon()

unsigned int core::battle::Battler::selectRandomPeoplemon ( ) const

Returns the index of a random, living Peoplemon that is not currently out.

Definition at line 104 of file Battler.cpp.

◆ setActivePeoplemon()

void core::battle::Battler::setActivePeoplemon ( unsigned int  index)

Sets the Peoplemon that is out now.

Parameters
indexThe index of the peoplemon that is out now

Definition at line 61 of file Battler.cpp.

◆ shouldContinue()

bool core::battle::Battler::shouldContinue ( ) const

Returns whether or not the player has chosen to continue.

Definition at line 114 of file Battler.cpp.

◆ startChooseToContinue()

void core::battle::Battler::startChooseToContinue ( )

Begins to decide whether or not to continue.

Definition at line 116 of file Battler.cpp.

◆ xpEarnerCount()

int core::battle::Battler::xpEarnerCount ( ) const

Returns how many of the current peoplemon should earn exp.

Definition at line 123 of file Battler.cpp.


The documentation for this class was generated from the following files: