Cute Chess 0.1
PgnGame Class Reference

A game of chess in PGN format. More...

#include <pgngame.h>

Classes

struct  MoveData
 A struct for storing the game's move history. More...

Public Types

enum  PgnMode { Minimal , Verbose }

Public Member Functions

void addMove (const MoveData &data, bool addEco=true)
void clear ()
Chess::BoardcreateBoard () const
QDate date () const
QString event () const
QMap< int, int > extractScores () const
bool isNull () const
bool isStandard () const
const QVector< MoveData > & moves () const
 PgnGame ()
QString playerName (Chess::Side side) const
bool read (PgnStream &in, int maxMoves=INT_MAX - 1, bool addEco=true)
Chess::Result result () const
int round () const
void setDate (const QDate &date)
void setEvent (const QString &event)
void setGameEndTime (const QDateTime &dateTime)
void setGameStartTime (const QDateTime &dateTime)
void setMove (int ply, const MoveData &data)
void setPlayerName (Chess::Side side, const QString &name)
void setResult (const Chess::Result &result)
void setResultDescription (const QString &description)
void setRound (int round)
void setSite (const QString &site)
void setStartingFenString (Chess::Side side, const QString &fen)
void setStartingSide (Chess::Side side)
void setTag (const QString &tag, const QString &value)
void setTagReceiver (QObject *receiver)
void setVariant (const QString &variant)
QString site () const
QString startingFenString () const
Chess::Side startingSide () const
QList< QPair< QString, QString > > tags () const
QString tagValue (const QString &tag) const
QString variant () const
bool write (const QString &filename, PgnMode mode=Verbose) const
bool write (QTextStream &out, PgnMode mode=Verbose) const

Detailed Description

A game of chess in PGN format.

PGN (Portable game notation) is a text format for chess games. Specification: http://www.very-best.de/pgn-spec.htm

PgnGame is a middle format between text-based PGN games and games played by Cute Chess. PgnGame objects are used for converting played games to PGN format, importing PGN data to opening books, analyzing previous games on a graphical board, etc.

See also
PgnStream
ChessGame

Member Enumeration Documentation

◆ PgnMode

The mode for writing PGN games.

Enumerator
Minimal 

Only use data which is required by the PGN standard.

Verbose 

Use additional data like extra tags and comments.

Constructor & Destructor Documentation

◆ PgnGame()

PgnGame::PgnGame ( )

Creates a new PgnGame object.

Member Function Documentation

◆ addMove()

void PgnGame::addMove ( const MoveData & data,
bool addEco = true )

Adds a new move to the game.

Parameters
dataThe move to add.
addEcoAdds opening information if true.

◆ clear()

void PgnGame::clear ( )

Deletes all tags and moves.

◆ createBoard()

Chess::Board * PgnGame::createBoard ( ) const

Creates a board object for viewing or analyzing the game.

The board is set to the game's starting position. Returns 0 on error.

◆ date()

QDate PgnGame::date ( ) const

Returns the starting date of the game.

◆ event()

QString PgnGame::event ( ) const

Returns the name of the tournament or match event.

◆ extractScores()

QMap< int, int > PgnGame::extractScores ( ) const

Returns QMap of scores extracted from PGN comments

◆ isNull()

bool PgnGame::isNull ( ) const

Returns true if the game doesn't contain any tags or moves.

◆ isStandard()

bool PgnGame::isStandard ( ) const

Returns true if the game's variant is "standard" and it's played from the default starting position; otherwise returns false.

◆ moves()

const QVector< PgnGame::MoveData > & PgnGame::moves ( ) const

Returns the moves that were played in the game.

◆ playerName()

QString PgnGame::playerName ( Chess::Side side) const

Returns the player's name who plays side.

◆ read()

bool PgnGame::read ( PgnStream & in,
int maxMoves = INT_MAX - 1,
bool addEco = true )

Reads a game from a PGN text stream.

Parameters
inThe PGN stream to read from.
maxMovesThe maximum number of halfmoves to read.
addEcoAdds opening information if true.
Note
Even if the stream contains multiple games, only one will be read.

Returns true if any tags and/or moves were read.

◆ result()

Chess::Result PgnGame::result ( ) const

Returns the result of the game.

◆ round()

int PgnGame::round ( ) const

Returns the the playing round ordinal of the game.

◆ setDate()

void PgnGame::setDate ( const QDate & date)

Sets the starting date of the game.

◆ setEvent()

void PgnGame::setEvent ( const QString & event)

Sets the name of the tournament or match event.

◆ setGameEndTime()

void PgnGame::setGameEndTime ( const QDateTime & dateTime)

Sets the end time and the duration of the game

◆ setGameStartTime()

void PgnGame::setGameStartTime ( const QDateTime & dateTime)

Sets the starting time of the game

◆ setPlayerName()

void PgnGame::setPlayerName ( Chess::Side side,
const QString & name )

Sets the player's name who plays side.

◆ setResult()

void PgnGame::setResult ( const Chess::Result & result)

Sets the result of the game.

◆ setResultDescription()

void PgnGame::setResultDescription ( const QString & description)

Sets a description for the result.

The description is appended to the last move's comment/annotation.

Note
This is not the same as the "Termination" tag which can only hold one of the standardized values.

◆ setRound()

void PgnGame::setRound ( int round)

Sets the playing round ordinal of the game.

◆ setSite()

void PgnGame::setSite ( const QString & site)

Sets the location of the event.

◆ setStartingFenString()

void PgnGame::setStartingFenString ( Chess::Side side,
const QString & fen )

Sets the starting position's FEN string.

◆ setStartingSide()

void PgnGame::setStartingSide ( Chess::Side side)

Sets the side that starts the game.

◆ setTag()

void PgnGame::setTag ( const QString & tag,
const QString & value )

Sets tag's value to value. If tag doesn't exist, a new tag is created.

◆ setTagReceiver()

void PgnGame::setTagReceiver ( QObject * receiver)

Sets a receiver for PGN tags

receiver is an object whose "setTag(QString tag, QString value)" slot is called when a PGN tag changes.

◆ setVariant()

void PgnGame::setVariant ( const QString & variant)

Sets the chess variant of the game.

◆ site()

QString PgnGame::site ( ) const

Returns the location of the event.

◆ startingFenString()

QString PgnGame::startingFenString ( ) const

Returns the starting position's FEN string.

◆ startingSide()

Chess::Side PgnGame::startingSide ( ) const

Returns the side that starts the game.

◆ tags()

QList< QPair< QString, QString > > PgnGame::tags ( ) const

Returns the tags that are used to describe the game.

◆ tagValue()

QString PgnGame::tagValue ( const QString & tag) const

Returns the value of tag tag. If tag doesn't exist, an empty string is returned.

◆ variant()

QString PgnGame::variant ( ) const

Returns the chess variant of the game.

◆ write() [1/2]

bool PgnGame::write ( const QString & filename,
PgnMode mode = Verbose ) const

Writes the game to a file. If the file already exists, the game will be appended to the end of the file.

Returns true if successful; otherwise returns false.

◆ write() [2/2]

bool PgnGame::write ( QTextStream & out,
PgnMode mode = Verbose ) const

Writes the game to a text stream.

Returns true if successful; otherwise returns false.


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