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

The state of a single piece of the game. More...

#include <piece.hpp>

Public Types

enum class  State : uint8_t { UNLAUNCHED , ON_BOARD , FINISHED }
 A value representing the (high level) state of this piece.
 

Public Member Functions

 Piece (PieceTypeID type, RoleID owner)
 Constructs a new Piece.
 
RoleID getOwner () const
 Gets the owner of this piece, the set to which this piece belongs.
 
PieceTypeID getType () const
 Gets the type of piece this piece is.
 
PieceIdentity getIdentity () const
 Gets the identity of this piece, both its type and owner.
 
State getState () const
 Gets the (high level) state of this piece.
 
glm::u8vec2 getLocation () const
 Gets the current location of this piece on the board.
 
void setState (State state)
 Sets the (high level) state of this piece.
 
void setLocation (glm::u8vec2 location)
 Sets the location of this piece on the board.
 
bool canMove (uint8_t roll, RoleID player) const
 Tests whether this piece can be moved at all.
 

Private Attributes

State mState { State::UNLAUNCHED }
 The current (high level) state of this piece.
 
PieceIdentity mIdentity
 The unique identity of this piece.
 
glm::u8vec2 mLocation {0, 0}
 This piece's current location with respect to the game board.
 

Detailed Description

The state of a single piece of the game.

Constructor & Destructor Documentation

◆ Piece()

Piece::Piece ( PieceTypeID type,
RoleID owner )
inline

Constructs a new Piece.

Parameters
typeThe type of piece represented by this object.
ownerThe set to which this piece belongs (black or white).

Member Function Documentation

◆ canMove()

bool Piece::canMove ( uint8_t roll,
RoleID player ) const

Tests whether this piece can be moved at all.

For this piece to report that it can move, it should either be on the board or unlaunched, and if unlaunched the roll must correspond to this piece type's launch roll.

Parameters
rollThe roll with which we'd like to move this piece.
playerThe player requesting the move.
Return values
trueThis piece may move.
falseThis piece can't move.

◆ getIdentity()

PieceIdentity Piece::getIdentity ( ) const
inline

Gets the identity of this piece, both its type and owner.

Returns
PieceIdentity The identity of this piece.

◆ getLocation()

glm::u8vec2 Piece::getLocation ( ) const
inline

Gets the current location of this piece on the board.

Returns
glm::u8vec2 The location of this piece on the board.

◆ getOwner()

RoleID Piece::getOwner ( ) const
inline

Gets the owner of this piece, the set to which this piece belongs.

Returns
RoleID The owner of this piece or the set to which it belongs.

◆ getState()

State Piece::getState ( ) const
inline

Gets the (high level) state of this piece.

Returns
State This piece's state.

◆ getType()

PieceTypeID Piece::getType ( ) const
inline

Gets the type of piece this piece is.

Returns
PieceTypeID This piece's type.

◆ setLocation()

void Piece::setLocation ( glm::u8vec2 location)
inline

Sets the location of this piece on the board.

Parameters
locationThis piece's new location.

◆ setState()

void Piece::setState ( State state)
inline

Sets the (high level) state of this piece.

Parameters
stateThis piece's new state.

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