The representation of a single house on the Game of Ur Board, in other words a tile.
More...
#include <house.hpp>
|
enum | Type : uint8_t { REGULAR
, ROSETTE
} |
| The type of a house.
|
|
enum | Region : uint8_t { BATTLEFIELD
, BLACK =RoleID::BLACK
, WHITE =RoleID::WHITE
} |
| The region this house belongs to.
|
|
|
| House (glm::i8vec2 nextCell, Type houseType, Region region) |
| Constructs a new House.
|
|
void | move (std::shared_ptr< Piece > gamePiece) |
| Validates and applies a move, replacing the reference to the currently occupying piece with a new one.
|
|
std::weak_ptr< Piece > | getOccupantReference () |
| Gets a reference to the piece already occupying this house, if any.
|
|
PieceIdentity | getOccupant () const |
| Gets the identity of the piece occupying this house.
|
|
bool | isOccupied () const |
| Tests whether this house is already occupied by a game piece.
|
|
bool | isRosette () const |
| Tests whether this house is a rosette house.
|
|
Region | getRegion () const |
| Gets the region this house belongs to.
|
|
Type | getType () const |
| Gets which type of house this house is.
|
|
glm::i8vec2 | getNextCellDirection () const |
| Gets an integral vector pointing to the location of the next House, relative to this one.
|
|
bool | canMove (const Piece &gamePiece) const |
| Tests whether a given piece can move into this house.
|
|
|
glm::i8vec2 | mNextCell |
| Direction to the location of the next House, relative to this one.
|
|
Type | mType |
| The type of House this one is.
|
|
Region | mRegion |
| The region in which this House lies.
|
|
std::weak_ptr< Piece > | mOccupant {} |
| The piece occupying this house, if any.
|
|
The representation of a single house on the Game of Ur Board, in other words a tile.
Also stores a reference to the game piece presently occupying this house.
◆ House()
House::House |
( |
glm::i8vec2 | nextCell, |
|
|
Type | houseType, |
|
|
Region | region ) |
|
inline |
Constructs a new House.
- Parameters
-
nextCell | The direction to the next House relative to this one. |
houseType | The type of house this is. |
region | The region in which this house is present. |
◆ canMove()
bool House::canMove |
( |
const Piece & | gamePiece | ) |
const |
Tests whether a given piece can move into this house.
The conditions determining this are as follows:
- This house must be a region accessible by the piece's owner (i.e., their own region or the battlefield)
- This house must be unoccupied.
- If this house is occupied, then it must be a non-rosette house occupied by a piece belonging to an opponent.
In all other cases, the house can't be occupied by this piece.
- Parameters
-
gamePiece | The piece trying to occupy this house. |
- Return values
-
true | This piece may move into this house. |
false | This piece can't move into this house. |
- Todo
- We shouldn't need Piece here, just PieceIdentity should do.
◆ getNextCellDirection()
glm::i8vec2 House::getNextCellDirection |
( |
| ) |
const |
|
inline |
Gets an integral vector pointing to the location of the next House, relative to this one.
- Returns
- glm::i8vec2 A vector pointing in the direction of the next house from this one.
◆ getOccupant()
Gets the identity of the piece occupying this house.
- Returns
- PieceIdentity The ID of the piece occupying this house.
◆ getOccupantReference()
std::weak_ptr< Piece > House::getOccupantReference |
( |
| ) |
|
|
inline |
Gets a reference to the piece already occupying this house, if any.
- Returns
- std::weak_ptr<Piece> A reference to the piece occupying this house.
◆ getRegion()
Region House::getRegion |
( |
| ) |
const |
|
inline |
Gets the region this house belongs to.
- Returns
- Region The region this house belongs to.
◆ getType()
Type House::getType |
( |
| ) |
const |
|
inline |
Gets which type of house this house is.
- Returns
- Type This house's type.
◆ isOccupied()
bool House::isOccupied |
( |
| ) |
const |
|
inline |
Tests whether this house is already occupied by a game piece.
- Return values
-
true | There is a game piece on this house. |
false | There is no game piece on this house. |
◆ isRosette()
bool House::isRosette |
( |
| ) |
const |
|
inline |
Tests whether this house is a rosette house.
- Return values
-
true | This house is a rosette house. |
false | This house is not a rosette house. |
◆ move()
void House::move |
( |
std::shared_ptr< Piece > | gamePiece | ) |
|
Validates and applies a move, replacing the reference to the currently occupying piece with a new one.
Passing an empty pointer causes this house to lose its reference to its current occupant.
- Warning
- This method assumes that any higher level game logic checks were already performed before it was called.
- Parameters
-
gamePiece | The piece to now occupy this, or a nullptr if the piece here is to be moved. |
The documentation for this class was generated from the following files:
- src/app/game_of_ur_data/house.hpp
- src/app/game_of_ur_data/house.cpp