Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
|
Represents a movement path for a Pawn, including priority handling. More...
#include <field.hpp>
Public Member Functions | |
Path (Coordinates, Coordinates, Pawn *) | |
Constructor to initialize a Path with begin and end coordinates and associated Pawn. | |
bool | operator| (const Path &) const |
Overloaded operator to check if two paths are opposite (reverse of each other). | |
bool | operator< (const Path &) const |
Overloaded operator to compare paths based on priority. | |
bool | operator== (const Path &) const |
Overloaded operator to check if two paths are equal (same begin and end coordinates). | |
Public Attributes | |
int | priority |
Coordinates | begin |
Coordinates | end |
Pawn * | pawn |
Static Public Attributes | |
static long long int | current_priority = 0 |
Represents a movement path for a Pawn, including priority handling.
The Path struct encapsulates the beginning and end coordinates of a movement path for a Pawn. It includes a priority attribute to determine the order of processing paths, as well as a static current_priority counter to assign unique priorities to new paths.
The struct provides operator overloads to compare paths based on priority, check for equality, and determine if two paths are opposite (i.e., one is the reverse of the other).
sista::Path::Path | ( | Coordinates | begin_, |
Coordinates | end_, | ||
Pawn * | pawn_ | ||
) |
Constructor to initialize a Path with begin and end coordinates and associated Pawn.
pawn - the pawn that is moving along the path
begin_ | The starting Coordinates of the path. |
end_ | The ending Coordinates of the path. |
pawn_ | A pointer to the Pawn associated with this path. |
This constructor initializes a Path object with the specified begin and end coordinates, assigns a unique priority based on the static current_priority counter, and associates it with the given Pawn.
bool sista::Path::operator< | ( | const Path & | other | ) | const |
Overloaded operator to compare paths based on priority.
other | The other Path to compare with. |
true
if this path has a higher priority (lower number) than the other path, false
otherwise.This operator allows comparing two Path objects based on their priority attribute. It is useful for sorting or ordering paths when processing multiple movements.
bool sista::Path::operator== | ( | const Path & | other | ) | const |
Overloaded operator to check if two paths are equal (same begin and end coordinates).
other | The other Path to compare with. |
true
if both paths have the same begin and end coordinates, false
otherwise.This operator checks if two Path objects represent the same movement path, ignoring the priority and associated Pawn.
bool sista::Path::operator| | ( | const Path & | other | ) | const |
Overloaded operator to check if two paths are opposite (reverse of each other).
other | The other Path to compare with. |
true
if the paths are opposite, false
otherwise.This operator checks if the current path is the reverse of the other path, meaning that the begin coordinates of one path match the end coordinates of the other and vice versa.
Coordinates sista::Path::begin |
priority - priority of the path (lower number = higher priority)
|
static |
Coordinates sista::Path::end |
begin - starting coordinates of the path
Pawn* sista::Path::pawn |
end - ending coordinates of the path
int sista::Path::priority |
Static counter to assign unique priorities to new paths.