Game of Ur
0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Toggle main menu visibility
Loading...
Searching...
No Matches
piece.hpp
Go to the documentation of this file.
1
11
12
#ifndef ZOAPPGAMEPIECES_H
13
#define ZOAPPGAMEPIECES_H
14
15
#include <string>
16
17
#include <glm/glm.hpp>
18
19
#include "
role_id.hpp
"
20
#include "
piece_type_id.hpp
"
21
29
struct
PieceIdentity
{
34
PieceTypeID
mType
;
35
40
RoleID
mOwner
;
41
};
42
43
bool
operator<(
const
PieceIdentity
& one,
const
PieceIdentity
& two);
44
bool
operator==(
const
PieceIdentity
& one,
const
PieceIdentity
& two);
45
bool
operator!=(
const
PieceIdentity
& one,
const
PieceIdentity
& two);
46
52
class
Piece
{
53
public
:
58
enum class
State
: uint8_t {
59
UNLAUNCHED,
//< This piece hasn't been launched to the board yet.
60
ON_BOARD,
//< This piece is currently on the board.
61
FINISHED,
//< This piece has completed its route.
62
};
63
70
Piece
(
PieceTypeID
type,
RoleID
owner):
71
mIdentity
{ .mType { type }, .mOwner { owner } }
72
{}
73
79
RoleID
getOwner
()
const
{
return
mIdentity
.mOwner; }
80
86
PieceTypeID
getType
()
const
{
return
mIdentity
.mType; }
87
93
PieceIdentity
getIdentity
()
const
{
return
mIdentity
; }
94
100
State
getState
()
const
{
return
mState
; }
101
107
glm::u8vec2
getLocation
()
const
{
return
mLocation
; }
108
114
void
setState
(
State
state) {
mState
= state; }
115
121
void
setLocation
(glm::u8vec2 location) {
mLocation
= location; }
122
133
bool
canMove
(uint8_t roll,
RoleID
player)
const
;
134
135
private
:
140
State
mState
{ State::UNLAUNCHED };
141
146
PieceIdentity
mIdentity
;
147
152
glm::u8vec2
mLocation
{0, 0};
153
};
154
155
#endif
Piece::getLocation
glm::u8vec2 getLocation() const
Gets the current location of this piece on the board.
Definition
piece.hpp:107
Piece::mState
State mState
The current (high level) state of this piece.
Definition
piece.hpp:140
Piece::getIdentity
PieceIdentity getIdentity() const
Gets the identity of this piece, both its type and owner.
Definition
piece.hpp:93
Piece::setLocation
void setLocation(glm::u8vec2 location)
Sets the location of this piece on the board.
Definition
piece.hpp:121
Piece::getOwner
RoleID getOwner() const
Gets the owner of this piece, the set to which this piece belongs.
Definition
piece.hpp:79
Piece::getState
State getState() const
Gets the (high level) state of this piece.
Definition
piece.hpp:100
Piece::setState
void setState(State state)
Sets the (high level) state of this piece.
Definition
piece.hpp:114
Piece::mLocation
glm::u8vec2 mLocation
This piece's current location with respect to the game board.
Definition
piece.hpp:152
Piece::State
State
A value representing the (high level) state of this piece.
Definition
piece.hpp:58
Piece::canMove
bool canMove(uint8_t roll, RoleID player) const
Tests whether this piece can be moved at all.
Definition
piece.cpp:4
Piece::getType
PieceTypeID getType() const
Gets the type of piece this piece is.
Definition
piece.hpp:86
Piece::mIdentity
PieceIdentity mIdentity
The unique identity of this piece.
Definition
piece.hpp:146
Piece::Piece
Piece(PieceTypeID type, RoleID owner)
Constructs a new Piece.
Definition
piece.hpp:70
PieceTypeID
PieceTypeID
Enum listing the different types of pieces present in the game.
Definition
piece_type_id.hpp:22
RoleID
RoleID
A value representing the various roles (or sets, if preferred) possible in this game.
Definition
role_id.hpp:20
piece_type_id.hpp
Contains enum listing the different types of pieces present in the game.
role_id.hpp
Contains an enum for the roles (sets of pieces) possible within this game.
PieceIdentity
Data uniquely identifying a piece used in the game.
Definition
piece.hpp:29
PieceIdentity::mOwner
RoleID mOwner
The set to which this piece belongs.
Definition
piece.hpp:40
PieceIdentity::mType
PieceTypeID mType
The type of the piece.
Definition
piece.hpp:34
src
app
game_of_ur_data
piece.hpp
Generated on
for Game of Ur by
1.17.0