Games-Euchre

 view release on metacpan or  search on metacpan

lib/Games/Euchre/Player.pm  view on Meta::CPAN

use strict;
use warnings;
use Scalar::Util;
use Games::Cards;

=head1 CLASS METHODS

=over 4

=item new GAME NUMBER NAME

Create and initialize a new Euchre player.  The number is 1-4.

=cut

sub new {
   my $pkg = shift;
   my $game = shift;
   my $number = shift; # 1-based
   my $name = shift;
   my $self =  bless({
      game => $game,
      number => $number,
      name => $name,
      hand => undef,
      team => undef,
      ai => undef,
      alone => undef,
      bid => undef,
   }, $pkg);
   return $self;
}

=back

=head1 INSTANCE METHODS

=over 4

=item getGame

Return the Euchre game instance to which this player belongs.

=cut

sub getGame {
   my $self = shift;
   return $self->{game};
}

=item setTeam TEAM

Record the Team instance that this player belongs to.

=cut

sub setTeam {
   my $self = shift;
   my $team = shift;
   $self->{team} = $team;
   weaken($self->{team}); # break anti-GC loop
   return $self;
}

=item getTeam

Return the Team instance to which this player belongs.

=cut

sub getTeam {
   my $self = shift;
   return $self->{team};
}

=item setAI AI

Record the AI instance for this player.

=cut

sub setAI {
   my $self = shift;
   my $ai = shift;
   $self->{ai} = $ai;
   return $self;
}

=item getAI

Return the AI instance for this player.

=cut

sub getAI {
   my $self = shift;
   return $self->{ai};
}

=item setAlone

Indicate that this player has chosen to go alone in the current hand.

=cut

sub setAlone {
   my $self = shift;
   $self->{alone} = 1;
   return $self;
}

=item setBid

Indicate that this player has chosen to choose trump in the current hand.

=cut

sub setBid {
   my $self = shift;
   $self->{bid} = 1;
   return $self;



( run in 2.073 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )