au.com.solidsoftware.multimahjong.mmc.game
Class PayoutInfo

java.lang.Object
  |
  +--au.com.solidsoftware.multimahjong.mmc.game.PayoutInfo

public class PayoutInfo
extends java.lang.Object

The PayoutInfo class acts as an interpreter between the Payout object and the PayoutGUI object. It generates all the required text for the PayoutGUI object so that it can then display this to the user.

Author:
Joel Brakey
See Also:
Payout, PayoutGUI, Game

Field Summary
private static int ALL_KONG
          Represents a unique value for an All Kong (Nine Gates) Special Hand
private static int ALL_WINDS_AND_DRAGS
          Represents a unique value for an All Winds and Dragons Special Hand
(package private)  int[] consecutiveChows
          Used to reflect whether or not the hand contained consecutive sets of Chows.
(package private)  boolean[] doubleFlags
          Holds flags required for displaying scoring information required for an Ordinary Suit Hand.
(package private)  int[] doubleInfo
          Holds further information required to generate the scoring information of an Ordinary Suit Hand.
private static int FOUR_BIG_WINDS
          Represents a unique value for a Four Big Winds Special Hand
private static int FOUR_LITTLE_WINDS
          Represents a unique value for a Four Little Winds Special Hand
(package private)  boolean[] gameDoubleFlags
          Holds additional flags required for scoring information of an Ordinary Suit Hand.
(package private)  int[] groundInfo
          Holds information pertaining to the ground score information for an Ordinary Suit Hand.
(package private)  int handLimit
          The maximum score for any given hand.
private static int HEADS_AND_TAILS
          Represents a unique value for a Heads and Tails Special Hand
private static int IMPERIAL_JADE
          Represents a unique value for an Imperial Jade Special Hand
(package private)  int lastPickup
          Indicates where in the game the winning player picked up their last tile from.
static int MAX_DOUBLES_SIZE
          Indicates the maximum number of items which can be displayed concerning the doubles of an Ordinary Suit Hand.
static int MAX_GROUND_SCORE_SIZE
          Indicates the maximum number of items which can be displayed concerning the ground score of an Ordinary Suit Hand.
private static int MIXED_PUNG
          Represents a unique value for a Mixed Pung Special Hand
(package private)  PayoutGUI payoutPanel
          Creates an instance of the PayoutGUI object.
(package private)  int score
          Holds the total score of the winning player's hand
(package private)  int specialHand
          Indicates the type of Special Hand that the player has won with, or is set to NONE to indicate that the player has won with an Ordinary Suit Hand.
private static int THREE_GREAT_SCHOLARS
          Represents a unique value for a Three Great Scholars Hand
 
Constructor Summary
PayoutInfo()
           
 
Method Summary
 void adjustInfo(int[] payoutInfo, java.lang.String[] playerNames, int[] playerWinds, int winnersPos, int totalScore, int specHand, int lastPick, int[] grdInf, boolean[] doubFlags, boolean[] gameDoubFlags, int[] doubInfo, int[] consChows, int limit, int theTotalPayout)
          Gathers all info required to generate what's to be shown by the PayoutGUI object.
private  void printPayout(int[] payoutInfo, java.lang.String[] playerNames, int[] playerWinds, int winnersPos, int theTotalPayout)
          Provides the PayoutGUI object with all information it requires concerning the payout which has been made to the winner.
 void printScore(Game gameReference, Set[] concealedSets, Set[] exposedSets)
          Sets up all information that is required to be displayed in the Payout Window.
 void printSpecialScore(Game gameReference, Tile[] concealedHand, Set[] exposedSets)
          Sets up all information that is required to be displayed in the Payout Window.
private  void setupDoublesInfo()
          Sets up a 2D array of Strings which shows all doubles have been earnt for the winner's hand.
private  void setupGroundScoreInfo()
          Sets up a 2D String array that contains the ground score item and score corresponding to this ground score item in order to be displayed in the ground score JTable of the Payout Window.
private  void setupSpecialHand()
          Gives the PayoutGUI object the kind of special hand which the winner won with and the description of how it's achieved.
private  java.lang.String windIdToString(int windID)
          Converts a windID into it's corresponding String for the loser's table.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

IMPERIAL_JADE

private static final int IMPERIAL_JADE
Represents a unique value for an Imperial Jade Special Hand

ALL_KONG

private static final int ALL_KONG
Represents a unique value for an All Kong (Nine Gates) Special Hand

ALL_WINDS_AND_DRAGS

private static final int ALL_WINDS_AND_DRAGS
Represents a unique value for an All Winds and Dragons Special Hand

HEADS_AND_TAILS

private static final int HEADS_AND_TAILS
Represents a unique value for a Heads and Tails Special Hand

MIXED_PUNG

private static final int MIXED_PUNG
Represents a unique value for a Mixed Pung Special Hand

FOUR_BIG_WINDS

private static final int FOUR_BIG_WINDS
Represents a unique value for a Four Big Winds Special Hand

FOUR_LITTLE_WINDS

private static final int FOUR_LITTLE_WINDS
Represents a unique value for a Four Little Winds Special Hand

THREE_GREAT_SCHOLARS

private static final int THREE_GREAT_SCHOLARS
Represents a unique value for a Three Great Scholars Hand

score

int score
Holds the total score of the winning player's hand

specialHand

int specialHand
Indicates the type of Special Hand that the player has won with, or is set to NONE to indicate that the player has won with an Ordinary Suit Hand.

lastPickup

int lastPickup
Indicates where in the game the winning player picked up their last tile from. Uses symbolic constants defined in the Payout Object to specify these locations.

groundInfo

int[] groundInfo
Holds information pertaining to the ground score information for an Ordinary Suit Hand. It is passed in by the Payout object.

doubleFlags

boolean[] doubleFlags
Holds flags required for displaying scoring information required for an Ordinary Suit Hand.

gameDoubleFlags

boolean[] gameDoubleFlags
Holds additional flags required for scoring information of an Ordinary Suit Hand.

doubleInfo

int[] doubleInfo
Holds further information required to generate the scoring information of an Ordinary Suit Hand.

consecutiveChows

int[] consecutiveChows
Used to reflect whether or not the hand contained consecutive sets of Chows.

handLimit

int handLimit
The maximum score for any given hand.

payoutPanel

PayoutGUI payoutPanel
Creates an instance of the PayoutGUI object. This is used to display a break down of the scoring and payout information for the winning hand.

MAX_GROUND_SCORE_SIZE

public static final int MAX_GROUND_SCORE_SIZE
Indicates the maximum number of items which can be displayed concerning the ground score of an Ordinary Suit Hand.

MAX_DOUBLES_SIZE

public static final int MAX_DOUBLES_SIZE
Indicates the maximum number of items which can be displayed concerning the doubles of an Ordinary Suit Hand.
Constructor Detail

PayoutInfo

public PayoutInfo()
Method Detail

printSpecialScore

public void printSpecialScore(Game gameReference,
                              Tile[] concealedHand,
                              Set[] exposedSets)
Sets up all information that is required to be displayed in the Payout Window. It then calls an instance of PayoutGUI in order to display this data to the user.
Parameters:
gameReference - A reference to the Game so that it can't proceed until the user's clicked "OK" to close the Payout Window.
concealedSets - Lists the concealed sets contained in the winning player's hand.
exposedSets - Lists the exposed sets contained in the winning player's hand.

printScore

public void printScore(Game gameReference,
                       Set[] concealedSets,
                       Set[] exposedSets)
Sets up all information that is required to be displayed in the Payout Window. It then calls an instance of PayoutGUI in order to display this data to the user.
Parameters:
gameReference - A reference to the Game so that it can't proceed until the user's clicked "OK" to close the Payout Window.
concealedSets - Lists the concealed sets contained in the winning player's hand.
exposedSets - Lists the exposed sets contained in the winning player's hand.

setupGroundScoreInfo

private void setupGroundScoreInfo()
Sets up a 2D String array that contains the ground score item and score corresponding to this ground score item in order to be displayed in the ground score JTable of the Payout Window. This is provided that the winner has won with an Ordinary Suit Hand.

setupDoublesInfo

private void setupDoublesInfo()
Sets up a 2D array of Strings which shows all doubles have been earnt for the winner's hand.

setupSpecialHand

private void setupSpecialHand()
Gives the PayoutGUI object the kind of special hand which the winner won with and the description of how it's achieved.

printPayout

private void printPayout(int[] payoutInfo,
                         java.lang.String[] playerNames,
                         int[] playerWinds,
                         int winnersPos,
                         int theTotalPayout)
Provides the PayoutGUI object with all information it requires concerning the payout which has been made to the winner.
Parameters:
payoutInfo - An array of the payouts.
playerNames - An array of the player's names.
playerWinds - An array of the player's winds.
winnersPos - The position of the winner's details in all of the other parameter arrays of the printPayout method.
totalPayout - The total payout made to the winner.

windIdToString

private java.lang.String windIdToString(int windID)
Converts a windID into it's corresponding String for the loser's table.
Parameters:
windID - A wind ID.
Returns:
The String representation of the windID.

adjustInfo

public void adjustInfo(int[] payoutInfo,
                       java.lang.String[] playerNames,
                       int[] playerWinds,
                       int winnersPos,
                       int totalScore,
                       int specHand,
                       int lastPick,
                       int[] grdInf,
                       boolean[] doubFlags,
                       boolean[] gameDoubFlags,
                       int[] doubInfo,
                       int[] consChows,
                       int limit,
                       int theTotalPayout)
Gathers all info required to generate what's to be shown by the PayoutGUI object.
Parameters:
payoutInfo - Details of the payouts by all players.
playerNames - The names of all players.
playerWinds - The winds of all players.
winnersPos - The position of the winner in the payoutInfo, playerNames and playerWinds arrays.
totalScore - The total score for the winning hand.
specHand - The type of special hand.
lastPick - Where the last tile was picked up from.
grdInf - Information concerning the ground score of an Ordinary Suit Hand.
doubFlags - Flags concerning doubles applicable to the hand, set by the Payout object.
gameDoubleFlags - Further flags concerning doubles, but these are Game generated flags.
doubInfo - Information concerning doubles.
consChows - Information concerning consecutive chows.
limit - The set limit on any given hand.
theTotalPayout - The total payout made to the winner.