NAME
Games::Go::AGA::DataObjects::Game - model an AGA game
VERSION
version 0.152
SYNOPSIS
use Games::Go::AGA::DataObjects::Game;
my $game = Games::Go::AGA::DataObjects::Game->new(
black => $player, # Games::Go::AGA::DataObjects::Player
white => $another, # this too
handi => 0, # positive integer
komi => 5.5, # number
);
$game->winner($player); # set the winner
DESCRIPTION
Games::Go::AGA::DataObjects::Game models a single game.
ACCESSORS
Accessor methods are defined for the following attributes:
- black Games::Go::AGA::DataObjects::Player
- white Games::Go::AGA::DataObjects::Player
- handi Integer from 0 to 99 (probably should be 9 or less)
- komi Number
- winner Games::Go::AGA::DataObjects::Player or 'b' or 'w' or undef
- loser read only (set automatically when winner is set)
Accessors are used like this to retrieve an attribute:
my $winner = $game->winner;
and like this to set an attribute:
$game->winner($player);
All attributes are read/write, and are type-checked on setting.
Attempting to set the winner to a player who is not either the black or the white player causes an exception to be thrown.
Attempting to set black or white player when a winner is already set causes an exception to be thrown.
METHODS
my $loser = $game->loser;
Simalar to the winner accessor, but read only - returns the player who is not the winner, or undef if no winner is set.
$game->handicap( $default_komi );
$game->auto_handicap( $default_komi );
Sets handicap and komi based on the adjusted ratings of the two players. auto_handicap swaps white and black players if black's rating is significantly higher than white's. $default_komi
is the value set for even games or -$default_komi
for reverse komi games. If $default_komi
is undefined, 7.5 is used.
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.