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.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
42
43bool operator<(const PieceIdentity& one, const PieceIdentity& two);
44bool operator==(const PieceIdentity& one, const PieceIdentity& two);
45bool operator!=(const PieceIdentity& one, const PieceIdentity& two);
46
52class Piece {
53public:
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
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
135private:
140 State mState { State::UNLAUNCHED };
141
147
152 glm::u8vec2 mLocation {0, 0};
153};
154
155#endif
glm::u8vec2 getLocation() const
Gets the current location of this piece on the board.
Definition piece.hpp:107
State mState
The current (high level) state of this piece.
Definition piece.hpp:140
PieceIdentity getIdentity() const
Gets the identity of this piece, both its type and owner.
Definition piece.hpp:93
void setLocation(glm::u8vec2 location)
Sets the location of this piece on the board.
Definition piece.hpp:121
RoleID getOwner() const
Gets the owner of this piece, the set to which this piece belongs.
Definition piece.hpp:79
State getState() const
Gets the (high level) state of this piece.
Definition piece.hpp:100
void setState(State state)
Sets the (high level) state of this piece.
Definition piece.hpp:114
glm::u8vec2 mLocation
This piece's current location with respect to the game board.
Definition piece.hpp:152
State
A value representing the (high level) state of this piece.
Definition piece.hpp:58
bool canMove(uint8_t roll, RoleID player) const
Tests whether this piece can be moved at all.
Definition piece.cpp:4
PieceTypeID getType() const
Gets the type of piece this piece is.
Definition piece.hpp:86
PieceIdentity mIdentity
The unique identity of this piece.
Definition piece.hpp:146
Piece(PieceTypeID type, RoleID owner)
Constructs a new Piece.
Definition piece.hpp:70
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 enum listing the different types of pieces present in the game.
Contains an enum for the roles (sets of pieces) possible within this game.
Data uniquely identifying a piece used in the game.
Definition piece.hpp:29
RoleID mOwner
The set to which this piece belongs.
Definition piece.hpp:40
PieceTypeID mType
The type of the piece.
Definition piece.hpp:34