Cute Chess  0.1
Public Types | Public Member Functions | List of all members
Chess::Result Class Reference

The result of a chess game. More...

#include <result.h>

Public Types

enum  Type {
  Win, Draw, Resignation, Timeout,
  Adjudication, IllegalMove, Disconnection, StalledConnection,
  Agreement, NoResult, ResultError
}
 

Public Member Functions

QString description () const
 
bool isDraw () const
 
bool isNone () const
 
Side loser () const
 
bool operator!= (const Result &other) const
 
bool operator== (const Result &other) const
 
 Result (Type type=NoResult, Side winner=Side(), const QString &description=QString())
 
 Result (const QString &str)
 
QString toShortString () const
 
QString toVerboseString () const
 
Type type () const
 
Side winner () const
 

Detailed Description

The result of a chess game.

The Result class is used to store the result of a chess game, and to compare it to other results.

Member Enumeration Documentation

Result type.

Enumerator
Win 

Win by any means.

Draw 

Draw by any means.

Resignation 

Loser resigns.

Timeout 

A player's time flag falls.

Adjudication 

Adjudication by the GUI.

IllegalMove 

Loser tries to make an illegal move.

Disconnection 

Loser disconnects, or terminates (if it's an engine).

StalledConnection 

Loser's connection stalls (doesn't respond to ping).

Agreement 

Both players agree to a result.

NoResult 

No result. The game may continue.

ResultError 

Result error, caused by an invalid result string.

Constructor & Destructor Documentation

Chess::Result::Result ( Type  type = NoResult,
Side  winner = Side(),
const QString description = QString() 
)
explicit

Creates a new result.

Parameters
typeThe type of the result
winnerThe winning side (or NoSide in case of a draw)
descriptionA description of the result. If the Result class has a preset description for type, this additional description is appended to it.
Chess::Result::Result ( const QString str)
explicit

Creates a new result from a string.

Member Function Documentation

QString Chess::Result::description ( ) const

Returns the result description.

bool Chess::Result::isDraw ( ) const

Returns true if the result is Draw.

bool Chess::Result::isNone ( ) const

Returns true if the result is NoResult.

Side Chess::Result::loser ( ) const

Returns the losing side, or NoSide if there's no loser.

bool Chess::Result::operator!= ( const Result other) const

Returns true if other different from this result.

bool Chess::Result::operator== ( const Result other) const

Returns true if other is the same as this result.

QString Chess::Result::toShortString ( ) const

Returns the short string representation of the result. Can be "1-0", "0-1", "1/2-1/2", or "*".

QString Chess::Result::toVerboseString ( ) const

Returns the verbose string representation of the result.

Uses the format "result {description}". Eg. "1-0 {White mates}".

Result::Type Chess::Result::type ( ) const

Returns the type of the result.

Side Chess::Result::winner ( ) const

Returns the winning side, or NoSide if there's no winner.


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