Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sista::Field Class Reference

Represents a 2D grid where Pawns can be placed, moved, and managed. More...

#include <field.hpp>

Inheritance diagram for sista::Field:
Inheritance graph
[legend]
Collaboration diagram for sista::Field:
Collaboration graph
[legend]

Public Member Functions

void clear ()
 Clears the field by removing all Pawns and resetting the grid.
 
 Field (int, int)
 Constructor to initialize the field with specified width and height.
 
 ~Field ()
 Destructor to clean up resources.
 
void print () const
 Prints the entire field to the terminal.
 
void print (char) const
 Prints the entire field to the terminal.
 
void print (Border &) const
 Prints the entire field to the terminal.
 
virtual void addPawn (std::shared_ptr< Pawn >)
 Adds a Pawn to the field at its specified coordinates.
 
virtual void removePawn (Pawn *)
 Removes a Pawn from the field.
 
virtual void removePawn (const Coordinates &)
 Removes a Pawn from the field at specified coordinates.
 
virtual void erasePawn (Pawn *)
 Removes a Pawn from the field at specified coordinates.
 
virtual void erasePawn (const Coordinates &)
 Removes a Pawn from the field at specified coordinates.
 
void addPrintPawn (std::shared_ptr< Pawn >)
 Adds a Pawn to the field at its specified coordinates and prints it.
 
void rePrintPawn (Pawn *)
 Reprints a Pawn at its current coordinates.
 
void movePawn (Pawn *, const Coordinates &)
 Moves a Pawn to new coordinates.
 
void movePawn (Pawn *, unsigned short, unsigned short)
 Moves a Pawn to new coordinates.
 
void movePawnBy (Pawn *, const Coordinates &)
 Moves a Pawn by a relative offset.
 
void movePawnBy (Pawn *, unsigned short, unsigned short)
 Moves a Pawn by a relative offset.
 
void movePawnBy (Pawn *, const Coordinates &, Effect)
 Moves a Pawn by a relative offset with specified effect on out-of-bounds coordinates.
 
void movePawnBy (Pawn *, short int, short int, Effect)
 Moves a Pawn by a relative offset with specified effect on out-of-bounds coordinates.
 
void movePawnFromTo (const Coordinates &, const Coordinates &)
 Moves a Pawn from one set of coordinates to another.
 
void movePawnFromTo (unsigned short, unsigned short, unsigned short, unsigned short)
 Moves a Pawn from one set of coordinates to another.
 
Coordinates movingByCoordinates (Pawn *, short int, short int) const
 Calculates the new coordinates of a Pawn after moving by a relative offset.
 
Coordinates movingByCoordinates (Pawn *, short int, short int, Effect) const
 Calculates the new coordinates of a Pawn after moving by a relative offset with specified effect on out-of-bounds coordinates.
 
PawngetPawn (const Coordinates &) const
 Gets the Pawn at specified coordinates.
 
PawngetPawn (unsigned short, unsigned short) const
 Gets the Pawn at specified coordinates.
 
bool isOccupied (const Coordinates &) const
 Checks if specified coordinates are occupied by a Pawn.
 
bool isOccupied (unsigned short, unsigned short) const
 Checks if specified coordinates are occupied by a Pawn.
 
bool isOccupied (short int, short int) const
 Checks if specified coordinates are occupied by a Pawn.
 
bool isOutOfBounds (const Coordinates &) const
 Checks if specified coordinates are out of bounds.
 
bool isOutOfBounds (unsigned short, unsigned short) const
 Checks if specified coordinates are out of bounds.
 
bool isOutOfBounds (short int, short int) const
 Checks if specified coordinates are out of bounds.
 
bool isFree (const Coordinates &) const
 Checks if specified coordinates are free (not occupied by a Pawn).
 
bool isFree (unsigned short, unsigned short) const
 Checks if specified coordinates are free (not occupied by a Pawn).
 
bool isFree (short int, short int) const
 Checks if specified coordinates are free (not occupied by a Pawn).
 
void validateCoordinates (const Coordinates &) const
 Validates that the given coordinates are within bounds and not occupied.
 
void validateCoordinates (unsigned short, unsigned short) const
 Validates that the given coordinates are within bounds and not occupied.
 

Protected Member Functions

void cleanCoordinates (const Coordinates &) const
 Cleans the coordinates on screen by printing spaces.
 
void cleanCoordinates (unsigned short, unsigned short) const
 Cleans the coordinates on screen by printing spaces.
 

Protected Attributes

std::vector< std::vector< std::shared_ptr< Pawn > > > pawns
 2D grid of shared pointers to Pawn objects.
 
Cursor cursor
 
int width
 
int height
 

Detailed Description

Represents a 2D grid where Pawns can be placed, moved, and managed.

The Field class encapsulates a 2D grid structure using a vector of vectors to hold shared pointers to Pawn objects. It provides methods to add, remove, move, and print Pawns on the field. The class also includes functionality to check if specific coordinates are occupied, free, or out of bounds, and to validate coordinates.

The Field class is designed to be extended for more specialized behavior, such as in the SwappableField subclass, which handles scenarios where multiple Pawns may need to swap positions without conflicts.

See also
Pawn
Coordinates
Border
Cursor
SwappableField

Constructor & Destructor Documentation

◆ Field()

sista::Field::Field ( int  width_,
int  height_ 
)

Constructor to initialize the field with specified width and height.

Parameters
width_The width of the field (number of columns).
height_The height of the field (number of rows).

This constructor initializes a Field object with the given dimensions. It sets up a 2D grid (vector of vectors) to hold shared pointers to Pawn objects, and initializes the Cursor for terminal operations.

See also
Cursor

◆ ~Field()

sista::Field::~Field ( )

Destructor to clean up resources.

Member Function Documentation

◆ addPawn()

void sista::Field::addPawn ( std::shared_ptr< Pawn pawn)
virtual

Adds a Pawn to the field at its specified coordinates.

Parameters
pawnA shared pointer to the Pawn to add.

This method places the given Pawn on the field at its current coordinates. If the coordinates are already occupied, the existing Pawn will be replaced.

Warning
The Pawn's coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method takes a shared pointer to manage the Pawn's memory automatically.
See also
Pawn

Reimplemented in sista::SwappableField.

◆ addPrintPawn()

void sista::Field::addPrintPawn ( std::shared_ptr< Pawn pawn)

Adds a Pawn to the field at its specified coordinates and prints it.

Parameters
pawnA shared pointer to the Pawn to add and print.

This method places the given Pawn on the field at its current coordinates and prints it to the terminal. If the coordinates are already occupied, the existing Pawn will be replaced.

Warning
The Pawn's coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method takes a shared pointer to manage the Pawn's memory automatically.
See also
Pawn

◆ cleanCoordinates() [1/2]

void sista::Field::cleanCoordinates ( const Coordinates coordinates) const
protected

Cleans the coordinates on screen by printing spaces.

Height of the matrix

Parameters
coordinatesThe Coordinates to clean.

◆ cleanCoordinates() [2/2]

void sista::Field::cleanCoordinates ( unsigned short  y,
unsigned short  x 
) const
protected

Cleans the coordinates on screen by printing spaces.

Parameters
yThe y coordinate (row).
xThe x coordinate (column).

◆ clear()

void sista::Field::clear ( )

Clears the field by removing all Pawns and resetting the grid.

Note
This does not delete the Pawn objects, it only removes them from the field.

◆ erasePawn() [1/2]

void sista::Field::erasePawn ( const Coordinates coordinates)
virtual

Removes a Pawn from the field at specified coordinates.

Parameters
coordinatesThe Coordinates of the Pawn to remove.

This method removes the Pawn located at the given coordinates from the field. Unlike removePawn, this method also cleans the cell on the terminal by printing a space.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method does not delete the Pawn object, it only removes it from the field.
See also
Pawn

◆ erasePawn() [2/2]

void sista::Field::erasePawn ( Pawn pawn)
virtual

Removes a Pawn from the field at specified coordinates.

Parameters
pawnA pointer to the Pawn to remove.

This method removes the given Pawn from the field. Unlike removePawn, this method also cleans the cell on the terminal by printing a space.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method does not delete the Pawn object, it only removes it from the field.
See also
Pawn

◆ getPawn() [1/2]

Pawn * sista::Field::getPawn ( const Coordinates coordinates) const

Gets the Pawn at specified coordinates.

Parameters
coordinatesThe Coordinates to get the Pawn from.
Returns
A pointer to the Pawn at the given coordinates, or nullptr if no Pawn is found.

This method retrieves the Pawn located at the specified coordinates on the field. If no Pawn is found at those coordinates, the method returns nullptr.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method returns a raw pointer to the Pawn that is managed by a shared pointer in the field and thus must not be deleted.
See also
Pawn
Coordinates

◆ getPawn() [2/2]

Pawn * sista::Field::getPawn ( unsigned short  y,
unsigned short  x 
) const

Gets the Pawn at specified coordinates.

Parameters
yThe y coordinate (row) to get the Pawn from.
xThe x coordinate (column) to get the Pawn from.
Returns
A pointer to the Pawn at the given coordinates, or nullptr if no Pawn is found.

This method retrieves the Pawn located at the specified coordinates on the field. If no Pawn is found at those coordinates, the method returns nullptr.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method returns a raw pointer to the Pawn that is managed by a shared pointer in the field and thus must not be deleted.
See also
Pawn
Coordinates

◆ isFree() [1/3]

bool sista::Field::isFree ( const Coordinates coordinates) const

Checks if specified coordinates are free (not occupied by a Pawn).

Parameters
coordinatesThe Coordinates to check.
Returns
true if the coordinates are free, false otherwise.

This method checks if there is no Pawn located at the specified coordinates on the field.

Note
This is a negation of isOccupied provided that isOutOfBounds returns false. Read implementation for more details.
See also
Pawn
Coordinates
isOccupied
isOutOfBounds

◆ isFree() [2/3]

bool sista::Field::isFree ( short int  y,
short int  x 
) const

Checks if specified coordinates are free (not occupied by a Pawn).

Parameters
yThe y coordinate (row) to check.
xThe x coordinate (column) to check.
Returns
true if the coordinates are free, false otherwise.

This method checks if there is no Pawn located at the specified coordinates on the field.

Note
This overload uses signed integers to allow checking for negative coordinates.
This is a negation of isOccupied provided that isOutOfBounds returns false. Read implementation for more details.
See also
Pawn
Coordinates
isOccupied
isOutOfBounds

◆ isFree() [3/3]

bool sista::Field::isFree ( unsigned short  y,
unsigned short  x 
) const

Checks if specified coordinates are free (not occupied by a Pawn).

Parameters
yThe y coordinate (row) to check.
xThe x coordinate (column) to check.
Returns
true if the coordinates are free, false otherwise.

This method checks if there is no Pawn located at the specified coordinates on the field.

Note
This is a negation of isOccupied provided that isOutOfBounds returns false. Read implementation for more details.
See also
Pawn
Coordinates
isOccupied
isOutOfBounds

◆ isOccupied() [1/3]

bool sista::Field::isOccupied ( const Coordinates coordinates) const

Checks if specified coordinates are occupied by a Pawn.

Parameters
coordinatesThe Coordinates to check.
Returns
true if the coordinates are occupied, false otherwise.

This method checks if there is a Pawn located at the specified coordinates on the field.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here
See also
Pawn
Coordinates
isFree
isOutOfBounds

◆ isOccupied() [2/3]

bool sista::Field::isOccupied ( short int  y,
short int  x 
) const

Checks if specified coordinates are occupied by a Pawn.

Parameters
yThe y coordinate (row) to check.
xThe x coordinate (column) to check.
Returns
true if the coordinates are occupied, false otherwise.

This method checks if there is a Pawn located at the specified coordinates on the field.

Note
This overload uses signed integers to allow checking for negative coordinates.
Warning
The coordinates must be valid (within the field bounds) as they are not validated here
See also
Pawn
Coordinates
isFree
isOutOfBounds

◆ isOccupied() [3/3]

bool sista::Field::isOccupied ( unsigned short  y,
unsigned short  x 
) const

Checks if specified coordinates are occupied by a Pawn.

Parameters
yThe y coordinate (row) to check.
xThe x coordinate (column) to check.
Returns
true if the coordinates are occupied, false otherwise.

This method checks if there is a Pawn located at the specified coordinates on the field.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here
See also
Pawn
Coordinates
isFree
isOutOfBounds

◆ isOutOfBounds() [1/3]

bool sista::Field::isOutOfBounds ( const Coordinates coordinates) const

Checks if specified coordinates are out of bounds.

Parameters
coordinatesThe Coordinates to check.
Returns
true if the coordinates are out of bounds, false otherwise.

This method checks if the given coordinates are outside the valid range of the field.

See also
Coordinates
isOccupied
isFree

◆ isOutOfBounds() [2/3]

bool sista::Field::isOutOfBounds ( short int  y,
short int  x 
) const

Checks if specified coordinates are out of bounds.

Parameters
yThe y coordinate (row) to check.
xThe x coordinate (column) to check.
Returns
true if the coordinates are out of bounds, false otherwise.

This method checks if the given coordinates are outside the valid range of the field.

Note
This overload uses signed integers to allow checking for negative coordinates.
See also
Coordinates
isOccupied
isFree

◆ isOutOfBounds() [3/3]

bool sista::Field::isOutOfBounds ( unsigned short  y,
unsigned short  x 
) const

Checks if specified coordinates are out of bounds.

Parameters
yThe y coordinate (row) to check.
xThe x coordinate (column) to check.
Returns
true if the coordinates are out of bounds, false otherwise.

This method checks if the given coordinates are outside the valid range of the field.

See also
Coordinates
isOccupied
isFree

◆ movePawn() [1/2]

void sista::Field::movePawn ( Pawn pawn,
const Coordinates coordinates 
)

Moves a Pawn to new coordinates.

Parameters
pawnA pointer to the Pawn to move.
coordinatesThe new Coordinates to move the Pawn to.

This method moves the specified Pawn to the given coordinates on the field. If the target coordinates are already occupied, the existing Pawn will be replaced.

Exceptions
`std::invalid_argument`if the coordinates are occupied by another Pawn or out of bounds.
See also
Pawn
Coordinates
validateCoordinates

◆ movePawn() [2/2]

void sista::Field::movePawn ( Pawn pawn,
unsigned short  y,
unsigned short  x 
)

Moves a Pawn to new coordinates.

Parameters
pawnA pointer to the Pawn to move.
yThe new y coordinate (row) to move the Pawn to.
xThe new x coordinate (column) to move the Pawn to.

This method moves the specified Pawn to the given coordinates on the field. If the target coordinates are already occupied, the existing Pawn will be replaced.

Exceptions
`std::invalid_argument`if the coordinates are occupied by another Pawn or out of bounds.
Note
This method is just a convenience overload that constructs a Coordinates object internally.
See also
Pawn
Coordinates
validateCoordinates

◆ movePawnBy() [1/4]

void sista::Field::movePawnBy ( Pawn pawn,
const Coordinates coordinates 
)

Moves a Pawn by a relative offset.

Parameters
pawnA pointer to the Pawn to move.
coordinatesThe relative Coordinates to move the Pawn by.

This method moves the specified Pawn by the given relative offset.

Exceptions
`std::invalid_argument`if the resulting coordinates are occupied by another Pawn or out of bounds.
Note
This method is just a convenience overload that constructs a Coordinates object internally and then calls movePawn.
See also
Pawn
Coordinates
validateCoordinates

◆ movePawnBy() [2/4]

void sista::Field::movePawnBy ( Pawn pawn,
const Coordinates coordinates,
Effect  effect 
)

Moves a Pawn by a relative offset with specified effect on out-of-bounds coordinates.

Parameters
pawnA pointer to the Pawn to move.
coordinatesThe relative Coordinates to move the Pawn by.
effectThe Effect to apply when the resulting coordinates are out of bounds.

This method moves the specified Pawn by the given relative offset, applying the specified effect if the resulting coordinates go out of bounds.

Exceptions
`std::invalid_argument`if the resulting coordinates are occupied by another Pawn after applying the effect.
`std::out_of_range`if the effect is MATRIX and the resulting coordinates are out of bounds.
Note
This method is just a convenience overload that deconstructs a Coordinates object internally and then calls movePawnBy(y,x).
See also
Pawn
Coordinates
Effect
validateCoordinates

◆ movePawnBy() [3/4]

void sista::Field::movePawnBy ( Pawn pawn,
short int  y,
short int  x,
Effect  effect 
)

Moves a Pawn by a relative offset with specified effect on out-of-bounds coordinates.

Parameters
pawnA pointer to the Pawn to move.
yThe relative y offset (rows) to move the Pawn by.
xThe relative x offset (columns) to move the Pawn by.
effectThe Effect to apply when the resulting coordinates are out of bounds.

This method moves the specified Pawn by the given relative offset, applying the specified effect if the resulting coordinates go out of bounds.

Exceptions
`std::invalid_argument`if the resulting coordinates are occupied by another Pawn after applying the effect.
`std::out_of_range`if the effect is MATRIX and the resulting coordinates are out of bounds.
See also
Pawn
Coordinates
Effect
validateCoordinates

◆ movePawnBy() [4/4]

void sista::Field::movePawnBy ( Pawn pawn,
unsigned short  y,
unsigned short  x 
)

Moves a Pawn by a relative offset.

Parameters
pawnA pointer to the Pawn to move.
yThe relative y offset (rows) to move the Pawn by.
xThe relative x offset (columns) to move the Pawn by.

This method moves the specified Pawn by the given relative offset.

Exceptions
`std::invalid_argument`if the resulting coordinates are occupied by another Pawn or out of bounds.
Note
This method is just a convenience overload that constructs a Coordinates object internally and then calls movePawn.
See also
Pawn
Coordinates
validateCoordinates

◆ movePawnFromTo() [1/2]

void sista::Field::movePawnFromTo ( const Coordinates coordinates,
const Coordinates newCoordinates 
)

Moves a Pawn from one set of coordinates to another.

Parameters
coordinatesThe current Coordinates of the Pawn.
newCoordinatesThe new Coordinates to move the Pawn to.

This method finds the Pawn at the specified current coordinates and moves it to the new coordinates.

Exceptions
`std::invalid_argument`if there is no Pawn at the current coordinates or if the new coordinates are occupied by another Pawn or out of bounds.
Note
This method is a convenience function that calls both getPawn and movePawn internally.
See also
Pawn
Coordinates
validateCoordinates
getPawn
movePawn

◆ movePawnFromTo() [2/2]

void sista::Field::movePawnFromTo ( unsigned short  y,
unsigned short  x,
unsigned short  newY,
unsigned short  newX 
)

Moves a Pawn from one set of coordinates to another.

Parameters
yThe current y coordinate (row) of the Pawn.
xThe current x coordinate (column) of the Pawn.
newYThe new y coordinate (row) to move the Pawn to.
newXThe new x coordinate (column) to move the Pawn to.

This method finds the Pawn at the specified current coordinates and moves it to the new coordinates.

Exceptions
`std::invalid_argument`if there is no Pawn at the current coordinates or if the new coordinates are occupied by another Pawn or out of bounds.
Note
This method is a convenience function that calls both getPawn and movePawn internally.
See also
Pawn
Coordinates
validateCoordinates
getPawn
movePawn

◆ movingByCoordinates() [1/2]

Coordinates sista::Field::movingByCoordinates ( Pawn pawn,
short int  y,
short int  x 
) const

Calculates the new coordinates of a Pawn after moving by a relative offset.

Parameters
pawnA pointer to the Pawn to calculate the new coordinates for.
yThe relative y offset (rows) to move the Pawn by.
xThe relative x offset (columns) to move the Pawn by.
Returns
The new Coordinates of the Pawn after applying the movement.

This method calculates the new coordinates of the specified Pawn after moving it by the given relative offset. It does not modify the Pawn's actual coordinates, it only computes and returns the new position.

Exceptions
`std::out_of_range`if the resulting coordinates are out of bounds.
Note
This method only calculates the new coordinates, it does not move the Pawn.
See also
Pawn
Coordinates

◆ movingByCoordinates() [2/2]

Coordinates sista::Field::movingByCoordinates ( Pawn pawn,
short int  y,
short int  x,
Effect  effect 
) const

Calculates the new coordinates of a Pawn after moving by a relative offset with specified effect on out-of-bounds coordinates.

Parameters
pawnA pointer to the Pawn to calculate the new coordinates for.
yThe relative y offset (rows) to move the Pawn by.
xThe relative x offset (columns) to move the Pawn by.
effectThe Effect to apply when the resulting coordinates are out of bounds.
Returns
The new Coordinates of the Pawn after applying the movement and effect.

This method calculates the new coordinates of the specified Pawn after moving it by the given relative offset. If the resulting coordinates go out of bounds, the specified effect is applied to adjust them accordingly.

Exceptions
`std::out_of_range`if the resulting coordinates are out of bounds.
Note
This method only calculates the new coordinates, it does not move the Pawn.
See also
Pawn
Coordinates
Effect

◆ print() [1/3]

void sista::Field::print ( ) const

Prints the entire field to the terminal.

This method iterates through the 2D grid of Pawns and prints each Pawn's symbol at its respective coordinates. The method uses the Cursor object to manage terminal cursor positioning.

See also
Pawn::print
Cursor

◆ print() [2/3]

void sista::Field::print ( Border border) const

Prints the entire field to the terminal.

Parameters
borderA Border object to use for the border.

This method iterates through the 2D grid of Pawns and prints each Pawn's symbol at its respective coordinates. It also prints a border around the field using the specified Border object. The method uses the Cursor object to manage terminal cursor positioning.

See also
Pawn::print
Border::print
Cursor

◆ print() [3/3]

void sista::Field::print ( char  border) const

Prints the entire field to the terminal.

Parameters
borderA character to use as the border symbol.

This method iterates through the 2D grid of Pawns and prints each Pawn's symbol at its respective coordinates. It also prints a border around the field using the specified character. The method uses the Cursor object to manage terminal cursor positioning.

See also
Pawn::print
Cursor

◆ removePawn() [1/2]

void sista::Field::removePawn ( const Coordinates coordinates)
virtual

Removes a Pawn from the field at specified coordinates.

Parameters
coordinatesThe Coordinates of the Pawn to remove.

This method removes the Pawn located at the given coordinates from the field. If no Pawn is found at the specified coordinates, no action is taken.

Warning
The coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method does not delete the Pawn object, it only removes it from the field.
See also
Pawn

◆ removePawn() [2/2]

void sista::Field::removePawn ( Pawn pawn)
virtual

Removes a Pawn from the field.

Parameters
pawnA pointer to the Pawn to remove.

This method removes the specified Pawn from the field. If the Pawn is not found at its coordinates, no action is taken.

Warning
The Pawn's coordinates must be valid (within the field bounds) as they are not validated here.
Note
The method does not delete the Pawn object, it only removes it from the field.
See also
Pawn

Reimplemented in sista::SwappableField.

◆ rePrintPawn()

void sista::Field::rePrintPawn ( Pawn pawn)

Reprints a Pawn at its current coordinates.

Parameters
pawnA pointer to the Pawn to reprint.

This method reprints the specified Pawn at its current coordinates on the terminal. It is useful for updating the Pawn's appearance after changes to its settings or symbol.

Warning
The Pawn's coordinates must be valid (within the field bounds) as they are not validated here.
See also
Pawn::print

◆ validateCoordinates() [1/2]

void sista::Field::validateCoordinates ( const Coordinates coordinates) const

Validates that the given coordinates are within bounds and not occupied.

Parameters
coordinatesThe Coordinates to validate.

This method checks if the specified coordinates are within the valid range of the field and not occupied by another Pawn. If either condition is not met, an exception is thrown.

Exceptions
`std::invalid_argument`if the coordinates are occupied by another Pawn.
`std::out_of_range`if the coordinates are out of bounds.
See also
Coordinates
isOccupied
isOutOfBounds

◆ validateCoordinates() [2/2]

void sista::Field::validateCoordinates ( unsigned short  y,
unsigned short  x 
) const

Validates that the given coordinates are within bounds and not occupied.

Parameters
yThe y coordinate (row) to validate.
xThe x coordinate (column) to validate.

This method checks if the specified coordinates are within the valid range of the field and not occupied by another Pawn. If either condition is not met, an exception is thrown.

Exceptions
`std::invalid_argument`if the coordinates are occupied by another Pawn.
`std::out_of_range`if the coordinates are out of bounds.
See also
Coordinates
isOccupied
isOutOfBounds

Member Data Documentation

◆ cursor

Cursor sista::Field::cursor
protected

◆ height

int sista::Field::height
protected

Width of the matrix

◆ pawns

std::vector<std::vector<std::shared_ptr<Pawn> > > sista::Field::pawns
protected

2D grid of shared pointers to Pawn objects.

◆ width

int sista::Field::width
protected

Cursor object for terminal operations.


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