| Package | com.whirled.contrib.card |
| Class | public class CardArray |
| Inheritance | CardArray flash.events.EventDispatcher |
| Property | Defined by | ||
|---|---|---|---|
| cards : Array [read-only] Access the underlying array of card objects.
| CardArray | ||
| length : int [read-only] Access to the length of the array.
| CardArray | ||
| ordinals : Array [read-only] Access the underlying array of ordinal values.
| CardArray | ||
| Property | Defined by | ||
|---|---|---|---|
| _cards : Array The Card objects.
| CardArray | ||
| _ordinals : Array The ordinals.
| CardArray | ||
| Method | Defined by | ||
|---|---|---|---|
|
CardArray(ordinals:Array = null)
Create a new array of cards.
| CardArray | ||
|
Returns a new CardArray consisting of the contents of this array for which the given
callback evaluates to true.
| CardArray | ||
|
Test if a card (of the same value) is in the array
| CardArray | ||
|
Get the index of a card in the array, or -1 if not present.
| CardArray | ||
|
Insert a new card into the array.
| CardArray | ||
|
[static] Create a new full deck.
| CardArray | ||
|
Add a new card to the end.
| CardArray | ||
|
pushOrdinal(ordinal:int):void
Add a new card to the end by ordinal value.
| CardArray | ||
|
Remove a card from the array.
| CardArray | ||
|
reset(ordinals:Array = null):void
Reset the contents of the array.
| CardArray | ||
|
shortFilter(callback:Function):CardArray
Returns a new CardArray consisting of the contents of this array for which the given
callback evaluates to true.
| CardArray | ||
|
sortedInsert(card:Card, suits:Array, ordering:int):void
Insert a card into the array such that sorting is maintained.
| CardArray | ||
|
standardSort(suits:Array, ordering:int):void
Sort the array in place for player's ease of use.
| CardArray | ||
|
toString():String
| CardArray | ||
| Method | Defined by | ||
|---|---|---|---|
|
setOrdinals(ordinals:Array):void
Set the ordinal values, no event sending.
| CardArray | ||
| _cards | property |
protected var _cards:ArrayThe Card objects.
| cards | property |
cards:Array [read-only]Access the underlying array of card objects.
Implementation public function get cards():Array
| length | property |
length:int [read-only]Access to the length of the array.
Implementation public function get length():int
| _ordinals | property |
protected var _ordinals:ArrayThe ordinals.
| ordinals | property |
ordinals:Array [read-only]Access the underlying array of ordinal values.
Implementation public function get ordinals():Array
| CardArray | () | constructor |
public function CardArray(ordinals:Array = null)Create a new array of cards.
Parametersordinals:Array (default = null) — optional array of ordinal values for initial contents
|
— if any contents are not valid.
|
| filter | () | method |
public function filter(callback:Function):CardArrayReturns a new CardArray consisting of the contents of this array for which the given callback evaluates to true. The callback should have signature: function callback (card :Card, index :int, array :CardArray) :Boolean For example, the following function will return all queens: function findQueens (array :CardArray) :CardArray { return array.filter( function ( card :Card, index :int, array :CardArray) :Boolean { return card.rank == Card.QUEEN; }); }
Parameterscallback:Function |
CardArray |
| has | () | method |
public function has(card:Card):BooleanTest if a card (of the same value) is in the array
Parameterscard:Card |
Boolean |
| indexOf | () | method |
public function indexOf(card:Card):intGet the index of a card in the array, or -1 if not present.
Parameterscard:Card |
int |
| insert | () | method |
public function insert(card:Card, index:int):voidInsert a new card into the array.
Parameterscard:Card |
|
index:int |
| makeDeck | () | method |
public static function makeDeck():CardArrayCreate a new full deck. Users may modify the result.
ReturnsCardArray |
| push | () | method |
| pushOrdinal | () | method |
public function pushOrdinal(ordinal:int):voidAdd a new card to the end by ordinal value.
Parametersordinal:int |
| remove | () | method |
public function remove(card:Card):voidRemove a card from the array.
Parameterscard:Card |
— if the card is not present. |
| reset | () | method |
public function reset(ordinals:Array = null):voidReset the contents of the array.
Parametersordinals:Array (default = null) — optional array of ordinal values for the new contents
|
— if any ordinals are not valid. |
| setOrdinals | () | method |
protected function setOrdinals(ordinals:Array):voidSet the ordinal values, no event sending.
Parametersordinals:Array |
| shortFilter | () | method |
public function shortFilter(callback:Function):CardArrayReturns a new CardArray consisting of the contents of this array for which the given callback evaluates to true. The callback should have signature: function callback (card :Card) :Boolean This is a more terse alternative to the more standard-compliant "filter" method. For example, the following function will return all queens: function findQueens (array :CardArray) :CardArray { return array.filter( function ( card :Card) :Boolean { return card.rank == Card.QUEEN; }); }
Parameterscallback:Function |
CardArray |
| sortedInsert | () | method |
public function sortedInsert(card:Card, suits:Array, ordering:int):voidInsert a card into the array such that sorting is maintained. The array must previously be sorted with the same parameters.
Parameterscard:Card — the card to insert
|
|
suits:Array — an Array of Card.SUIT_constants indicating the desired order of suits
|
|
ordering:int — one of the Card.RANK_ORDER_constants indicating how to order the ranks |
| standardSort | () | method |
public function standardSort(suits:Array, ordering:int):voidSort the array in place for player's ease of use. Suits are the primary key and ranks secondary.
Parameterssuits:Array — an Array of Card.SUIT_constants indicating the desired order of suits
|
|
ordering:int — one of the Card.RANK_ORDER_constants indicating how to order the ranks |
| toString | () | method |
public override function toString():StringReturns
String |