Cute Chess 0.1
Chess::Square Class Reference

A generic chess square type consisting of a file and a rank. More...

#include <square.h>

Public Types

enum  Color { Light , Dark , NoColor }

Public Member Functions

Color color () const
int file () const
bool isValid () const
bool operator!= (const Square &other) const
bool operator== (const Square &other) const
int rank () const
void setFile (int file)
void setRank (int rank)
 Square ()
 Square (int file, int rank)

Detailed Description

A generic chess square type consisting of a file and a rank.

Square is mainly used as a middle-layer between the Board class (which uses integers for squares) and more generic, high-level classes like GenericMove.

Member Enumeration Documentation

◆ Color

Square color

Enumerator
Light 

Light-colored square.

Dark 

Dark-colored square.

NoColor 

Color for invalid squares.

Constructor & Destructor Documentation

◆ Square() [1/2]

Chess::Square::Square ( )

Creates a new square with invalid defaults.

◆ Square() [2/2]

Chess::Square::Square ( int file,
int rank )

Creates a new square from file and rank.

Member Function Documentation

◆ color()

Square::Color Chess::Square::color ( ) const

Returns the color of the square.

◆ file()

int Chess::Square::file ( ) const

Zero-based file of the square. 0 is the 'a' file.

◆ isValid()

bool Chess::Square::isValid ( ) const

Returns true if both file and rank have non-negative values.

◆ operator!=()

bool Chess::Square::operator!= ( const Square & other) const

Returns true if other is different from this square.

◆ operator==()

bool Chess::Square::operator== ( const Square & other) const

Returns true if other is the same as this square.

◆ rank()

int Chess::Square::rank ( ) const

Zero-based rank of the square. 0 is white's first rank.

◆ setFile()

void Chess::Square::setFile ( int file)

Sets the file to file.

◆ setRank()

void Chess::Square::setRank ( int rank)

Sets the rank to rank.


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