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
house.hpp
Go to the documentation of this file.
1
11
12#ifndef ZOAPPHOUSE_H
13#define ZOAPPHOUSE_H
14
15#include <memory>
16
17#include <glm/glm.hpp>
18
19#include "piece.hpp"
20
21
29class House {
30public:
35 enum Type: uint8_t {
36 REGULAR, //< A regular house, with no special rules.
37 ROSETTE, //< A rosette house, granting its occupant special immunity, and deciding whether counters are won, lost, or neither, by the active player during GamePhase::PLAY.
38 };
39
44 enum Region: uint8_t {
45 BATTLEFIELD, //< A tile that can be occupied by either player, and making up the main part of the route they compete over.
46 BLACK=RoleID::BLACK, //< A small region only usable by the player playing black.
47 WHITE=RoleID::WHITE, //< A small region only usable by the player playing white.
48 };
49
57 House(glm::i8vec2 nextCell, Type houseType, Region region):
58 mNextCell { nextCell },
59 mType { houseType },
60 mRegion { region }
61 {}
62
72 void move(std::shared_ptr<Piece> gamePiece);
73
79 std::weak_ptr<Piece> getOccupantReference() { return mOccupant; }
80
87
94 bool isOccupied() const { return !mOccupant.expired(); }
95
102 bool isRosette() const { return mType == Type::ROSETTE; };
103
109 Region getRegion() const { return mRegion; }
110
116 Type getType() const { return mType; }
117
123 glm::i8vec2 getNextCellDirection() const { return mNextCell; }
124
146 bool canMove(const Piece& gamePiece) const;
147
148private:
153 glm::i8vec2 mNextCell;
154
160
166
171 std::weak_ptr<Piece> mOccupant {};
172};
173
174#endif
glm::i8vec2 getNextCellDirection() const
Gets an integral vector pointing to the location of the next House, relative to this one.
Definition house.hpp:123
glm::i8vec2 mNextCell
Direction to the location of the next House, relative to this one.
Definition house.hpp:153
bool canMove(const Piece &gamePiece) const
Tests whether a given piece can move into this house.
Definition house.cpp:3
Type mType
The type of House this one is.
Definition house.hpp:159
Type getType() const
Gets which type of house this house is.
Definition house.hpp:116
Type
The type of a house.
Definition house.hpp:35
Region
The region this house belongs to.
Definition house.hpp:44
bool isOccupied() const
Tests whether this house is already occupied by a game piece.
Definition house.hpp:94
bool isRosette() const
Tests whether this house is a rosette house.
Definition house.hpp:102
Region mRegion
The region in which this House lies.
Definition house.hpp:165
House(glm::i8vec2 nextCell, Type houseType, Region region)
Constructs a new House.
Definition house.hpp:57
void move(std::shared_ptr< Piece > gamePiece)
Validates and applies a move, replacing the reference to the currently occupying piece with a new one...
Definition house.cpp:28
std::weak_ptr< Piece > mOccupant
The piece occupying this house, if any.
Definition house.hpp:171
PieceIdentity getOccupant() const
Gets the identity of the piece occupying this house.
Definition house.cpp:39
Region getRegion() const
Gets the region this house belongs to.
Definition house.hpp:109
std::weak_ptr< Piece > getOccupantReference()
Gets a reference to the piece already occupying this house, if any.
Definition house.hpp:79
The state of a single piece of the game.
Definition piece.hpp:52
Contains definitions for pieces belonging to different sets used by competing players.
Data uniquely identifying a piece used in the game.
Definition piece.hpp:29