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

Represents a figure on the board. More...

#include <Figure.hpp>

Inheritance diagram for Figure:
UniqueSerializable Serializable

Public Member Functions

 Figure (unsigned color, int figure_idx)
 
Color GetColor ()
 
int GetFigureIdx () const
 
int GetColorIdx () 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 FigureFromJson (const rapidjson::Value &json)
 

Private Member Functions

 Figure (std::string id, unsigned color_idx, int figure_idx)
 

Private Attributes

Color _color
 
unsigned _color_idx
 
int _figure_idx
 

Additional Inherited Members

- Protected Member Functions inherited from UniqueSerializable
 UniqueSerializable ()
 
 UniqueSerializable (std::string id)
 
- Protected Attributes inherited from UniqueSerializable
std::string id
 

Detailed Description

Represents a figure on the board.

A figure is identified by its color and its index. The index is used to determine which figure of the current player is to be moved.

Constructor & Destructor Documentation

◆ Figure() [1/2]

Figure::Figure ( unsigned  color,
int  figure_idx 
)

Constructor: creates a Figure with a Color and an id (_figure_idx).

◆ Figure() [2/2]

Figure::Figure ( std::string  id,
unsigned  color_idx,
int  figure_idx 
)
private

Deserialization constructor used by FromJson

Member Function Documentation

◆ FromJson()

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

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

◆ GetColor()

Color Figure::GetColor ( )

Getter for _color

◆ GetColorIdx()

int Figure::GetColorIdx ( ) const

Getter for _color_idx

◆ GetFigureIdx()

int Figure::GetFigureIdx ( ) const

Getter for _figure_idx

◆ WriteIntoJson()

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

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

Implements Serializable.

Member Data Documentation

◆ _color

Color Figure::_color
private

The Color of the Figure

◆ _color_idx

unsigned Figure::_color_idx
private

Corresponds to the enum integer value of the Color of the Figure

◆ _figure_idx

int Figure::_figure_idx
private

Value from 0 to 3 makes the Player's 4 figures uniquely identifiable


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