The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Games::Tournament::Contestant A competitor matched with others over a series of rounds

VERSION

Version 0.01

SYNOPSIS

    my $foo = Games::Tournament::Contestant->new( rating => '15', name => 'Your New Knicks' );
    ...

DESCRIPTION

A generic tournament/series player/team contestant object.

METHODS

new

        $team = Games::Tournament::Contestant->new( id => '15', name => 'Lala Lakers', rating => 0, score => 1000,  )
        $grandmaster = Games::Tournament::Contestant->new( name => 'Jose Raul Capablanca', rating => 1000 )

clone

        $monster = $alekhine->clone( score => 1000, reputation => 'bad' )

Creates a similar object to $alekhine, with the same id, name, score, title, and rating fields but with any other changes or additions you want to make.

findCard

 @venues = $player->findCard(@games);

Returns a/the first game in @games in which $player is a contestant. 'findCard' expects the game objects to have 'contestants' accessors and be 'canonize'able. The players are grepped for stringwise id equality.

myOpponent

 $opponent = $player->myOpponent($game);

Returns a/the opponent in $game of $player. 'myOpponent' expects the game object to have 'contestants' accessors. The players are grepped for stringwise id equality.

copyCard

 @result = $player->copyCard(@games);

Stores a ref to the @games in which $player has participated and copied the cards for. @games may or may not be a complete list of result for all rounds, and may include games in which $player wasn't a participant. Pushed to an anonymous array stored as the 'play' field. 'copyCard' expects the game objects to have 'round' and 'contestants' accessors and be 'canonize'able.

writeCard (deprecated)

 @result = $player->writeCard(@games);

Updates the contestant's result in the matches played, using no intelligence if records only have only opponents' scores. @games may or may not be a complete list of result for all rounds, and may include games in which $player wasn't a participant. Stored as a 'play' field and keyed on the round, the resultant records have 'opponent' and 'result' subfields. 'writeCard' expects the game objects to have 'round', 'contestants' and 'result' accessors. Returns the new play field. TODO The 'opponent' subfield will be an anonymous array of player objects if it is a multi-player game.

score

        $rounds = $deepblue->score
        next if $deepblue->score

Gets/sets the total score over the rounds in which $deepblue has a score. Don't forget to tally $deepblue's scorecard with the appropriate games first! We don't check any cards. Internally, this method accumulates the results of all the rounds into a total score, unless no results exist. If they don't exist, a hash key $self->{score} is consulted. You can set the score this way too, bypassing the elegant code to do it from individual game results stored by the Games::Tournament::Contestant object. A hack to allow importing a pairing table.

met

        $rounds = $deepblue->met(@grandmasters)
        next if $deepblue->met($capablanca)

Returns an anonymous array either of the rounds in which $deepblue remembers meeting the members of @grandmasters or of the empty string '' if there is no record of such a meeting. Don't forget to tally $deepblue's scorecard with the appropriate games first! We don't check $deepblue's partners' cards. (Assumes players do not meet more than once!) This is same as Games::Tournament::met or different?

name

        $member->name('Alexander Alekhine');
        $member->name

Sets or gets the name of the contesting individual or team, a string that may or may not be unique to the tournament member.

title

        $member->title('Grandmaster')

Sets/gets the title of the contestant, a courtesy given to the contestant.

scores

        $member->scores

Sets/gets the scores (actually results, eg 'Draw', 'Win') of the contestant in the different matches of the tournament, an ongoing record of their standing in the competition. These scores may or may not include the current score. To calculate the total score, use 'score', because internally the scores are not stored as number scores.

rating

        $member->rating

Sets/gets the rating of the contestant, an estimate of their strength. The constructor assumes if no rating or a non-numeric rating is given, that they don't have a rating, and it is set to 0.

play

        $games = $member->play;
        $games = $member->play(
                { 1 => { opponent => $grandmaster, result => 'Loss' } });

Sets/gets a hash reference to the result of the pairings in each of the rounds played so far. Don't use this to enter a player's match result. Use $p->writeCard instead. Implementation: The keys of the hash are the round numbers and the values are themselves hash references, to the other player and whether the result was a 'Win', 'Loss', or 'Draw', with as keys, 'opponent' and 'result', NO. I think it is the gamecard of the player in that round. Or is that the play accessor for tournaments?

id

        $member->id

Returns/sets the id of the contestant, a number unique to the member.

AUTHOR

Dr Bean, <drbean, followed by the at mark (@), cpan, then a dot, and finally, org>

BUGS

Please report any bugs or feature requests to bug-games-tournament-contestant at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Tournament-Swiss. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Games::Tournament::Contestant

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2006 Dr Bean, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.