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 | Public Attributes | Static Public Attributes | List of all members
sista::Path Struct Reference

Represents a movement path for a Pawn, including priority handling. More...

#include <field.hpp>

Collaboration diagram for sista::Path:
Collaboration graph
[legend]

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
 
Pawnpawn
 

Static Public Attributes

static long long int current_priority = 0
 

Detailed Description

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).

Note
The way this struct is handled assumes that no two identical paths (same begin and end coordinates) will be created, as no two pawns can occupy the same coordinates at the same time.
See also
Coordinates
Pawn

Constructor & Destructor Documentation

◆ Path()

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

Parameters
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.

See also
Coordinates
Pawn

Member Function Documentation

◆ operator<()

bool sista::Path::operator< ( const Path other) const

Overloaded operator to compare paths based on priority.

Parameters
otherThe other Path to compare with.
Returns
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.

See also
priority

◆ operator==()

bool sista::Path::operator== ( const Path other) const

Overloaded operator to check if two paths are equal (same begin and end coordinates).

Parameters
otherThe other Path to compare with.
Returns
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.

See also
begin
end

◆ operator|()

bool sista::Path::operator| ( const Path other) const

Overloaded operator to check if two paths are opposite (reverse of each other).

Parameters
otherThe other Path to compare with.
Returns
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.

See also
begin
end

Member Data Documentation

◆ begin

Coordinates sista::Path::begin

priority - priority of the path (lower number = higher priority)

◆ current_priority

long long int sista::Path::current_priority = 0
static

◆ end

Coordinates sista::Path::end

begin - starting coordinates of the path

◆ pawn

Pawn* sista::Path::pawn

end - ending coordinates of the path

◆ priority

int sista::Path::priority

Static counter to assign unique priorities to new paths.


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