17#ifndef ZOAPPURCONTROLLER_H
18#define ZOAPPURCONTROLLER_H
20#define GLM_ENABLE_EXPERIMENTAL
21#include <glm/gtx/string_cast.hpp>
23#include "toymaker/sim_system.hpp"
55 static std::shared_ptr<BaseSimObjectAspect>
create(
const nlohmann::json& jsonAspectProperties);
62 std::shared_ptr<BaseSimObjectAspect>
clone()
const override;
182 *
this,
"ViewSubscribedObserved",
227 *
this,
"ViewUpdateCompletedObserved",
296 inline static std::unique_ptr<UrPlayerControls>
create(
PlayerID player, UrController& urController) {
297 return std::unique_ptr<UrPlayerControls>(
new UrPlayerControls{ player, urController });
319friend class UrController;
The class containing the interface to the data model for the whole game (Game of Ur).
The data model representing one instance of Game of Ur.
Definition model.hpp:337
A SignalObserver object, which can subscribe to Signals matching its data signature and receive signa...
Definition signals.hpp:412
A Signal object, designed to emit signals matching some data signature to be received by all the Sign...
Definition signals.hpp:323
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
ToyMaker::Signal< DiceData > mSigDiceUpdated
Signal emitted when the game data model reports a change in the state of its dice.
Definition ur_controller.hpp:208
void onDiceRollAttempted(PlayerID player)
Attempts to roll the dice.
Definition ur_controller.cpp:153
void onViewSubscribed(const std::string &subscriber)
Adds a view which is interested in receiving information about events regarding changes in the state ...
Definition ur_controller.cpp:28
std::map< std::string, bool > mViewUpdated
Flags corresponding with various views subscribed with this object.
Definition ur_controller.hpp:108
GameOfUrModel mModel
The game data model this aspect is an interface to.
Definition ur_controller.hpp:86
ToyMaker::Signal mSigControllerReady
Signal emitted by this object when it is ready to be interacted with by other objects.
Definition ur_controller.hpp:175
static std::string getSimObjectAspectTypeName()
Gets the aspect type string associated with this object.
Definition ur_controller.hpp:47
void onLaunchPieceAttempted(PlayerID player, PieceIdentity piece, glm::u8vec2 launchLocation=glm::u8vec2{0, 0})
Attempts to launch a game piece to the board.
Definition ur_controller.cpp:71
ToyMaker::Signal< PlayerData > mSigPlayerUpdated
Signal emitted when information associated with a player changes.
Definition ur_controller.hpp:202
ToyMaker::Signal< MoveResultData > mSigMoveMade
Signal emitted when the game data model reports a move successfully executed.
Definition ur_controller.hpp:214
void onNextTurnAttempted(PlayerID player)
Attempts to end the current turn and move to the next one.
Definition ur_controller.cpp:128
ToyMaker::Signal< GameScoreData > mSigScoreUpdated
Signal emitted when the game data model reports a change in score.
Definition ur_controller.hpp:196
ToyMaker::Signal mSigViewUpdateStarted
Signal emitted when this controller begins waiting for view updates related to the latest game state ...
Definition ur_controller.hpp:220
std::unique_ptr< UrPlayerControls > createControls()
Creates an instance of UrPlayerControls, which exposes methods which allow (controlled) interaction w...
Definition ur_controller.cpp:66
ToyMaker::SignalObserver< const std::string & > mObserveViewSubscribed
Observer to a signal emitted by views interested in events broadcasted by this object.
Definition ur_controller.hpp:181
void onMoveBoardPieceAttempted(PlayerID player, PieceIdentity piece)
Attempts to move a piece present on the board according to the current roll.
Definition ur_controller.cpp:92
static std::shared_ptr< BaseSimObjectAspect > create(const nlohmann::json &jsonAspectProperties)
Creates an UrController based on its JSON description.
Definition ur_controller.cpp:9
UrController()
Constructs a new UrController aspect.
Definition ur_controller.hpp:40
const GameOfUrModel & getModel() const
Gets a const reference to the underlying data model of this object.
Definition ur_controller.hpp:69
ToyMaker::Signal< GamePhaseData > mSigMovePrompted
Signal emitted when the controller expects a player to act, either via the game UI or some other sour...
Definition ur_controller.hpp:235
std::shared_ptr< BaseSimObjectAspect > clone() const override
Constructs an UrController object using this one as its blueprint.
Definition ur_controller.cpp:15
bool viewUpdatesComplete() const
Returns whether all the views connected with this controller have reported completion of their update...
Definition ur_controller.cpp:21
void onViewUpdatesCompleted(const std::string &viewName)
The callback, invoked by a subscribed view, where the view reports that it has completed all view cha...
Definition ur_controller.cpp:32
void onActivated() override
Initializes the game data model.
Definition ur_controller.cpp:51
std::string mSceneManagerPath
The path to the scene manager, responsible for navigating between the different game screens in this ...
Definition ur_controller.hpp:100
ToyMaker::Signal< GamePhaseData > mSigPhaseUpdated
Signal emitted when a the game data model reports a change to its phase.
Definition ur_controller.hpp:190
uint8_t mControlsCreated
The number of controls connected with this object created over its lifetime.
Definition ur_controller.hpp:94
ToyMaker::SignalObserver< const std::string & > mObserveViewUpdateCompleted
Observer which receives signals from its subscribed views when they report their updates are complete...
Definition ur_controller.hpp:226
The definition for the object that acts as the interface between the game controller and any systems ...
Definition ur_controller.hpp:246
void attemptDiceRoll()
Attempts to roll the dice.
Definition ur_controller.cpp:166
PlayerID getPlayer() const
Gets the ID of the player associated with this object.
Definition ur_controller.hpp:253
const GameOfUrModel & getModel()
Gets a constant reference to the underlying data model used by UrController.
Definition ur_controller.hpp:287
static std::unique_ptr< UrPlayerControls > create(PlayerID player, UrController &urController)
Creates an instance of UrPlayerControls.
Definition ur_controller.hpp:296
PlayerID mPlayer
The ID of the player to whom these controls belong.
Definition ur_controller.hpp:311
UrController & mUrController
The reference to the game controller connected with these controls.
Definition ur_controller.hpp:317
UrPlayerControls(PlayerID player, UrController &urController)
Constructs a new UrPlayerControls object.
Definition ur_controller.hpp:305
void attemptLaunchPiece(PieceTypeID pieceType, glm::u8vec2 launchLocation=glm::u8vec2{0, 0})
Attempts to launch a game piece to some location on the game board.
Definition ur_controller.cpp:169
void attemptNextTurn()
Attempts to end the current turn and begin the next one.
Definition ur_controller.cpp:176
void attemptMoveBoardPiece(PieceIdentity piece)
Attempts to move a piece already on the board to a new location based on the current dice roll.
Definition ur_controller.cpp:173
PieceTypeID
Enum listing the different types of pieces present in the game.
Definition piece_type_id.hpp:22
PlayerID
The two players playing the game, as known to GameOfUrModel.
Definition model.hpp:40
Data uniquely identifying a piece used in the game.
Definition piece.hpp:29