Wizard
Software Engineering Project - Wizard
Loading...
Searching...
No Matches
card Class Reference

Represents a card in the game. More...

#include <card.h>

Inheritance diagram for card:
unique_serializable serializable

Public Member Functions

 card (int value, int color)
 Constructs a new card object (public constructor).
 
 ~card () override
 Destructs a card object.
 
int get_value () const noexcept
 Gets the card's value.
 
int get_color () const noexcept
 Gets the card's color.
 
void write_into_json (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override
 Serializes a card object into a json object.
 
- Public Member Functions inherited from unique_serializable
std::string get_id () const
 
virtual void write_into_json (rapidjson::Value &json, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator) const override
 
- Public Member Functions inherited from serializable
virtual rapidjson::Document * to_json () const
 

Static Public Member Functions

static cardfrom_json (const rapidjson::Value &json)
 Deserializes a card object from a json object.
 

Additional Inherited Members

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

Detailed Description

Represents a card in the game.

This class encapsulates all information about a card, including its value and color.

Constructor & Destructor Documentation

◆ card()

card::card ( int value,
int color )

Constructs a new card object (public constructor).

Parameters
valueThe card's value.
colorThe card's color.

Member Function Documentation

◆ from_json()

card * card::from_json ( const rapidjson::Value & json)
static

Deserializes a card object from a json object.

Parameters
jsonThe json object containing the card information.
Returns
A pointer to a new card object created from the given json object.

◆ get_color()

int card::get_color ( ) const
nodiscardnoexcept

Gets the card's color.

Returns
The card's color.

◆ get_value()

int card::get_value ( ) const
nodiscardnoexcept

Gets the card's value.

Returns
The card's value.

◆ write_into_json()

void card::write_into_json ( rapidjson::Value & json,
rapidjson::Document::AllocatorType & allocator ) const
overridevirtual

Serializes a card object into a json object.

Parameters
jsonThe json object for serializing the card.
allocatorThe json allocator for serializing the card.

Implements serializable.


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