Eile Mit Weile
Loading...
Searching...
No Matches
HomeField Class Reference

Represents a home space on the board. More...

#include <HomeField.hpp>

Inheritance diagram for HomeField:
Space UniqueSerializable Serializable

Public Member Functions

 HomeField (unsigned int space_idx, unsigned color_idx)
 
unsigned int GetColorIdx () const
 
unsigned int GetTypeOfSpace () const override
 
void WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override
 
unsigned AddFigure (Figure *figure) override
 
- Public Member Functions inherited from Space
 Space (unsigned space_idx, std::vector< Figure * > figures=std::vector< Figure * >(0))
 
 ~Space ()
 
virtual FigureRemoveFigure (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::DocumentToJson () const
 

Static Public Member Functions

static HomeFieldFromJson (const rapidjson::Value &json)
 

Private Member Functions

 HomeField (std::string id, unsigned int space_idx, unsigned int color_idx, std::vector< Figure * > figures)
 

Private Attributes

unsigned _color_idx
 

Additional Inherited Members

- Protected Member Functions inherited from Space
 Space (std::string id, unsigned space_idx, std::vector< Figure * > figures)
 
- Protected Member Functions inherited from UniqueSerializable
 UniqueSerializable ()
 
 UniqueSerializable (std::string id)
 
- Protected Attributes inherited from Space
std::vector< Figure * > _figures
 
unsigned _space_idx
 
- Protected Attributes inherited from UniqueSerializable
std::string id
 

Detailed Description

Represents a home space on the board.

The home field is the space where figures are moved to when they are kicked back to home and where they are placed at the start of the game.

Constructor & Destructor Documentation

◆ HomeField() [1/2]

HomeField::HomeField ( unsigned int  space_idx,
unsigned  color_idx 
)

Constructor: creates a HomeField with a space index (_space_idx) and a color id (_color_idx)

◆ HomeField() [2/2]

HomeField::HomeField ( std::string  id,
unsigned int  space_idx,
unsigned int  color_idx,
std::vector< Figure * >  figures 
)
private

Deserialization constructor used by FromJson

Member Function Documentation

◆ AddFigure()

unsigned int HomeField::AddFigure ( Figure figure)
overridevirtual

Adds a Figure to the space. Returns the amount of figures on the space. Throws an exception if a figure is added to a full HomeSpace

Reimplemented from Space.

◆ FromJson()

HomeField * HomeField::FromJson ( const rapidjson::Value json)
static

Deserializes a HomeField object from a json object. Used by client.

◆ GetColorIdx()

unsigned int HomeField::GetColorIdx ( ) const

Getter for _color_idx. Currently unused as the space index is sufficient for identification of color

◆ GetTypeOfSpace()

unsigned int HomeField::GetTypeOfSpace ( ) const
overridevirtual

Returns the type of the space. For home fields this is 2. Currently never used as home fields are identifiably by space index.

Reimplemented from Space.

◆ WriteIntoJson()

void HomeField::WriteIntoJson ( rapidjson::Value json,
rapidjson::Document::AllocatorType &  allocator 
) const
overridevirtual

Serializes a HomeField object into a json object. Used by server.

Implements Serializable.

Member Data Documentation

◆ _color_idx

unsigned HomeField::_color_idx
private

The color id of the home field. Used to identify the player that owns the home field.


The documentation for this class was generated from the following files: