Cute Chess  0.1
Classes | Public Member Functions | List of all members
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 ( 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

void TournamentPair::addFirstScore ( int  score)

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

void TournamentPair::addSecondScore ( int  score)

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

void TournamentPair::addStartedGame ( )

Adds a new started game to the current encounter.

int TournamentPair::firstPlayer ( ) const

Returns the first player's index.

int TournamentPair::firstScore ( ) const

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

int TournamentPair::gamesFinished ( ) const

Returns the number of finished games between the pair.

int TournamentPair::gamesInProgress ( ) const

Returns the number of ongoing between the pair.

int TournamentPair::gamesStarted ( ) const

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

bool TournamentPair::hasOriginalOrder ( ) const

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

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.
bool TournamentPair::isValid ( ) const

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

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.

int TournamentPair::scoreDiff ( ) const
int TournamentPair::scoreSum ( ) const

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

int TournamentPair::secondPlayer ( ) const

Returns the second player's index.

int TournamentPair::secondScore ( ) const

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

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: