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

## com.threerings.parlor.card.client
Class CardGameController

    java.lang.Object
      com.samskivert.swing.Controller
          com.threerings.crowd.client.PlaceController
              com.threerings.parlor.game.client.GameController
                  com.threerings.parlor.card.client.CardGameController

All Implemented Interfaces:
  CardGameReceiver, CardCodes, TurnGameController, com.threerings.presents.client.InvocationReceiver, com.threerings.presents.data.InvocationCodes, com.threerings.presents.dobj.AttributeChangeListener, com.threerings.presents.dobj.ChangeListener, ActionListener, EventListener

    public abstract class CardGameController

extends GameController
implements TurnGameController, CardCodes, CardGameReceiver

A controller class for card games. Handles common functions like accepting dealt hands.

Nested Class Summary

Nested classes/interfaces inherited from class com.threerings.crowd.client.PlaceController
`com.threerings.crowd.client.PlaceController.DelegateOp`

Nested classes/interfaces inherited from interface com.threerings.presents.client.InvocationReceiver
`com.threerings.presents.client.InvocationReceiver.Registration`

Field Summary

Fields inherited from class com.samskivert.swing.Controller
`DISPATCHER`

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
`CardGameController()`

Method Summary
`void` `cardsTransferredBetweenPlayers(int fromidx, int toidx, int cards)` Dispatched to the client when a set of cards is transferred between two other players in the game.
`void` `didLeavePlace(com.threerings.crowd.data.PlaceObject plobj)` Removes our listener registration from the game object and cleans house.
`void` `receivedCardsFromPlayer(int plidx, Card[] cards)` Dispatched to the client when it has received a set of cards from another player.
`void` `receivedHand(Hand hand)` Called when the server deals the client a new hand of cards.
`void` `receivedHand(int oid, Hand hand)` Called by our sender to notify us of a received hand.
`void` `sentCardsToPlayer(int plidx, Card[] cards)` Dispatched to the client when the server has forced it to send a set of cards to another player.
`void` `turnDidChange(com.threerings.util.Name turnHolder)` Called when the turn changed.
`void` `willEnterPlace(com.threerings.crowd.data.PlaceObject plobj)` Adds this controller as a listener to the game object (thus derived classes need not do so) and lets the game manager know that we are now ready to go.

Methods inherited from class com.threerings.parlor.game.client.GameController
`attributeChanged, getMatchType, getSessionId, handleAction, init, isGameOver, resetGame, setGameOver, systemMessage`

Methods inherited from class com.threerings.crowd.client.PlaceController
`getPlaceConfig, getPlaceView, mayLeavePlace`

Methods inherited from class com.samskivert.swing.Controller
`actionPerformed, configureAction, createActionButton, handleAction, handleAction, handleAction, postAction, postAction, postAction, setControlledPanel, wasAdded, wasRemoved`

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

Constructor Detail

### CardGameController

    public CardGameController()

Method Detail

### willEnterPlace

    public void willEnterPlace(com.threerings.crowd.data.PlaceObject plobj)

  Description copied from class: `GameController`
  Adds this controller as a listener to the game object (thus derived classes need not do so) and lets the game manager know that we are now ready to go.

  Overrides:
    `willEnterPlace` in class `GameController`

### didLeavePlace

    public void didLeavePlace(com.threerings.crowd.data.PlaceObject plobj)

  Description copied from class: `GameController`
  Removes our listener registration from the game object and cleans house.

  Overrides:
    `didLeavePlace` in class `GameController`

### turnDidChange

    public void turnDidChange(com.threerings.util.Name turnHolder)

  Description copied from interface: `TurnGameController`
  Called when the turn changed. This indicates the start of a turn and the user interface should adjust itself accordingly (activating controls if it is our turn and deactivating them if it is not).

  Specified by:
    `turnDidChange` in interface `TurnGameController`
  Parameters:
    `turnHolder` - the username of the new holder of the turn.

### receivedHand

    public final void receivedHand(int oid,
                                   Hand hand)

  Called by our sender to notify us of a received hand.

  Specified by:
    `receivedHand` in interface `CardGameReceiver`
  Parameters:
    `oid` - the oid of the game for which this hand applies
    `hand` - the received hand

### receivedHand

    public void receivedHand(Hand hand)

  Called when the server deals the client a new hand of cards. Default implementation does nothing.

  Parameters:
    `hand` - the hand dealt to the user

### receivedCardsFromPlayer

    public void receivedCardsFromPlayer(int plidx,
                                        Card[] cards)

  Dispatched to the client when it has received a set of cards from another player. Default implementation does nothing.

  Specified by:
    `receivedCardsFromPlayer` in interface `CardGameReceiver`
  Parameters:
    `plidx` - the index of the player providing the cards
    `cards` - the cards received

### sentCardsToPlayer

    public void sentCardsToPlayer(int plidx,
                                  Card[] cards)

  Dispatched to the client when the server has forced it to send a set of cards to another player. Default implementation does nothing.

  Specified by:
    `sentCardsToPlayer` in interface `CardGameReceiver`
  Parameters:
    `plidx` - the index of the player to which the cards were sent
    `cards` - the cards sent

### cardsTransferredBetweenPlayers

    public void cardsTransferredBetweenPlayers(int fromidx,
                                               int toidx,
                                               int cards)

  Dispatched to the client when a set of cards is transferred between two other players in the game. Default implementation does nothing.

  Specified by:
    `cardsTransferredBetweenPlayers` in interface `CardGameReceiver`
  Parameters:
    `fromidx` - the index of the player sending the cards
    `toidx` - the index of the player receiving the cards
    `cards` - the number of cards transferred

Copyright © 2011. All Rights Reserved.