NAME
Games::Go::AGA::DataObjects::Round - model a round of an AGA tournament
VERSION
version 0.107
SYNOPSIS
use Games::Go::AGA::DataObjects::Round;
my $round = Games::Go::AGA::DataObjects::Round->new;
DESCRIPTION
A Games::Go::AGA::DataObjects::Round models the information in a tournament round. There is a list of pairings and a list of BYE players (not playing this round).
METHODS
my $round = Games::Go::AGA::DataObjects::Round->new();
Creates a new Round object.
my $games_ref = $round->games;
Returns a reference to a copy of the games list. Since this is a copy, games cannot be added or removed by changing this list.
my $byes_ref = $round->byes;
Returns a reference to a copy of the byes list. Since this is a copy, byes cannot be added or removed by changing this list.
$round->add_game($game);
Adds a Games::Go::AGA::DataObjects::Game to the Round. The game is also added to each Games::Go::AGA::DataObjects::Player's games list. The number of tables (table_number) in the round is incremented, and $game->table_number is set to the new number.
$round->clear_table_number;
Normally, table_number is incremented for each added game and is never decremented. Games don't 'give up' their numbers, which could cause confusion.
For a round that is being re-paired, call clear_table_number to reset the number back to the start.
$round->remove_game($game);
Removes a Games::Go::AGA::DataObjects::Game to the Round and from each Games::Go::AGA::DataObjects::Player's games list. $game can also be an index into the games array. The players from the removed game are transferred to the byes array. Can die if game is not found.
$round->add_bye($player);
Adds a Games::Go::AGA::DataObjects::Player as a BYE.
$round->remove_bye($player);
Removes a Games::Go::AGA::DataObjects::Player from the byes list. $player can be an ID or an index into the byes list. The Games::Go::AGA::DataObjects::Player is returned. Can die if the player is not found.
$round->replace_bye($old_player, $new_player);
Removes $old_player from the byes list and replaces him with $new_player. $old_player can be an ID or an index into the byes list. The Games::Go::AGA::DataObjects::Player for $old_player is returned. Can die if the $old_player is not found.
$round->swap($id_0, $id_1);
Swap two players. The two players may both be in a game, or one (but not both) may be in the byes list. The forward and backward pointers from the game(s) to the Games::Go::AGA::DataObjects::Players' games lists are properly adjusted.
Throws an exception if either player is not found. If both are in the byes list, nothing happens.
ACCESSORS
Accessor methods are defined for the following attributes:
SEE ALSO
AUTHOR
Reid Augustin <reid@hellosix.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Reid Augustin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.