| Package | com.whirled.contrib.card |
| Class | public class Hand |
| Inheritance | Hand flash.events.EventDispatcher |
| Property | Defined by | ||
|---|---|---|---|
| cards : CardArray
[read-only] Access the underlying array of cards.
| Hand | ||
| hasPlayed : Boolean [read-only] Access whether or not some cards have been selected since the last call to beginTurn.
| Hand | ||
| isPassing : Boolean [read-only] Access whether the local player is currently passing.
| Hand | ||
| length : int [read-only] Access the number of cards in the hand.
| Hand | ||
| passCount : int [read-only] Access the numr of cards requested to be passed by the local player.
| Hand | ||
| passTarget : int [read-only] Access the target player for the local player's pass in progress.
| Hand | ||
| Property | Defined by | ||
|---|---|---|---|
| _cards : CardArray | Hand | ||
| _gameCtrl : GameControl | Hand | ||
| _hasPlayed : Boolean | Hand | ||
| _passCount : int | Hand | ||
| _passTarget : int | Hand | ||
| _prefix : String | Hand | ||
| _sorter : Sorter | Hand | ||
| Method | Defined by | ||
|---|---|---|---|
|
Create a new hand.
| Hand | ||
|
Allow the local player to play some cards from a given allowed set.
| Hand | ||
|
allowSelection(enabled:CardArray, count:int = 1):void
Allow the selection of cards, but not actually playing them.
| Hand | ||
|
dealFaceDownTo(id:int, numCards:int):void
Add some face down cards to a given player.
| Hand | ||
|
dealTo(playerId:int, numCards:int):void
Deal from the server's deck to one player.
| Hand | ||
|
disallowSelection():void
Disallow card selection, typically called when it is no longer the player's turn and there
is no reasonable selection he or she could make.
| Hand | ||
|
Pass the given cards to fulfill a pass request.
| Hand | ||
|
Play a single card.
| Hand | ||
|
Select some cards to play.
| Hand | ||
|
Reset the deck on the server to the given deck.
| Hand | ||
|
prepareAndDeal(deck:CardArray, numCards:int):void
Deal the given deck to all players, giving each player the same number of cards.
| Hand | ||
|
removeCard(card:Card):void
Remove a single card from the hand.
| Hand | ||
|
removeCards(cards:CardArray):void
Remove cards from the hand.
| Hand | ||
|
requestPass(fromPlayer:int, toPlayer:int, numCards:int):void
Request that one player pass some cards to another player.
| Hand | ||
| Method | Defined by | ||
|---|---|---|---|
|
handleMessage(event:MessageReceivedEvent):void
| Hand | ||
|
varName(name:String):String
| Hand | ||
| Constant | Defined by | ||
|---|---|---|---|
| DEALT : String = "hand.dealt" [static] Event message for getting cards.
| Hand | ||
| DEALT_FACE_DOWN : String = "hand.dealt.face.down" [static] Event message for getting face down cards.
| Hand | ||
| DECK : String = "hand.deck" [static] Name of bag for the deck.
| Hand | ||
| PASS_FULFILL : String = "hand.pass.fulfill" [static] Event message for receiving passed cards.
| Hand | ||
| PASS_NOTIFY : String = "hand.pass.notify" [static] Event message for notifying other players of the pass.
| Hand | ||
| PASS_REQUEST : String = "hand.pass.request" [static] Event message for receiving the pass request.
| Hand | ||
| _cards | property |
protected var _cards:CardArray
| cards | property |
cards:CardArray [read-only]Access the underlying array of cards. The caller MUST NOT modify the array directly.
Implementation public function get cards():CardArray
| _gameCtrl | property |
protected var _gameCtrl:GameControl
| _hasPlayed | property |
protected var _hasPlayed:Boolean
| hasPlayed | property |
hasPlayed:Boolean [read-only]Access whether or not some cards have been selected since the last call to beginTurn. This is necessary for the auto-play feature where cards are randomly selected by the controller if the player takes too long to make a move.
Implementation public function get hasPlayed():Boolean
| isPassing | property |
isPassing:Boolean [read-only]Access whether the local player is currently passing.
Implementation public function get isPassing():Boolean
| length | property |
length:int [read-only]Access the number of cards in the hand.
Implementation public function get length():int
| _passCount | property |
protected var _passCount:int
| passCount | property |
passCount:int [read-only]Access the numr of cards requested to be passed by the local player. 0 if no pass has been requested.
Implementation public function get passCount():int
| _passTarget | property |
protected var _passTarget:int
| passTarget | property |
passTarget:int [read-only]Access the target player for the local player's pass in progress. 0 if no pass has been requested.
Implementation public function get passTarget():int
| _prefix | property |
protected var _prefix:String
| _sorter | property |
protected var _sorter:Sorter
| Hand | () | constructor |
public function Hand(gameCtrl:GameControl, sorter:Sorter, prefix:String = null)Create a new hand.
ParametersgameCtrl:GameControl — the game control to use for table information and for networking
|
|
sorter:Sorter — the prefix to use for our server variables in case the rules require
multiple local hands
|
|
prefix:String (default = null) — applies an ordering to cards when they are dealt and prior |
| allowPlay | () | method |
public function allowPlay(enabled:CardArray, count:int = 1):voidAllow the local player to play some cards from a given allowed set. This is not a network event and immediately sends HandEvent.BEGAN_TURN.
Parametersenabled:CardArray |
|
count:int (default = 1) |
| allowSelection | () | method |
public function allowSelection(enabled:CardArray, count:int = 1):voidAllow the selection of cards, but not actually playing them. This is not a network event and immediately sends HandEvent.ALLOW_SELECT.
Parametersenabled:CardArray |
|
count:int (default = 1) |
| dealFaceDownTo | () | method |
public function dealFaceDownTo(id:int, numCards:int):voidAdd some face down cards to a given player.
Parametersid:int |
|
numCards:int |
| dealTo | () | method |
public function dealTo(playerId:int, numCards:int):voidDeal from the server's deck to one player.
ParametersplayerId:int — the player to deal to
|
|
numCards:int — number of cards to deal |
| disallowSelection | () | method |
public function disallowSelection():voidDisallow card selection, typically called when it is no longer the player's turn and there is no reasonable selection he or she could make. This is not a network event and immediately sends HandEvent.DISALLOWED_SELECTION.
| handleMessage | () | method |
protected function handleMessage(event:MessageReceivedEvent):voidParameters
event:MessageReceivedEvent |
| passCards | () | method |
public function passCards(cards:CardArray):voidPass the given cards to fulfill a pass request. The cards are sent to the pass target using a HandEvent.PASSED event. Other players are also notified via a HandEvent.PASSED event with no cards.
Parameterscards:CardArray |
| playCard | () | method |
public function playCard(card:Card):voidPlay a single card. Convenience function to call playCards with a CardArray containing only one card.
Parameterscard:Card |
| playCards | () | method |
public function playCards(cards:CardArray):voidSelect some cards to play. This is not a network event. It immediately sends a HandEvent.CARDS_PLAYED event.
Parameterscards:CardArray |
| prepare | () | method |
public function prepare(deck:CardArray):voidReset the deck on the server to the given deck. Note that this method should only be called by one of the players in the game (the one for which GameSubControl.amInControl returns true) or the server agent.
Parametersdeck:CardArray |
| prepareAndDeal | () | method |
public function prepareAndDeal(deck:CardArray, numCards:int):voidDeal the given deck to all players, giving each player the same number of cards. Leftover cards will be held on the server. Note that this method should only be called by one of the players in the game (the one for which GameSubControl.amInControl returns true) or the server agent. When the cards arrive to the player, each local hand will dispatch a HandEvent.DEALT message.
Parametersdeck:CardArray — the full deck of cards to store on the server
|
|
numCards:int — optional number of cards to deal to each player. If 0, cards are dealt
evenly
TODO: options for what to do with the leftover cards? |
| removeCard | () | method |
public function removeCard(card:Card):voidRemove a single card from the hand. Normally the controller will call this in conjunction with another call to place the card elsewhere on the table, return it to the deck, etc. Does not send any events.
Parameterscard:Card |
| removeCards | () | method |
public function removeCards(cards:CardArray):voidRemove cards from the hand. Normally the controller will call this in conjunction with another call to place the cards elsewhere on the table, return them to the deck, etc. Does not send any events.
Parameterscards:CardArray |
| requestPass | () | method |
public function requestPass(fromPlayer:int, toPlayer:int, numCards:int):voidRequest that one player pass some cards to another player. This will dispatch a HandEvent.PASS_REQUESTED event on the client who perform the pass and set the passTarget property to indicate the target player.
ParametersfromPlayer:int — the id of the player who is to perform the pass
|
|
toPlayer:int — the id of the player to receive the passed cards
|
|
numCards:int — the number of cards to pass |
| varName | () | method |
protected function varName(name:String):StringParameters
name:String |
String |
| DEALT | constant |
protected static const DEALT:String = "hand.dealt"Event message for getting cards.
| DEALT_FACE_DOWN | constant |
protected static const DEALT_FACE_DOWN:String = "hand.dealt.face.down"Event message for getting face down cards.
| DECK | constant |
protected static const DECK:String = "hand.deck"Name of bag for the deck.
| PASS_FULFILL | constant |
protected static const PASS_FULFILL:String = "hand.pass.fulfill"Event message for receiving passed cards.
| PASS_NOTIFY | constant |
protected static const PASS_NOTIFY:String = "hand.pass.notify"Event message for notifying other players of the pass.
| PASS_REQUEST | constant |
protected static const PASS_REQUEST:String = "hand.pass.request"Event message for receiving the pass request.