Cute Chess 0.1
TournamentPair Class Reference

A single encounter in a tournament. More...

#include <tournamentpair.h>

Public Member Functions

void addFirstScore (int score)
void addSecondScore (int score)
void addStartedGame ()
int firstPlayer () const
int firstScore () const
int gamesFinished () const
int gamesInProgress () const
int gamesStarted () const
bool hasOriginalOrder () const
bool hasSamePlayers (const TournamentPair *other) const
bool isValid () const
int leader () const
int scoreDiff () const
int scoreSum () const
int secondPlayer () const
int secondScore () const
void swapPlayers ()
 TournamentPair (int firstPlayer=-1, int secondPlayer=-1)

Detailed Description

A single encounter in a tournament.

The TournamentPair class can be used to manage a single tournament encounter's progress, eg. scores for each player, number of games started, games finished, games left, etc.

TODO: players should be pointers to TournamentPlayer objects, not indexes

Constructor & Destructor Documentation

◆ TournamentPair()

TournamentPair::TournamentPair ( int firstPlayer = -1,
int secondPlayer = -1 )

Creates a new TournamentPair object.

firstPlayer is the first player's index and secondPlayer is the second player's index. An index value of -1 represents a BYE player.

Member Function Documentation

◆ addFirstScore()

void TournamentPair::addFirstScore ( int score)

Adds score to the first player's score in the current encounter.

◆ addSecondScore()

void TournamentPair::addSecondScore ( int score)

Adds score to the second player's score in the current encounter.

◆ addStartedGame()

void TournamentPair::addStartedGame ( )

Adds a new started game to the current encounter.

◆ firstPlayer()

int TournamentPair::firstPlayer ( ) const

Returns the first player's index.

◆ firstScore()

int TournamentPair::firstScore ( ) const

Returns the first player's score in the current encounter.

◆ gamesFinished()

int TournamentPair::gamesFinished ( ) const

Returns the number of finished games between the pair.

◆ gamesInProgress()

int TournamentPair::gamesInProgress ( ) const

Returns the number of ongoing between the pair.

◆ gamesStarted()

int TournamentPair::gamesStarted ( ) const

Returns the number of started games between the pair, including finished games.

◆ hasOriginalOrder()

bool TournamentPair::hasOriginalOrder ( ) const

Returns true if the players are in their original order, ie. not swapped; otherwise returns false.

◆ hasSamePlayers()

bool TournamentPair::hasSamePlayers ( const TournamentPair * other) const

Returns true if this pair has the same players as other; otherwise returns false.

Note
The players may be in different order in other.

◆ isValid()

bool TournamentPair::isValid ( ) const

Returns true if both players are real (ie. not BYEs); otherwise returns false.

◆ leader()

int TournamentPair::leader ( ) const

Returns the index of the player in the lead. Returns -1 if both players have the same score.

If one of the players is a BYE, the other player's index is returned.

◆ scoreDiff()

int TournamentPair::scoreDiff ( ) const

◆ scoreSum()

int TournamentPair::scoreSum ( ) const

Returns the sum of both player's score in their current encounter.

◆ secondPlayer()

int TournamentPair::secondPlayer ( ) const

Returns the second player's index.

◆ secondScore()

int TournamentPair::secondScore ( ) const

Returns the second player's score in the current encounter.

◆ swapPlayers()

void TournamentPair::swapPlayers ( )

Swaps the players so that the first player becomes the second player and vice versa.


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