|
Eile Mit Weile
|
Abstract Base Class. Represents a space on the board. More...
#include <Space.hpp>
Public Member Functions | |
| Space (unsigned space_idx, std::vector< Figure * > figures=std::vector< Figure * >(0)) | |
| ~Space () | |
| virtual unsigned | GetTypeOfSpace () const |
| virtual unsigned | AddFigure (Figure *figure) |
| virtual Figure * | RemoveFigure (Figure *figure) |
| virtual std::vector< Figure * > | GetFigures () |
| unsigned | GetSpaceIdx () const |
| virtual bool | IsBlocked () const |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
Public Member Functions inherited from UniqueSerializable | |
| std::string | GetId () const |
| void | WriteIntoJson (rapidjson::Value &json, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator) const override |
Public Member Functions inherited from Serializable | |
| virtual rapidjson::Document * | ToJson () const |
Protected Member Functions | |
| Space (std::string id, unsigned space_idx, std::vector< Figure * > figures) | |
Protected Member Functions inherited from UniqueSerializable | |
| UniqueSerializable () | |
| UniqueSerializable (std::string id) | |
Protected Attributes | |
| std::vector< Figure * > | _figures |
| unsigned | _space_idx |
Protected Attributes inherited from UniqueSerializable | |
| std::string | id |
Abstract Base Class. Represents a space on the board.
A space is identified by its index. The index is used to determine which space a Figure is to be moved to. The convention for space indices is found in Board.
Special spaces are derived from this class. They are identifiable by an integer returned by GetTypeOfSpace().
However, for some spaces, their _space_idx is fixed and thus we don't need to use GetTypeOfSpace() to identify them. For normal spaces there's also no need for identification as they do not have any special behaviour.
For the sake of completeness GetTypeOfSpace() is implemented for all Space derivatives regardless.
Here's a list of the integer values returned by GetTypeOfSpace() for each space type:
|
explicit |
Constructor: creates a Space with a space index (_space_idx)
| Space::~Space | ( | ) |
Destructor: deletes all Figures on the Space
|
explicitprotected |
Deserialization constructor used by FromJson (only defined in derivatives)
Adds a Figure to the space. Returns the amount of figures on the space.
Reimplemented in BenchSpace, and HomeField.
| unsigned Space::GetSpaceIdx | ( | ) | const |
Getter for _space_idx
|
virtual |
Returns the type of the space. Derivatives (e.g. BenchSpace) override this function.
Reimplemented in BenchSpace, FinishArea, HomeField, LadderSpace, and NormalSpace.
|
virtual |
Indicates whether the space is blocked by two figures of the same player. For all space types except BenchSpace this is always false.
Reimplemented in BenchSpace.
Removes a Figure from the space and returns its pointer.
Reimplemented in BenchSpace.
|
overridevirtual |
Serializes a Space object into a json object. Used by server.
Implements Serializable.
|
protected |
The Figures on the space. Used as a push/pop list.
|
protected |
Denotes the index of the space. See Board for which index represents which space.