Ez game stuff, javafied.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@63 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.threerings.ezgame;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 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 CardDeck (EZGame gameObj)
|
||||
{
|
||||
this(gameObj, "deck");
|
||||
}
|
||||
|
||||
public CardDeck (EZGame gameObj, String deckName)
|
||||
{
|
||||
_gameObj = gameObj;
|
||||
_deckName = deckName;
|
||||
|
||||
ArrayList<String> deck = new ArrayList<String>();
|
||||
for (String rank : new String[] { "2", "3", "4", "5", "6", "7", "8",
|
||||
"9", "T", "J", "Q", "K", "A" }) {
|
||||
for (String suit : new String[] { "c", "d", "h", "s" }) {
|
||||
deck.add(rank + suit);
|
||||
}
|
||||
}
|
||||
|
||||
_gameObj.setCollection(_deckName, deck);
|
||||
}
|
||||
|
||||
public void dealToPlayer (int playerIdx, int count, String msgName)
|
||||
{
|
||||
// TODO: support the callback
|
||||
_gameObj.dealFromCollection(_deckName, count, msgName, null, playerIdx);
|
||||
}
|
||||
|
||||
public void dealToData (int count, String propName)
|
||||
{
|
||||
_gameObj.dealFromCollection(_deckName, count, propName, null);
|
||||
}
|
||||
|
||||
/** The game object. */
|
||||
protected EZGame _gameObj;
|
||||
|
||||
/** The name of our deck. */
|
||||
protected String _deckName;
|
||||
}
|
||||
Reference in New Issue
Block a user