MiniGame-Madness
Public Member Functions | Public Attributes | List of all members
ChessSquare Struct Reference

A struct that represents a chess square. More...

#include <Chess.h>

Public Member Functions

 ChessSquare (SquareColour squareColour)
 Default constructor for ChessSquare. More...
 
 ChessSquare (PieceType type, PlayerColour playerColour, SquareColour squareColour)
 Constructor for ChessSquare. More...
 
void addNeighbor (ChessSquare *square, Direction direction)
 Add a neighboring square with a direction. More...
 
bool removeNeighbor (Direction direction)
 Remove a neighboring square with a direction. More...
 
ChessSquaregetNeighbor (Direction direction) const
 Get the neighboring square in a given direction. More...
 
std::map< Direction, ChessSquare * > getNeighbors () const
 Get all neighboring squares. More...
 
PieceType getPieceType () const
 Get the piece type of the square. More...
 
bool setPieceType (PieceType type)
 Set the piece type of the square. More...
 
PlayerColour getPlayerColour () const
 Get the player color of the square. More...
 
bool setPlayerColour (PlayerColour playerColour)
 Set the player color of the square. More...
 
SquareColour getSquareColour () const
 Get the square colour of the square. More...
 

Public Attributes

PieceType type
 
PlayerColour playerColour
 
SquareColour squareColour
 
std::map< Direction, ChessSquare * > neighbors
 

Detailed Description

A struct that represents a chess square.

This struct contains the type of the piece and the color of the player that owns the piece as well as colour of the square.

The default type is EMPTY and the default player color is BLANK reprasenting an emptry square.

Constructor & Destructor Documentation

◆ ChessSquare() [1/2]

ChessSquare::ChessSquare ( SquareColour  squareColour)
inline

Default constructor for ChessSquare.

Initializes the ChessSquare with an EMPTY type, a BLANK player color.

Parameters
squareColourThe Colour of the square.

◆ ChessSquare() [2/2]

ChessSquare::ChessSquare ( PieceType  type,
PlayerColour  playerColour,
SquareColour  squareColour 
)
inline

Constructor for ChessSquare.

Initializes the ChessSquare with the given type, player color, and square colour.

Parameters
typeThe type of the piece.
playerColourThe color of the player that owns the piece.
squareColourThe color of the square.

Member Function Documentation

◆ addNeighbor()

void ChessSquare::addNeighbor ( ChessSquare square,
Direction  direction 
)
inline

Add a neighboring square with a direction.

Parameters
square- The square to add as a neighbor.
direction- The direction of the neighboring square.

◆ getNeighbor()

ChessSquare* ChessSquare::getNeighbor ( Direction  direction) const
inline

Get the neighboring square in a given direction.

Parameters
direction- The direction of the neighboring square.
Returns
The neighboring square in the given direction.

◆ getNeighbors()

std::map<Direction, ChessSquare*> ChessSquare::getNeighbors ( ) const
inline

Get all neighboring squares.

Returns
A map of directions to neighboring squares.

◆ getPieceType()

PieceType ChessSquare::getPieceType ( ) const
inline

Get the piece type of the square.

Returns
The piece type of the square.

◆ getPlayerColour()

PlayerColour ChessSquare::getPlayerColour ( ) const
inline

Get the player color of the square.

Returns
The player color of the square.

◆ getSquareColour()

SquareColour ChessSquare::getSquareColour ( ) const
inline

Get the square colour of the square.

Returns
The square colour of the square.

◆ removeNeighbor()

bool ChessSquare::removeNeighbor ( Direction  direction)
inline

Remove a neighboring square with a direction.

Parameters
direction- The direction of the neighboring square.

◆ setPieceType()

bool ChessSquare::setPieceType ( PieceType  type)
inline

Set the piece type of the square.

Parameters
type- The piece type to set.
Returns
True if the piece type was set successfully, false otherwise.

◆ setPlayerColour()

bool ChessSquare::setPlayerColour ( PlayerColour  playerColour)
inline

Set the player color of the square.

Parameters
playerColour- The player color to set.
Returns
True if the player color was set successfully, false otherwise.

Member Data Documentation

◆ neighbors

std::map<Direction, ChessSquare*> ChessSquare::neighbors

A map of directions to neighboring squares.

◆ playerColour

PlayerColour ChessSquare::playerColour

The color of the player that owns the piece.

◆ squareColour

SquareColour ChessSquare::squareColour

The color of the square.

◆ type

PieceType ChessSquare::type

The type of the piece.


The documentation for this struct was generated from the following file: