com.threerings.parlor.card.data
Class Deck
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
com.threerings.util.StreamableArrayList<Card>
com.threerings.parlor.card.data.Deck
- All Implemented Interfaces:
- com.threerings.io.Streamable, CardCodes, com.threerings.presents.data.InvocationCodes, Serializable, Cloneable, Iterable<Card>, Collection<Card>, List<Card>, RandomAccess
public class Deck
- extends com.threerings.util.StreamableArrayList<Card>
- implements CardCodes
Instances of this class represent decks of cards.
- See Also:
- Serialized Form
| Nested classes/interfaces inherited from interface com.threerings.io.Streamable |
com.threerings.io.Streamable.Closure |
| Fields inherited from interface com.threerings.presents.data.InvocationCodes |
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR |
|
Constructor Summary |
Deck()
Default constructor creates an unshuffled deck of cards without
jokers. |
Deck(boolean includeJokers)
Constructor. |
|
Method Summary |
Hand |
dealHand(int size)
Deals a hand of cards from the deck. |
void |
reset(boolean includeJokers)
Resets the deck to its initial state: an unshuffled deck of
52 or 54 cards, depending on whether the jokers are included. |
void |
returnHand(Hand hand)
Returns a hand of cards to the deck. |
void |
shuffle()
Shuffles the deck. |
void |
shuffle(Random r)
Shuffles the deck. |
| Methods inherited from class com.threerings.util.StreamableArrayList |
newList, readObject, writeObject |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, set, size, toArray, toArray, trimToSize |
Deck
public Deck()
- Default constructor creates an unshuffled deck of cards without
jokers.
Deck
public Deck(boolean includeJokers)
- Constructor.
- Parameters:
includeJokers - whether or not to include the two jokers
in the deck
reset
public void reset(boolean includeJokers)
- Resets the deck to its initial state: an unshuffled deck of
52 or 54 cards, depending on whether the jokers are included.
- Parameters:
includeJokers - whether or not to include the two jokers
in the deck
shuffle
public void shuffle()
- Shuffles the deck.
shuffle
public void shuffle(Random r)
- Shuffles the deck.
dealHand
public Hand dealHand(int size)
- Deals a hand of cards from the deck.
- Parameters:
size - the size of the hand to deal
- Returns:
- the newly created and populated hand, or null
if there are not enough cards in the deck to deal the hand
returnHand
public void returnHand(Hand hand)
- Returns a hand of cards to the deck.
- Parameters:
hand - the hand of cards to return
Copyright © 2011. All Rights Reserved.