Chris Dolan > Games-Euchre > Games::Euchre::Trick

Download:
Games-Euchre-1.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Games::Euchre::Trick - Trick class for Euchre card game

DESCRIPTION ^

Only one Trick instance is alive at one time per Euchre game. The Trick keeps track of which cards have been played, and provides useful functions to determine which cards are legal plays, as well as who is the winner of the trick. The trick class makes the determination of which card beats which card, given the current trump and lead. The trick class knows how to handle an alone hand and it calls the playCard() method for each player in turn in it's play() method, usually called from the Games::Euchre->playHand() method.

CLASS METHODS ^

new GAME LEAD NAME NUMBER

Create and initialize a new Euchre trick. The lead is a Games::Euchre::Player instance. The name is any string. The number is a one-based index of which trick this is (from 1 to 5).

CLASS METHODS ^

getGame

Return the Euchre game instance to which this trick belongs.

getName

Return the name of this trick.

getNumber

Return the number of this trick (from 1 to 5).

getHand

Return the Games::Cards::Hand object representing this trick.

getCards

Return an array of the Games::Cards::Card objects played in this trick.

getPlayers

Return an array of the players in the order they will play in this trick. If someone went alone, this array will have three entries. Otherwise it will always have four.

getPlayerIndex PLAYER

Returns the 0-based index of the specified player in the order that he would play in the current trick. This is crucial for figuring out who played which card. Returns undef in the case that the player did not play (yet, or not at all if the partner went alone).

recordTrick

Record the result of this trick by informing the winning team.

getWinner

Returns the player who played the card that won the trick.

cmpCards CARD1 CARD2

Returns -1, 0, or 1 indicating the relative rank of the two cards. Like the string 'cmp' operator -1 means that CARD2 beats CARD1, 1 means that CARD1 beats CARD2 and 0 means that they are equivalent (i.e. both worthless!).

play

Calls the playCard() method for the player whose turn it is to play.

isLegalPlay PLAYER CHOICE

Returns a boolean indicating whether the selected card to play is legal, given the specified player's hand. CHOICE is a 0-based index into the array of cards held by the player's hand.

Checks if the choice is an actual card in the player's hand and whether the card follows suit.

SEE ALSO ^

Games::Euchre

LICENSE ^

GNU Public License, version 2

AUTHOR ^

Chris Dolan, chrisdolan@users.sourceforge.net

syntax highlighting: