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 Class Reference

Data model for a single player of the game, tracking also the number of counters held by this player. More...

#include <player.hpp>

Public Member Functions

void initializeWithRole (RoleID role)
 Assigns a role (black or white) to this player, and initializes the set of pieces corresponding to that role.
 
uint8_t deductCounters (uint8_t counters)
 Deducts some quantity of counters from this player's bank.
 
void depositCounters (uint8_t counters)
 Deposits some quantity of counters to this player's bank.
 
uint8_t getNPieces (Piece::State inState) const
 Returns the number of pieces owned by this player in a particular state.
 
uint8_t getNCounters () const
 Gets the number of counters currently held by this player.
 
RoleID getRole () const
 Gets the role (black or white or neither) currently assigned to this player for this game.
 
std::weak_ptr< PiecegetPiece (PieceTypeID pieceType)
 Gets a reference to the data model of some piece owned by this player.
 
const PiececGetPiece (PieceTypeID pieceType) const
 Gets (a const reference to) a piece owned by this player corresponding to a requested type.
 

Private Attributes

RoleID mRole { NA }
 The role (black or white) assigned to this player.
 
std::array< std::shared_ptr< Piece >, 5 > mPieces { nullptr }
 References to the data models of all the pieces owned by this player.
 
uint8_t mCounters { 25 }
 The number of counters currently held by this player.
 

Detailed Description

Data model for a single player of the game, tracking also the number of counters held by this player.

Member Function Documentation

◆ cGetPiece()

const Piece & Player::cGetPiece ( PieceTypeID pieceType) const

Gets (a const reference to) a piece owned by this player corresponding to a requested type.

Parameters
pieceTypeThe type of this player's piece we want the data model of.
Returns
const Piece& A const reference to the requested piece.

◆ deductCounters()

uint8_t Player::deductCounters ( uint8_t counters)

Deducts some quantity of counters from this player's bank.

Parameters
countersThe number of counters to be deducted per request.
Returns
uint8_t The number of counters actually deducted.

◆ depositCounters()

void Player::depositCounters ( uint8_t counters)

Deposits some quantity of counters to this player's bank.

Parameters
countersThe number of counters to be added to this player's bank.

◆ getNCounters()

uint8_t Player::getNCounters ( ) const
inline

Gets the number of counters currently held by this player.

Returns
uint8_t The number of counters held by this player.

◆ getNPieces()

uint8_t Player::getNPieces ( Piece::State inState) const

Returns the number of pieces owned by this player in a particular state.

Parameters
inStateThe state whose game piece count we want.
Returns
uint8_t The number of this player's pieces matching the state.

◆ getPiece()

std::weak_ptr< Piece > Player::getPiece ( PieceTypeID pieceType)

Gets a reference to the data model of some piece owned by this player.

Parameters
pieceTypeThe type of piece whose reference we want.
Returns
std::weak_ptr<Piece> The reference to the requested piece.
Todo
Why did I make this a pointer in the first place? I forget.

◆ getRole()

RoleID Player::getRole ( ) const
inline

Gets the role (black or white or neither) currently assigned to this player for this game.

Returns
RoleID The role assigned to this player.

◆ initializeWithRole()

void Player::initializeWithRole ( RoleID role)

Assigns a role (black or white) to this player, and initializes the set of pieces corresponding to that role.

Parameters
roleThe role (black or white) being assigned to this player.

Member Data Documentation

◆ mPieces

std::array<std::shared_ptr<Piece>, 5> Player::mPieces { nullptr }
private

References to the data models of all the pieces owned by this player.

Todo
Once again, why did these need to be pointers?

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