3 #include <BLIB/Util/Random.hpp>
12 : currentPeoplemon(0) {}
15 std::unique_ptr<BattlerController>&& c) {
18 controller->setOwner(*
this);
28 return controller->actionSelected();
34 controller->pickAction();
43 return controller->chosenAction();
49 if (substate.
gotBaked) {
return -1; }
50 return controller->chosenMove();
79 BL_LOG_ERROR <<
"Unknown turn action: " <<
chosenAction();
85 for (
const auto& ppl : team) {
86 if (ppl.base().currentHp() > 0)
return true;
92 for (
const auto& ppl : team) {
93 if (ppl.base().currentHp() > 0 && &ppl != &team[currentPeoplemon])
return true;
105 if (!
canSwitch())
return currentPeoplemon;
109 r = bl::util::Random::get<unsigned int>(0, team.size());
110 }
while (team[r].
base().currentHp() == 0 || r == currentPeoplemon);
120 return base * team.back().base().currentLevel();
125 for (
const auto& ppl : team) {
126 if (ppl.hasSeenBattle()) ++c;
127 if (ppl.base().hasExpShare()) ++c;
133 for (
auto& ppl : team) { ppl.resetSawBattle(); }
138 for (
const auto& ppl : team) {
139 if (ppl.hasSeenBattle() && ppl.base().currentLevel() < 100)
return i;
146 const unsigned int bi = ci;
147 if (bi >= team.size() - 1)
return -1;
148 for (
unsigned int i = bi + 1; i < team.size(); ++i) {
149 if (team[i].hasSeenBattle() && team[i].
base().currentLevel() < 100)
return i;
156 for (
unsigned int i = 0; i < team.size(); ++i) {
Id
Represents an item in its simplist form.
Core classes and functionality for both the editor and game.
TurnAction
Represents an action that a battler may take on their turn.
void notifyTurnEnd()
Notifies the battler that a turn has ended.
void startChooseToContinue()
Begins to decide whether or not to continue.
void init(std::vector< core::pplmn::BattlePeoplemon > &&team, std::unique_ptr< BattlerController > &&controller)
Initializes the battler with a team and a controller.
void pickPeoplemon(bool fromFaint, bool reviveOnly)
Initiates the process of selecting a replacement peoplemon if the current one faints.
unsigned int outNowIndex() const
Returns the index of the peoplemon that is out now.
void refresh()
Calls refresh on the controller. Should be called every update.
bool actionSelected() const
Returns whether or not the battler has chosen what to do on this turn.
bool removeItem(item::Id item)
Removes the given item from the battler's inventory.
Battler()
Creates an uninitialized battler.
int getNextXpEarnerIndex(int ci)
Returns the index of the next peoplemon that should earn XP.
bool shouldContinue() const
Returns whether or not the player has chosen to continue.
BattlerSubstate & getSubstate()
Returns the state of this battler.
bool canFight() const
Returns true if the battler has at least one non-fainted peoplemon.
core::pplmn::BattlePeoplemon & activePeoplemon()
Returns the peoplemon that is currently out.
bool isHost() const
Returns whether or not this battler is the host.
TurnAction chosenAction() const
Returns the action the battler is using this turn.
int xpEarnerCount() const
Returns how many of the current peoplemon should earn exp.
std::uint8_t chosenPeoplemon() const
Returns the peoplemon the battler is switching to this turn.
bool canSwitch() const
Returns whether or not the battler has another peoplemon besides the active one.
unsigned int selectRandomPeoplemon() const
Returns the index of a random, living Peoplemon that is not currently out.
int prizeMoney() const
Returns the amount of prize money awarded for defeating this battler.
int chosenMove() const
Returns the move the battler is using this turn.
core::item::Id chosenItem() const
Returns the item the battler is using this turn.
int getFirstXpEarner() const
Returns the index of the first peoplemon that should earn XP.
void pickAction()
Initiates the process of selecting what to do on this turn.
unsigned int getPriority() const
Returns the priority of the battler's action. Fight returns the move priority and other choices retur...
const std::string & name() const
Returns the name of the battler.
void resetXpEarners()
Resets who earns XP.
std::vector< core::pplmn::BattlePeoplemon > & peoplemon()
Returns all the peoplemon held by this battler.
int getBroCount() const
Returns the number of total bros in the party, excluding the active peoplemon.
void notifyTurnBegin()
Notifies the battler that a turn has began.
void setActivePeoplemon(unsigned int index)
Sets the Peoplemon that is out now.
Struct containing state specific to each battler. These states facilitate logic that takes place over...
void notifyTurnBegin()
Resets and updates part of the state that depend on turns elapsing.
void notifyTurnEnd(TurnAction action, pplmn::BattlePeoplemon &outNow)
Resets and updates part of the state that depend on turns elapsing.
void notifySwitch()
Updates state that is unique to the currently out Peoplemon.
component::Trainer * trainer
std::uint8_t encoreTurnsLeft
std::uint8_t basePayout() const
Returns the base payout of the trainer.
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....
static int priority(MoveId move)
Returns the priority of the given move.