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

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

#include <BenchSpace.hpp>

Inheritance diagram for BenchSpace:
Space UniqueSerializable Serializable

Public Member Functions

 BenchSpace (unsigned space_idx)
 
void SetBlock ()
 
void FreeBlock ()
 
bool IsBlocked () const override
 
unsigned int AddFigure (Figure *figure) override
 
FigureRemoveFigure (Figure *figure) override
 
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 std::vector< Figure * > GetFigures ()
 
unsigned GetSpaceIdx () 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 BenchSpaceFromJson (const rapidjson::Value &json)
 

Private Member Functions

 BenchSpace (std::string id, unsigned space_idx, std::vector< Figure * > figures, bool is_blocked)
 

Private Attributes

bool _is_blocked
 

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

On bench spaces, figures are safe from being kicked back to home by other players. Furthermore, if two figures of the same player are on the same bench space, they block all other figures of all players from moving to that space (Note this makes any dice roll that would place a figure beyond that bench space unplayable. See Board::ComputePlayableFigures).

Constructor & Destructor Documentation

◆ BenchSpace() [1/2]

BenchSpace::BenchSpace ( unsigned  space_idx)
explicit

Constructor: creates a BenchSpace with a space index (Space::_space_idx)

◆ BenchSpace() [2/2]

BenchSpace::BenchSpace ( std::string  id,
unsigned  space_idx,
std::vector< Figure * >  figures,
bool  is_blocked 
)
private

Deserialization constructor used by FromJson (only defined in derivatives)

Member Function Documentation

◆ AddFigure()

unsigned int BenchSpace::AddFigure ( Figure figure)
overridevirtual

Adds a Figure to the space. If the space is blocked, the figure is not added.
Returns the amount of figures on the space.

Reimplemented from Space.

◆ FreeBlock()

void BenchSpace::FreeBlock ( )

Sets the bench space to unblocked (_is_blocked == false).

◆ FromJson()

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

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

◆ GetTypeOfSpace()

unsigned BenchSpace::GetTypeOfSpace ( ) const
overridevirtual

Returns the type of the space. For bench spaces this is 1.

Reimplemented from Space.

◆ IsBlocked()

bool BenchSpace::IsBlocked ( ) const
overridevirtual

Indicates whether the bench space is blocked by two figures of the same player

Reimplemented from Space.

◆ RemoveFigure()

Figure * BenchSpace::RemoveFigure ( Figure figure)
overridevirtual

Removes a Figure from the space and returns its pointer. Also checks if this unblocks the space.

Reimplemented from Space.

◆ SetBlock()

void BenchSpace::SetBlock ( )

Sets the bench space to blocked (_is_blocked == true).

◆ WriteIntoJson()

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

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

Implements Serializable.

Member Data Documentation

◆ _is_blocked

bool BenchSpace::_is_blocked
private

Indicates whether the bench space is blocked by two figures of the same player


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