# Deck (vilya 1.3 API)
Date: 2011-04-06

## 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 Class Summary

Nested classes/interfaces inherited from interface com.threerings.io.Streamable
`com.threerings.io.Streamable.Closure`

Field Summary

Fields inherited from interface com.threerings.parlor.card.data.CardCodes
`ACE, BLACK_JOKER, CLUBS, DIAMONDS, HEARTS, JACK, KING, QUEEN, RED_JOKER, SPADES`

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`

Methods inherited from class java.util.AbstractList
`equals, hashCode, iterator, listIterator, listIterator, subList`

Methods inherited from class java.util.AbstractCollection
`containsAll, removeAll, retainAll, toString`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.List
`containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList`

Constructor Detail

### 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

Method Detail

### 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.