Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
The class responsible for managing and reporting the state of the game. It owns its own instance of GameOfUrModel, and acts as the interface between it and engine-specific objects. More...
#include <ur_controller.hpp>
Public Member Functions | |
UrController () | |
Constructs a new UrController aspect. | |
std::shared_ptr< BaseSimObjectAspect > | clone () const override |
Constructs an UrController object using this one as its blueprint. | |
const GameOfUrModel & | getModel () const |
Gets a const reference to the underlying data model of this object. | |
std::unique_ptr< UrPlayerControls > | createControls () |
Creates an instance of UrPlayerControls, which exposes methods which allow (controlled) interaction with this aspect, corresponding with an ID known by the underlying data model. | |
![]() | |
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. | |
ViewportNode & | getLocalViewport () |
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). | |
![]() | |
SignalTracker () | |
Constructs a new SignalTracker object. | |
SignalTracker (const SignalTracker &other) | |
Constructs a new SignalTracker. | |
SignalTracker & | operator= (const SignalTracker &other) |
Copy assignment operator. | |
SignalTracker (SignalTracker &&other) | |
Moves resources from another SignalTracker into this one, invalidating them from the other. | |
SignalTracker & | operator= (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 () |
Gets the aspect type string associated with this object. | |
static std::shared_ptr< BaseSimObjectAspect > | create (const nlohmann::json &jsonAspectProperties) |
Creates an UrController based on its JSON description. | |
Public Attributes | |
ToyMaker::Signal | mSigControllerReady { *this, "ControllerReady" } |
Signal emitted by this object when it is ready to be interacted with by other objects. | |
ToyMaker::SignalObserver< const std::string & > | mObserveViewSubscribed |
Observer to a signal emitted by views interested in events broadcasted by this object. | |
ToyMaker::Signal< GamePhaseData > | mSigPhaseUpdated { *this, "PhaseUpdated" } |
Signal emitted when a the game data model reports a change to its phase. | |
ToyMaker::Signal< GameScoreData > | mSigScoreUpdated { *this, "ScoreUpdated" } |
Signal emitted when the game data model reports a change in score. | |
ToyMaker::Signal< PlayerData > | mSigPlayerUpdated { *this, "PlayerUpdated" } |
Signal emitted when information associated with a player changes. | |
ToyMaker::Signal< DiceData > | mSigDiceUpdated { *this, "DiceUpdated" } |
Signal emitted when the game data model reports a change in the state of its dice. | |
ToyMaker::Signal< MoveResultData > | mSigMoveMade { *this, "MoveMade" } |
Signal emitted when the game data model reports a move successfully executed. | |
ToyMaker::Signal | mSigViewUpdateStarted { *this, "ViewUpdateStarted" } |
Signal emitted when this controller begins waiting for view updates related to the latest game state change to complete. | |
ToyMaker::SignalObserver< const std::string & > | mObserveViewUpdateCompleted |
Observer which receives signals from its subscribed views when they report their updates are complete. | |
ToyMaker::Signal< GamePhaseData > | mSigMovePrompted { *this, "MovePrompted" } |
Signal emitted when the controller expects a player to act, either via the game UI or some other source. | |
Private Member Functions | |
bool | viewUpdatesComplete () const |
Returns whether all the views connected with this controller have reported completion of their updates. | |
void | onViewSubscribed (const std::string &subscriber) |
Adds a view which is interested in receiving information about events regarding changes in the state of the game. | |
void | onLaunchPieceAttempted (PlayerID player, PieceIdentity piece, glm::u8vec2 launchLocation=glm::u8vec2{0, 0}) |
Attempts to launch a game piece to the board. | |
void | onMoveBoardPieceAttempted (PlayerID player, PieceIdentity piece) |
Attempts to move a piece present on the board according to the current roll. | |
void | onNextTurnAttempted (PlayerID player) |
Attempts to end the current turn and move to the next one. | |
void | onDiceRollAttempted (PlayerID player) |
Attempts to roll the dice. | |
void | onViewUpdatesCompleted (const std::string &viewName) |
The callback, invoked by a subscribed view, where the view reports that it has completed all view changes related to the latest change in game state. | |
void | onActivated () override |
Initializes the game data model. | |
Private Attributes | |
GameOfUrModel | mModel {} |
The game data model this aspect is an interface to. | |
uint8_t | mControlsCreated {0} |
The number of controls connected with this object created over its lifetime. | |
std::string | mSceneManagerPath {} |
The path to the scene manager, responsible for navigating between the different game screens in this project. | |
std::map< std::string, bool > | mViewUpdated {} |
Flags corresponding with various views subscribed with this object. | |
Friends | |
class | UrPlayerControls |
Additional Inherited Members | |
![]() | |
SimObjectAspect (int explicitlyInitializeMe) | |
![]() | |
BaseSimObjectAspect (const BaseSimObjectAspect &other)=delete | |
BaseSimObjectAspect (BaseSimObjectAspect &&other)=delete | |
SimObject & | getSimObject () |
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. | |
BaseSimObjectAspect & | getAspect (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< FixedActionBinding > | declareFixedActionBinding (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< ECSWorld > | getWorld () const |
Gets a weak reference to the ECSWorld to which our SimObject's entity belongs. | |
![]() | |
template<typename TSimObjectAspectDerived> | |
static void | registerAspect () |
Registers an implementation of an aspect with the SimSystem. | |
The class responsible for managing and reporting the state of the game. It owns its own instance of GameOfUrModel, and acts as the interface between it and engine-specific objects.
|
overridevirtual |
Constructs an UrController object using this one as its blueprint.
Implements ToyMaker::BaseSimObjectAspect.
|
static |
Creates an UrController based on its JSON description.
jsonAspectProperties | The JSON description of this instance of UrController. |
std::unique_ptr< UrPlayerControls > UrController::createControls | ( | ) |
Creates an instance of UrPlayerControls, which exposes methods which allow (controlled) interaction with this aspect, corresponding with an ID known by the underlying data model.
No more than two such player controls can exist for a single instance of this controller.
|
inline |
Gets a const reference to the underlying data model of this object.
|
inlinestatic |
Gets the aspect type string associated with this object.
|
overrideprivatevirtual |
Initializes the game data model.
Reimplemented from ToyMaker::BaseSimObjectAspect.
|
private |
Attempts to roll the dice.
player | The player requesting the dice roll. |
|
private |
Attempts to launch a game piece to the board.
player | The player requesting the launch. |
piece | The piece being launched. |
launchLocation | The game board grid location to which the player wants the piece launched. |
|
private |
Attempts to move a piece present on the board according to the current roll.
player | The player requesting the move. |
piece | The piece on the game board being moved. |
|
private |
Attempts to end the current turn and move to the next one.
player | The player requesting the end of the turn. |
|
private |
Adds a view which is interested in receiving information about events regarding changes in the state of the game.
subscriber | A view interested in game-state changes. |
|
private |
The callback, invoked by a subscribed view, where the view reports that it has completed all view changes related to the latest change in game state.
viewName | The name of the view which has completed its view updates. |
|
private |
Returns whether all the views connected with this controller have reported completion of their updates.
true | All associated views have reported completion of their updates. |
false | One or more views have not reported completion of their updates. |
|
private |
The number of controls connected with this object created over its lifetime.
More than two is an error.
ToyMaker::SignalObserver<const std::string&> UrController::mObserveViewSubscribed |
Observer to a signal emitted by views interested in events broadcasted by this object.
ToyMaker::SignalObserver<const std::string&> UrController::mObserveViewUpdateCompleted |
Observer which receives signals from its subscribed views when they report their updates are complete.
|
private |
Flags corresponding with various views subscribed with this object.
All the subscribed views must report that their update has taken place before the controller allows more game events to occur.