NAME
Games::Go::AGA::DataObjects::Player - model an AGA player
VERSION
version 0.152
SYNOPSIS
use Games::Go::AGA::DataObjects::Player;
my $player = Games::Go::AGA::DataObjects::Player->new(
id => 'USA2122',
last_name => 'Augustin',
first_name => 'Reid',
rank => '5d',
flags => ['FOO', 'DROP']
comment => 'programs in perl',
);
DESCRIPTION
Games::Go::AGA::DataObjects::Player models a single player.
METHODS
- $player = new ( options ... );
-
Creates a new object. The options are in a hash describing any of the attributes of the player (see below).
- clone
-
Clones the player by copying all the attributes. Note that the games list still points to the original's games.
- add_game ($game, [ $idx ])
-
THIS METHOD IS DEPRECATED - modify tournament->round->games list instead.
Adds
$gameto the list of games.$gamemust be a Games::Go::AGA::DataObjects::Game. If $idx is specified, splices into that position in the games list, otherwise pushes onto the end.Note that this doesn't call the change_callback function.
- delete_game ($game, [ $idx, [ $id1 ] ])
-
THIS METHOD IS DEPRECATED - modify tournament->round->games list instead.
Finds and deletes
$gamefrom the list of games.$gamemay be a Games::Go::AGA::DataObjects::Game, or an index into the games list, or an ID of one of the players (in which case $id1 should be the ID of the other player). Croaks if$gameis not found the list of games.Note that this doesn't call the change_callback function.
- opponents
-
THIS METHOD IS DEPRECATED - use tournament->round->games list instead.
- defeated
-
THIS METHOD IS DEPRECATED - use tournament->player_defeated instead.
Returns the players this player defeated. In scalar context, returns the number of wins.
- defeated_by
-
THIS METHOD IS DEPRECATED - use tournament->player_defeated_by instead.
Returns the players this player lost to. In scalar context, returns the number of loses.
- wins
-
THIS METHOD IS DEPRECATED - use tournament->player_wins instead.
Returns the won games from the games array. In scalar context, returns the number of wins.
- losses
-
THIS METHOD IS DEPRECATED - use tournament->player_losses instead.
Returns the lost games from the games array. In scalar context, returns the number of losses.
- drop ( [ $round_num ] )
-
THIS METHOD IS DEPRECATED - use tournament->get_directive('DROP') instead.
Returns true if DROP flag is set, false if not. If
$round_numis defined, also checks for DROPn flag where n =$round_num. - bye
-
THIS METHOD IS DEPRECATED - use tournament->get_directive('BYE_CANDIDATE') instead.
Returns true if BYE flag is set, false if not.
- get_flag ( $name )
- set_flag ( $name )
- clear_flag ( $name )
-
These functions manipulate the AGA flags for a player as expected from the names.
get_flag() returns the flag if the
$nameflag is set for this player, false if it is not.For string matching,
$nameis always set to upper-case by this method.Any
$namecan be used, but 'BYE', 'DROP', 'DROPn' (where n is a round number) are recognized by tournament software as significant.Flags may also be key=value pairs. The 'club' attribute is really an AGA key=value pair.
'club', and 'drop*' attributes are actually AGA flags, but they are handled specially by this object - don't use these functions to manage the 'club'.
- rating
-
Returns player's rank/rating field in rating (numeric) format suitable for direct comparison (eg
if ($p1-rating > $p2->rating) {...}>).Note that rating is not settable. Instead, set the rank/rating to rank.
- fprint_register( $file_handle )
-
Prints the player to $file_handle in register.tde format.
- fprint_tdlist( $file_handle )
-
Prints the player to $file_handle in tdlist format.
ATTRIBUTES
Accessor methods are defined for the following attributes:
- id Games::Go::AGA::DataObjects::ID
- last_name String
- first_name String
- rank Games::Go::AGA::DataObjects::Rank or ::Rating
- date Date of membership (see TDList)
- membership Type of membership (see TDList)
- state State of residence
- club Club affiliation (converted to uppercase)
- flags Flags as defined by the AGA
- comment Arbitrary information for this player
- sigma Num, rates the trustworthiness of the rank
- games Array (ref) of games recorded for this player
- change_callback A code ref to a subroutine called whenever the object changes
- adj_rating Rating # rank/rating may change as a tournament progresses
- handicap_rating
-
Handicap rating is used during pairing. For normal handicap tournaments, this should be left uninitialized in which case it returns the normal
rating. For HANDICAP MIN tournaments, initialize all players to the samehandicap_ratingvalue before pairing the first round (doesn't really matter what the value is). - comment String
- flags reference to an Array of Strings
-
When setting flags, pass an array of new flags. To add flags, do a read/modify/write:
my $flags = $player->flags; push @{$flags}, 'new_flag'; $player->flags($flags);Returns a reference to the array of the current flags.
Note that the club field is not added to the flags even though it is part of the AGA flags field in a register.tde file. club should be handled by the caller as necessary.
Accessors are used like this to retrieve an attribute:
my $id = $player->id;
and like this to set an attribute:
$player->id("new_id");
All attributes are read/write, and are type-checked on setting.
rank can be either a Games::Go::AGA::DataObjects::Rank (like '4d' or '15K'), or a Games::Go::AGA::DataObjects::Rating (like 4.5 or -15.5).
SEE ALSO
AUTHOR
Reid Augustin <reid@hellosix.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 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.