Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
PlayerLocal Class Reference

Definition of the aspect class representing a player playing the Game of Ur locally. More...

#include <ur_player_local.hpp>

Inheritance diagram for PlayerLocal:
ToyMaker::SimObjectAspect< PlayerLocal > ToyMaker::BaseSimObjectAspect ToyMaker::SignalTracker ToyMaker::IActionHandler

Public Member Functions

std::shared_ptr< BaseSimObjectAspect > clone () const override
 A method which must be overridden to specify how a new aspect should be constructed as a copy of this one.
 
- Public Member Functions inherited from ToyMaker::BaseSimObjectAspect
virtual ~BaseSimObjectAspect ()=default
 Destroys this object.
 
virtual void simulationUpdate (uint32_t simStepMillis)
 Overriding this allows an aspect to respond to simulation updates.
 
virtual void variableUpdate (uint32_t variableStepMillis)
 Overriding this allows an aspect to respond to variable updates.
 
bool handleAction (const ActionData &actionData, const ActionDefinition &actionDefinition) override final
 Pipes an action received from the InputManager via our SimObject to all that action's handler methods on this aspect.
 
ViewportNodegetLocalViewport ()
 Returns the closest ancestor viewport to this node, if one exists (which it should, since this shouldn't be called until this aspect is attached to an active SimObject).
 
- Public Member Functions inherited from ToyMaker::SignalTracker
 SignalTracker ()
 Constructs a new SignalTracker object.
 
 SignalTracker (const SignalTracker &other)
 Constructs a new SignalTracker.
 
SignalTrackeroperator= (const SignalTracker &other)
 Copy assignment operator.
 
 SignalTracker (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, invalidating them from the other.
 
SignalTrackeroperator= (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, destroying this tracker's resources in the process.
 
void connect (const std::string &theirSignal, const std::string &ourObserver, SignalTracker &other)
 Method that connects one of this objects SignalObservers to another tracker's Signal.
 

Static Public Member Functions

static std::string getSimObjectAspectTypeName ()
 
static std::shared_ptr< BaseSimObjectAspect > create (const nlohmann::json &jsonAspectProperties)
 

Public Attributes

ToyMaker::SignalObserver< GamePhaseDatamObserveMovePrompted
 Observer of prompt move events generated by the game's UrController.
 
ToyMaker::SignalObserver< PieceTypeID, glm::u8vec2 > mObservePieceLaunchAttempted
 Observer of the launch piece event generated by the game's UI layer.
 
ToyMaker::SignalObserver< PieceIdentitymObserveMovePieceAttempted
 Observer of the move piece event, generated by the game's 3D scene layer.
 
ToyMaker::SignalObserver mObserveEndTurnAttempted
 Observer of the end turn event, generated by the game's UI layer.
 
ToyMaker::SignalObserver mObserveDiceRollAttempted
 Observerr of the dice roll event, generated by the game's UI layer.
 
ToyMaker::Signal< PlayerIDmSigControlInterface {*this, "ControlInterface"}
 Signal emitted when this player has been prompted for an action, and should take control of the UI and 3D scene of the game.
 

Private Member Functions

void onActivated () override
 Prompts UrController to create and hand over controls that this player can then use to interact with (the data model of) the game.
 
void onLaunchPieceAttempted (PieceTypeID pieceType, glm::u8vec2 location)
 Attempts to launch a game piece to some location.
 
void onNextTurnAttempted ()
 Attempts to advance the game by a turn, ending the current turn.
 
void onDiceRollAttempted ()
 Attempts to roll the dice.
 
void onMoveBoardPieceAttempted (PieceIdentity piece)
 Attempts to move a piece situated somewhere on the board to a new location based on the current dice state.
 
void onMovePrompted (GamePhaseData phaseData)
 Callback issued by UrController when this player is required to take action.
 

Private Attributes

std::string mControllerPath {}
 The path to the UrController in this scene, from which this aspect will receive its game controls.
 
std::unique_ptr< UrPlayerControlsmControls {}
 The controls returned by UrController, used to interact with the game data model.
 

Additional Inherited Members

- Protected Member Functions inherited from ToyMaker::SimObjectAspect< PlayerLocal >
 SimObjectAspect (int explicitlyInitializeMe)
 
- Protected Member Functions inherited from ToyMaker::BaseSimObjectAspect
 BaseSimObjectAspect (const BaseSimObjectAspect &other)=delete
 
 BaseSimObjectAspect (BaseSimObjectAspect &&other)=delete
 
SimObjectgetSimObject ()
 Returns the sim object that this aspect is attached to.
 
template<typename TComponent>
void addComponent (const TComponent &component)
 Adds a component of some type to the underlying entity.
 
template<typename TComponent>
bool hasComponent ()
 Tests whether a component of some specific type is present on the object.
 
template<typename TComponent>
void updateComponent (const TComponent &component)
 Updates the value of a component belonging to this object to a new one.
 
template<typename TComponent>
TComponent getComponent (const float simulationProgress=1.f) const
 Gets the value of a component belonging to this object.
 
template<typename TComponent>
void removeComponent ()
 Removes a component of some type belonging to the underlying SimObject.
 
void addAspect (const nlohmann::json &jsonAspectProperties)
 Adds a new aspect to the underlying SimObject constructed based on its properties in JSON.
 
void addAspect (const BaseSimObjectAspect &aspect)
 Adds a new aspect to the underlying SimObject copied from an already existing aspect.
 
template<typename TSimObjectAspect>
bool hasAspect () const
 Tests whether an aspect of a particular type is attached to the underlying SimObject.
 
bool hasAspect (const std::string &aspectType) const
 Tests whether an aspect of a particular type is attached to the underlying SimObject.
 
template<typename TSimObjectAspect>
TSimObjectAspect & getAspect ()
 Gets an aspect of a particular type belonging to the underlying SimObject.
 
BaseSimObjectAspectgetAspect (const std::string &aspectType)
 Gets (a base class reference to) an aspect of a particular type belonging to the underlying SimObject.
 
template<typename TSimObjectAspect>
void removeAspect ()
 Removes an aspect from the underlying SimObject.
 
void addOrReplaceAspect (const BaseSimObjectAspect &aspect)
 Adds or replaces an aspect on the underlying SimObject with a new aspect constructed as a copy of another.
 
void addOrReplaceAspect (const nlohmann::json &jsonAspectProperties)
 Adds or replaces an aspect on the underlying SimObject with a new aspect constructed from its JSON description.
 
std::weak_ptr< FixedActionBindingdeclareFixedActionBinding (const std::string &context, const std::string &action, std::function< bool(const ActionData &, const ActionDefinition &)>)
 Binds some method (or any function) present on this object to an action generated by the InputManager.
 
EntityID getEntityID () const
 Gets the ID of the ECSWorld Entity belonging to our SimObject.
 
std::weak_ptr< ECSWorldgetWorld () const
 Gets a weak reference to the ECSWorld to which our SimObject's entity belongs.
 
- Static Protected Member Functions inherited from ToyMaker::BaseSimObjectAspect
template<typename TSimObjectAspectDerived>
static void registerAspect ()
 Registers an implementation of an aspect with the SimSystem.
 

Detailed Description

Definition of the aspect class representing a player playing the Game of Ur locally.

This player uses this application's UI and input system to interact with the game data model.

Member Function Documentation

◆ clone()

std::shared_ptr< ToyMaker::BaseSimObjectAspect > PlayerLocal::clone ( ) const
overridevirtual

A method which must be overridden to specify how a new aspect should be constructed as a copy of this one.

Returns
std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.

Implements ToyMaker::BaseSimObjectAspect.

◆ onActivated()

void PlayerLocal::onActivated ( )
overrideprivatevirtual

Prompts UrController to create and hand over controls that this player can then use to interact with (the data model of) the game.

Reimplemented from ToyMaker::BaseSimObjectAspect.

◆ onLaunchPieceAttempted()

void PlayerLocal::onLaunchPieceAttempted ( PieceTypeID pieceType,
glm::u8vec2 location )
private

Attempts to launch a game piece to some location.

Parameters
pieceTypeThe type of piece being launched.
locationThe location to which the piece should be launched.

◆ onMoveBoardPieceAttempted()

void PlayerLocal::onMoveBoardPieceAttempted ( PieceIdentity piece)
private

Attempts to move a piece situated somewhere on the board to a new location based on the current dice state.

Parameters
pieceThe piece to be moved.

◆ onMovePrompted()

void PlayerLocal::onMovePrompted ( GamePhaseData phaseData)
private

Callback issued by UrController when this player is required to take action.

Parameters
phaseDataThe current phase of the game.

Member Data Documentation

◆ mObserveDiceRollAttempted

ToyMaker::SignalObserver PlayerLocal::mObserveDiceRollAttempted
Initial value:
{
*this, "DiceRollAttemptedObserved",
[this]() { this->onDiceRollAttempted(); }
}
void onDiceRollAttempted()
Attempts to roll the dice.
Definition ur_player_local.cpp:31

Observerr of the dice roll event, generated by the game's UI layer.

◆ mObserveEndTurnAttempted

ToyMaker::SignalObserver PlayerLocal::mObserveEndTurnAttempted
Initial value:
{
*this, "NextTurnAttemptedObserved",
[this]() { this->onNextTurnAttempted(); }
}
void onNextTurnAttempted()
Attempts to advance the game by a turn, ending the current turn.
Definition ur_player_local.cpp:27

Observer of the end turn event, generated by the game's UI layer.

◆ mObserveMovePieceAttempted

ToyMaker::SignalObserver<PieceIdentity> PlayerLocal::mObserveMovePieceAttempted
Initial value:
{
*this, "MovePieceAttemptedObserved",
[this](PieceIdentity piece) { this->onMoveBoardPieceAttempted(piece); }
}
void onMoveBoardPieceAttempted(PieceIdentity piece)
Attempts to move a piece situated somewhere on the board to a new location based on the current dice ...
Definition ur_player_local.cpp:35
Data uniquely identifying a piece used in the game.
Definition piece.hpp:29

Observer of the move piece event, generated by the game's 3D scene layer.

◆ mObserveMovePrompted

ToyMaker::SignalObserver<GamePhaseData> PlayerLocal::mObserveMovePrompted
Initial value:
{
*this, "MovePromptedObserved",
[this](GamePhaseData phaseData) {this->onMovePrompted(phaseData);}
}
void onMovePrompted(GamePhaseData phaseData)
Callback issued by UrController when this player is required to take action.
Definition ur_player_local.cpp:39
Data returned by GameOfUrModel when queried about the current phase of the game.
Definition model.hpp:112

Observer of prompt move events generated by the game's UrController.

◆ mObservePieceLaunchAttempted

ToyMaker::SignalObserver<PieceTypeID, glm::u8vec2> PlayerLocal::mObservePieceLaunchAttempted
Initial value:
{
*this, "LaunchPieceAttemptedObserved",
[this](PieceTypeID pieceType, glm::u8vec2 location) { this->onLaunchPieceAttempted(pieceType, location); }
}
void onLaunchPieceAttempted(PieceTypeID pieceType, glm::u8vec2 location)
Attempts to launch a game piece to some location.
Definition ur_player_local.cpp:23
PieceTypeID
Enum listing the different types of pieces present in the game.
Definition piece_type_id.hpp:22

Observer of the launch piece event generated by the game's UI layer.


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