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

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

#include <LadderSpace.hpp>

Inheritance diagram for LadderSpace:
Space UniqueSerializable Serializable

Public Member Functions

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

Private Member Functions

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

Private Attributes

Color _color
 

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 ladder space on the board.

On ladder spaces, figures are safe from being kicked back to home by getting a 6 from a dice roll 3 times in a row. A figure only enters the ladder space if its color corresponds to the color of the ladder space (_color).

Constructor & Destructor Documentation

◆ LadderSpace() [1/2]

LadderSpace::LadderSpace ( unsigned  space_idx,
int  color 
)

Constructor: creates a LadderSpace with a space index and a color (_color)

◆ LadderSpace() [2/2]

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

Deserialization constructor used by FromJson

Member Function Documentation

◆ FromJson()

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

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

◆ GetColor()

Color LadderSpace::GetColor ( ) const

Getter for _color

◆ GetTypeOfSpace()

unsigned LadderSpace::GetTypeOfSpace ( ) const
overridevirtual

Returns the type of the space. For ladder spaces this is 4.

Reimplemented from Space.

◆ WriteIntoJson()

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

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

Implements Serializable.

Member Data Documentation

◆ _color

Color LadderSpace::_color
private

The Color of the ladder space. Used to identify the player that owns the ladder space.


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