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
player.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPPLAYER_H
13#define ZOAPPPLAYER_H
14
15#include <memory>
16#include <array>
17
18#include <glm/glm.hpp>
19
20#include "piece.hpp"
21#include "role_id.hpp"
22
28class Player {
29public:
35 void initializeWithRole(RoleID role);
36
43 uint8_t deductCounters(uint8_t counters);
44
50 void depositCounters(uint8_t counters);
51
58 uint8_t getNPieces(Piece::State inState) const;
59
65 inline uint8_t getNCounters() const { return mCounters; }
66
72 inline RoleID getRole() const { return mRole; }
73
82 std::weak_ptr<Piece> getPiece(PieceTypeID pieceType);
83
90 const Piece& cGetPiece(PieceTypeID pieceType) const;
91
92private:
97 RoleID mRole { NA };
98
105 std::array<std::shared_ptr<Piece>, 5> mPieces { nullptr };
106
111 uint8_t mCounters { 25 };
112};
113
114#endif
The state of a single piece of the game.
Definition piece.hpp:52
State
A value representing the (high level) state of this piece.
Definition piece.hpp:58
Data model for a single player of the game, tracking also the number of counters held by this player.
Definition player.hpp:28
uint8_t mCounters
The number of counters currently held by this player.
Definition player.hpp:111
std::weak_ptr< Piece > getPiece(PieceTypeID pieceType)
Gets a reference to the data model of some piece owned by this player.
Definition player.cpp:15
const Piece & cGetPiece(PieceTypeID pieceType) const
Gets (a const reference to) a piece owned by this player corresponding to a requested type.
Definition player.cpp:20
uint8_t getNCounters() const
Gets the number of counters currently held by this player.
Definition player.hpp:65
RoleID mRole
The role (black or white) assigned to this player.
Definition player.hpp:97
uint8_t deductCounters(uint8_t counters)
Deducts some quantity of counters from this player's bank.
Definition player.cpp:7
std::array< std::shared_ptr< Piece >, 5 > mPieces
References to the data models of all the pieces owned by this player.
Definition player.hpp:105
uint8_t getNPieces(Piece::State inState) const
Returns the number of pieces owned by this player in a particular state.
Definition player.cpp:41
void depositCounters(uint8_t counters)
Deposits some quantity of counters to this player's bank.
Definition player.cpp:3
void initializeWithRole(RoleID role)
Assigns a role (black or white) to this player, and initializes the set of pieces corresponding to th...
Definition player.cpp:26
RoleID getRole() const
Gets the role (black or white or neither) currently assigned to this player for this game.
Definition player.hpp:72
PieceTypeID
Enum listing the different types of pieces present in the game.
Definition piece_type_id.hpp:22
RoleID
A value representing the various roles (or sets, if preferred) possible in this game.
Definition role_id.hpp:20
Contains definitions for pieces belonging to different sets used by competing players.
Contains an enum for the roles (sets of pieces) possible within this game.