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

## com.threerings.parlor.card.trick.util
Class TrickCardGameUtil

    java.lang.Object
      com.threerings.parlor.card.trick.util.TrickCardGameUtil

All Implemented Interfaces:
  CardCodes, TrickCardCodes, com.threerings.presents.data.InvocationCodes

    public class TrickCardGameUtil

extends Object
implements TrickCardCodes

Methods of general utility to trick-taking card games.

Field Summary

Fields inherited from interface com.threerings.parlor.card.trick.data.TrickCardCodes
`BOTTOM, LEFT, RIGHT, TOP`

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

Method Summary
`static boolean` `canFollowSuit(PlayerCard[] cardsPlayed, Hand hand)` Checks whether the player can follow the suit lead with the hand given.
`static boolean` `containsCard(PlayerCard[] cards, Card card)` Checks whether the specified array contains the given card.
`static int` `countSuitMembers(PlayerCard[] cards, int suit)` Determines the number of cards that belong to the specified suit within the array given.
`static boolean` `followsSuit(PlayerCard[] cardsPlayed, Card card)` Checks whether the proposed card follows the suit lead.
`static PlayerCard` `getHighestInLeadSuit(PlayerCard[] cardsPlayed, int trumpSuit)` Returns the highest card (according to the standard A,K,...,2 ordering) in the suit lead, with an optional trump suit.
`static int` `getLeftIndex(int pidx)` For four-player games, returns the index of the player to the left of the specified player.
`static int` `getNextInClockwiseSequence(int pidx)` For four-player games, this returns the index of the player after the specified player going clockwise around the table.
`static int` `getOppositeIndex(int pidx)` For four-player games, returns the index of the player across from the specified player.
`static int` `getOtherTeamIndex(int tidx)` For four-player games with fixed partnerships, this returns the index of the other team.
`static int` `getPartnerIndex(int pidx)` For four-player games with fixed partnerships, this returns the index of the player's partner.
`static int` `getRelativeLocation(int pidx1, int pidx2)` For four-player games with fixed partnerships, this returns the relative location of one player from the point of view of another.
`static int` `getRightIndex(int pidx)` For four-player games, returns the index of the player to the right of the specified player.
`static int` `getTeamIndex(int pidx)` For four-player games with fixed partnerships, this returns the index of the player's team.
`static int` `getTeamMemberIndex(int tidx, int midx)` For four-player games with fixed partnerships, this returns the index of one of the members of a team.

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

Constructor Detail

### TrickCardGameUtil

    public TrickCardGameUtil()

Method Detail

### getTeamIndex

    public static int getTeamIndex(int pidx)

  For four-player games with fixed partnerships, this returns the index of the player's team.

  Parameters:
    `pidx` - the player index

### getOtherTeamIndex

    public static int getOtherTeamIndex(int tidx)

  For four-player games with fixed partnerships, this returns the index of the other team.

  Parameters:
    `tidx` - the index of the team

### getPartnerIndex

    public static int getPartnerIndex(int pidx)

  For four-player games with fixed partnerships, this returns the index of the player's partner.

### getTeamMemberIndex

    public static int getTeamMemberIndex(int tidx,
                                         int midx)

  For four-player games with fixed partnerships, this returns the index of one of the members of a team.

  Parameters:
    `tidx` - the index of the team
    `midx` - the index of the player within the team

### getNextInClockwiseSequence

    public static int getNextInClockwiseSequence(int pidx)

  For four-player games, this returns the index of the player after the specified player going clockwise around the table.

### getRelativeLocation

    public static int getRelativeLocation(int pidx1,
                                          int pidx2)

  For four-player games with fixed partnerships, this returns the relative location of one player from the point of view of another.

  Parameters:
    `pidx1` - the index of the player to whom the location is relative
    `pidx2` - the index of the player whose location is desired
  Returns:
    the relative location (TOP, BOTTOM, LEFT, or RIGHT)

### getLeftIndex

    public static int getLeftIndex(int pidx)

  For four-player games, returns the index of the player to the left of the specified player.

### getRightIndex

    public static int getRightIndex(int pidx)

  For four-player games, returns the index of the player to the right of the specified player.

### getOppositeIndex

    public static int getOppositeIndex(int pidx)

  For four-player games, returns the index of the player across from the specified player.

### canFollowSuit

    public static boolean canFollowSuit(PlayerCard[] cardsPlayed,
                                        Hand hand)

  Checks whether the player can follow the suit lead with the hand given.

### containsCard

    public static boolean containsCard(PlayerCard[] cards,
                                       Card card)

  Checks whether the specified array contains the given card.

### countSuitMembers

    public static int countSuitMembers(PlayerCard[] cards,
                                       int suit)

  Determines the number of cards that belong to the specified suit within the array given.

### followsSuit

    public static boolean followsSuit(PlayerCard[] cardsPlayed,
                                      Card card)

  Checks whether the proposed card follows the suit lead.

### getHighestInLeadSuit

    public static PlayerCard getHighestInLeadSuit(PlayerCard[] cardsPlayed,
                                                  int trumpSuit)

  Returns the highest card (according to the standard A,K,...,2 ordering) in the suit lead, with an optional trump suit.

  Parameters:
    `trumpSuit` - the trump suit, or -1 for none

Copyright © 2011. All Rights Reserved.