Peoplemon  0.1.0
Peoplemon 3 game source documentation
PlayerController.cpp
Go to the documentation of this file.
2 
4 
5 namespace core
6 {
7 namespace battle
8 {
9 const std::string& PlayerController::name() const { return player.state().name; }
10 
12 : state(State::Waiting)
13 , player(p)
14 , menu(menu) {}
15 
17  switch (state) {
18  case State::PickingTurn:
19  if (menu.ready()) {
20  state = State::Waiting;
21  switch (menu.selectedAction()) {
22  case TurnAction::Fight:
23  chooseMove(menu.selectedMove());
24  break;
25  case TurnAction::Item:
27  break;
28  case TurnAction::Switch:
30  break;
31  case TurnAction::Run:
32  chooseRun();
33  break;
34  default:
35  break;
36  }
37  }
38  break;
39 
40  case State::PickingFaintReplacement:
41  if (menu.ready()) {
42  state = State::Waiting;
44  }
45  break;
46 
47  default:
48  break;
49  }
50 }
51 
52 void PlayerController::startChooseAction() {
53  state = State::PickingTurn;
54  menu.beginTurn();
55 }
56 
57 void PlayerController::startChoosePeoplemon(bool fromFaint, bool reviveOnly) {
58  state = State::PickingFaintReplacement;
59  menu.choosePeoplemonMidTurn(fromFaint, reviveOnly);
60 }
61 
62 void PlayerController::startChooseToContinue() {
63  // TODO - get choice from UI
64  chooseGiveUp(false);
65 }
66 
67 bool PlayerController::removeItem(item::Id item) { return player.state().bag.removeItem(item); }
68 
69 bool PlayerController::isHost() const { return true; }
70 
71 } // namespace battle
72 } // namespace core
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
Core classes and functionality for both the editor and game.
void chooseGiveUp(bool yes)
Choose whether to give up or not.
void chooseMove(int move)
Selects the move to use this turn when fighting.
void choosePeoplemon(std::uint8_t i)
Selects the peoplemon to switch to.
void chooseItem(std::uint8_t pplIndex, core::item::Id item)
Selects the item to use.
void chooseRun()
Chooses to run away.
virtual void refresh() override
Checks the menu state.
virtual const std::string & name() const override
Returns the name of the battler.
virtual bool isHost() const override
Returns true.
PlayerController(system::Player &player, view::PlayerMenu &menu)
Construct a new Player Controller.
virtual bool removeItem(item::Id item) override
Removes the item from the battler's inventory.
The player menu for battles.
Definition: PlayerMenu.hpp:29
TurnAction selectedAction() const
The selected turn action.
Definition: PlayerMenu.cpp:190
int selectedPeoplemon() const
Returns the selected peoplemon index.
Definition: PlayerMenu.cpp:196
void choosePeoplemonMidTurn(bool fromFaint, bool fromRevive)
Opens the menu to select a peoplemon to send out.
Definition: PlayerMenu.cpp:159
item::Id selectedItem() const
Returns the selected item.
Definition: PlayerMenu.cpp:194
void beginTurn()
Resets the menu to the turn start state.
Definition: PlayerMenu.cpp:154
int selectedMove() const
Returns the selected move index.
Definition: PlayerMenu.cpp:192
bool ready() const
Returns true when the player's choice has been made.
Definition: PlayerMenu.cpp:188
bool removeItem(item::Id item, unsigned int qty=1)
Removes the given item from the bag.
Definition: Bag.cpp:52
std::string name
Definition: State.hpp:42
player::Bag bag
Definition: State.hpp:44
Primary system for managing the player and their data.
Definition: Player.hpp:35
player::State & state()
Returns the state of the player.
Definition: Player.cpp:154