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
ur_player_local.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPPLAYERLOCAL_H
13#define ZOAPPPLAYERLOCAL_H
14
15#include "toymaker/sim_system.hpp"
16
17#include "ur_controller.hpp"
18
26class PlayerLocal: public ToyMaker::SimObjectAspect<PlayerLocal> {
27public:
28 PlayerLocal(): SimObjectAspect<PlayerLocal>{0} {}
29 inline static std::string getSimObjectAspectTypeName() { return "UrPlayerLocal"; }
30 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
31 std::shared_ptr<BaseSimObjectAspect> clone() const override;
32
33private:
38 std::string mControllerPath {};
39
44 std::unique_ptr<UrPlayerControls> mControls {};
45
50 void onActivated() override;
51
58 void onLaunchPieceAttempted(PieceTypeID pieceType, glm::u8vec2 location);
59
65
71
78
84 void onMovePrompted(GamePhaseData phaseData);
85
86public:
92 *this, "MovePromptedObserved",
93 [this](GamePhaseData phaseData) {this->onMovePrompted(phaseData);}
94 };
95
101 *this, "LaunchPieceAttemptedObserved",
102 [this](PieceTypeID pieceType, glm::u8vec2 location) { this->onLaunchPieceAttempted(pieceType, location); }
103 };
104
110 *this, "MovePieceAttemptedObserved",
111 [this](PieceIdentity piece) { this->onMoveBoardPieceAttempted(piece); }
112 };
113
119 *this, "NextTurnAttemptedObserved",
120 [this]() { this->onNextTurnAttempted(); }
121 };
122
128 *this, "DiceRollAttemptedObserved",
129 [this]() { this->onDiceRollAttempted(); }
130 };
131
137};
138
139#endif
ToyMaker::SignalObserver mObserveEndTurnAttempted
Observer of the end turn event, generated by the game's UI layer.
Definition ur_player_local.hpp:118
void onActivated() override
Prompts UrController to create and hand over controls that this player can then use to interact with ...
Definition ur_player_local.cpp:14
ToyMaker::SignalObserver mObserveDiceRollAttempted
Observerr of the dice roll event, generated by the game's UI layer.
Definition ur_player_local.hpp:127
ToyMaker::SignalObserver< PieceTypeID, glm::u8vec2 > mObservePieceLaunchAttempted
Observer of the launch piece event generated by the game's UI layer.
Definition ur_player_local.hpp:100
std::string mControllerPath
The path to the UrController in this scene, from which this aspect will receive its game controls.
Definition ur_player_local.hpp:38
ToyMaker::SignalObserver< GamePhaseData > mObserveMovePrompted
Observer of prompt move events generated by the game's UrController.
Definition ur_player_local.hpp:91
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...
Definition ur_player_local.cpp:8
ToyMaker::Signal< PlayerID > mSigControlInterface
Signal emitted when this player has been prompted for an action, and should take control of the UI an...
Definition ur_player_local.hpp:136
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
ToyMaker::SignalObserver< PieceIdentity > mObserveMovePieceAttempted
Observer of the move piece event, generated by the game's 3D scene layer.
Definition ur_player_local.hpp:109
std::unique_ptr< UrPlayerControls > mControls
The controls returned by UrController, used to interact with the game data model.
Definition ur_player_local.hpp:44
void onMovePrompted(GamePhaseData phaseData)
Callback issued by UrController when this player is required to take action.
Definition ur_player_local.cpp:39
void onLaunchPieceAttempted(PieceTypeID pieceType, glm::u8vec2 location)
Attempts to launch a game piece to some location.
Definition ur_player_local.cpp:23
void onNextTurnAttempted()
Attempts to advance the game by a turn, ending the current turn.
Definition ur_player_local.cpp:27
void onDiceRollAttempted()
Attempts to roll the dice.
Definition ur_player_local.cpp:31
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
PieceTypeID
Enum listing the different types of pieces present in the game.
Definition piece_type_id.hpp:22
Data returned by GameOfUrModel when queried about the current phase of the game.
Definition model.hpp:112
Data uniquely identifying a piece used in the game.
Definition piece.hpp:29
Contains the class definition for UrController, the aspect responsible for managing and reporting the...