Peoplemon  0.1.0
Peoplemon 3 game source documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
core::battle::BattleController Class Referenceabstract

Interface for battle controllers. Battle controllers manage the flow of state and interaction for battles. More...

#include <BattleController.hpp>

+ Inheritance diagram for core::battle::BattleController:

Public Member Functions

 BattleController ()
 Initializes some internal state. More...
 
virtual ~BattleController ()=default
 Destroy the Battle Controller object. More...
 
void init (Battle &battle, BattleView &view, BattleState &state)
 Sets internal references to the view and state of the battle. More...
 
void update ()
 Updates the processing of the command queue. More...
 
void queueCommand (Command &&command, bool addWait=false)
 Enqueues a command to manipulate battle state or the view. More...
 

Protected Member Functions

virtual void onCommandQueued (const Command &cmd)=0
 Called when a command is first enqueued but not processed. May be used to send commands over the network, for example. More...
 
virtual void onCommandProcessed (const Command &cmd)=0
 This is called after a command is processed. Derived classes may perform specific actions for commands in this method, such as sending state across the network. More...
 
virtual void onUpdate (bool viewSynced, bool queueEmpty)=0
 Derived controllers may use this method for update logic every frame. More...
 

Protected Attributes

Battlebattle
 
BattleViewview
 
BattleStatestate
 

Detailed Description

Interface for battle controllers. Battle controllers manage the flow of state and interaction for battles.

Definition at line 23 of file BattleController.hpp.

Constructor & Destructor Documentation

◆ BattleController()

core::battle::BattleController::BattleController ( )

Initializes some internal state.

Definition at line 11 of file BattleController.cpp.

◆ ~BattleController()

virtual core::battle::BattleController::~BattleController ( )
virtualdefault

Destroy the Battle Controller object.

Member Function Documentation

◆ init()

void core::battle::BattleController::init ( Battle battle,
BattleView view,
BattleState state 
)

Sets internal references to the view and state of the battle.

Parameters
battleThe battle itself
viewThe view of the battle
stateThe state of the battle

Definition at line 16 of file BattleController.cpp.

◆ onCommandProcessed()

virtual void core::battle::BattleController::onCommandProcessed ( const Command cmd)
protectedpure virtual

This is called after a command is processed. Derived classes may perform specific actions for commands in this method, such as sending state across the network.

Parameters
cmdThe command that was just processed

◆ onCommandQueued()

virtual void core::battle::BattleController::onCommandQueued ( const Command cmd)
protectedpure virtual

Called when a command is first enqueued but not processed. May be used to send commands over the network, for example.

Parameters
cmdThe command that was just enqueued

◆ onUpdate()

virtual void core::battle::BattleController::onUpdate ( bool  viewSynced,
bool  queueEmpty 
)
protectedpure virtual

Derived controllers may use this method for update logic every frame.

Parameters
viewSyncedWhether or not the view is fully up to date and static
queueEmptyWhether or not the command queue has been fully drained

◆ queueCommand()

void core::battle::BattleController::queueCommand ( Command &&  command,
bool  addWait = false 
)

Enqueues a command to manipulate battle state or the view.

Parameters
commandThe command to enqueue
addWaitTrue to add a waitView command after the given command

Definition at line 49 of file BattleController.cpp.

◆ update()

void core::battle::BattleController::update ( )

Updates the processing of the command queue.

Definition at line 22 of file BattleController.cpp.

Member Data Documentation

◆ battle

Battle* core::battle::BattleController::battle
protected

Definition at line 61 of file BattleController.hpp.

◆ state

BattleState* core::battle::BattleController::state
protected

Definition at line 63 of file BattleController.hpp.

◆ view

BattleView* core::battle::BattleController::view
protected

Definition at line 62 of file BattleController.hpp.


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