Files
vilya/src/as/com/threerings/ezgame/CardDeck.as
T
Ray Greenwell 3b08974f73 Revamped EZGame to work over the security boundary.
Now, instead of implementing "Game" and having the EZGame object assigned
to you, you create it yourself using your top-level component.

You must register listeners manually, and keyboard focus is currently an
issue that I'm working on.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@137 c613c5cb-e716-0410-b11b-feb51c14d237
2007-01-05 18:59:08 +00:00

44 lines
1.2 KiB
ActionScript

package com.threerings.ezgame {
/**
* A simple card deck that encodes cards as a string like "Ac" for the
* ace of clubs, or "Td" for the 10 of diamonds.
*/
public class CardDeck
{
public function CardDeck (gameCtrl :EZGameControl, deckName :String = "deck")
{
_gameCtrl = gameCtrl;
_deckName = deckName;
var deck :Array = new Array();
for each (var rank :String in ["2", "3", "4", "5", "6", "7", "8",
"9", "T", "J", "Q", "K", "A"]) {
for each (var suit :String in ["c", "d", "h", "s"]) {
deck.push(rank + suit);
}
}
_gameCtrl.setCollection(_deckName, deck);
}
public function dealToPlayer (
playerIdx :int, count :int, msgName :String) :void
{
// TODO: support the callback
_gameCtrl.dealFromCollection(_deckName, count, msgName, null, playerIdx);
}
public function dealToData (count :int, propName :String) :void
{
_gameCtrl.dealFromCollection(_deckName, count, propName, null);
}
/** The game control. */
protected var _gameCtrl :EZGameControl;
/** The name of our deck. */
protected var _deckName :String;
}
}