|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--au.com.solidsoftware.multimahjong.mmc.game.Payout
The Payout class is used for two purposes. Namely:
1) At the end of a hand the handlePayout method is
used to determine how much the winning player's hand scores
and how much all losing players must payout to the winner.
2) The handleScoring method will calculate the score
of a given hand, thus the Payout class can also
be used to compare the scores of different combinations of
hands.
PayoutInfo,
PayoutGUI,
Game| Field Summary | |
static int |
ALL_HONOUR
ALL_HONOUR is an element of the
doubleFlags array. |
private static int |
ALL_KONG
ALL_KONG is a symbolic constant for a position in the
boolean array checkSpecial. |
private static int |
ALL_WINDS_AND_DRAGS
ALL_WINDS_AND_DRAGS is a symbolic constant
for a position in the boolean array checkSpecial. |
static int |
AT_LEAST_DOUBLE
AT_LEAST_DOUBLE is an element of the
doubleFlags array. |
private boolean[] |
checkSpecial
Used to determine whether the hand is a special hand. |
static int |
CHOWS
CHOWS is a symbolic constant for a position in the
array of ints doubleInfo. |
static int |
CLEAN
CLEAN is an element of the doubleFlags
array. |
static int |
CONC_OTHER_SETS
CONC_OTHER_SETS is a symbolic constant for an
element in the array of ints groundInfo. |
static int |
CONC_SIMPLE_SETS
CONC_SIMPLE_SETS is a symbolic constant for an
element in the array of ints groundInfo. |
static int |
CONCEALED_MAHJONG
CONCEALED_MAHJONG is an element of the
gameDoubleFlags array. |
(package private) Tile[] |
concealedHand
Stores all of the Winner's concealed Sets of tiles. |
(package private) int[] |
consecutiveChows
Used in determining whether the hand has 3 consecutive chows, thus earning an extra double if it's an ordinary suit hand. |
static int |
DISCARD
DISCARD indicates the LAST_PICKUP was
from the discard of another player. |
(package private) int |
discardersPos
The position of the discarding player (if there was one) in the playerNames and playerWinds arrays. |
static int |
DOUBLE_SUIT
DOUBLE_SUIT is a symbolic constant for a position in
the array of ints doubleInfo. |
(package private) boolean[] |
doubleFlags
Used to determine what doubles apply to the hand if it's an Ordinary Suit hand. |
(package private) int[] |
doubleInfo
Used to store information required in determining what doubles apply to the hand if it's found to be an Ordinary Suit Hand by the Payout class (in the handleScoring
method). |
static int |
DRAGON_PAIR
DRAGON_PAIR is a state which EXTRA_PAIR
in the groundInfo array can take. |
static int |
DRAGON_SETS
DRAGON_SETS is a symbolic constant for a position in
the array of ints doubleInfo. |
static int |
EARTHS_GRACE
A symbolic constant for one of the values which the private integer specialHand can take. |
static int |
EXP_DOUBLE_SETS
EXP_DOUBLE_SETS is a symbolic constant for a
position in the array of ints doubleInfo. |
static int |
EXP_OTHER_SETS
EXP_OTHER_SETS is a symbolic constant for an element
in the array of ints groundInfo. |
static int |
EXP_SIMPLE_SETS
EXP_SIMPLE_SETS is a symbolic constant for an
element in the array of ints groundInfo. |
static int |
EXTRA_PAIR
EXTRA_PAIR is a symbolic constant for an element in
the array of ints groundInfo. |
static int |
FIRST_DISCARD_BONUS
FIRST_DISCARD_BONUS is an element of the
gameDoubleFlags array. |
private static int |
FOUR_BIG_WINDS
FOUR_BIG_WINDS is a symbolic constant for a position
in the boolean array checkSpecial. |
private static int |
FOUR_LITTLE_WINDS
FOUR_LITTLE_WINDS is a symbolic constant for a
position in the boolean array checkSpecial. |
(package private) boolean[] |
gameDoubleFlags
Stores information supplied by the Game required for
calculating the score of the hand. |
(package private) int[] |
gameInfo
Stores information supplied by the Game required for
calculating the score of the hand. |
static int |
GATES_OF_HEAVEN
A symbolic constant for one of the values which the private integer specialHand can take. |
static int |
GROUND_CM_BONUS
GROUND_CM_BONUS is an element of the
doubleFlags array. |
(package private) int[] |
groundInfo
Used to gather Ground Score Information for an Ordinary Suit Hand. |
private static int |
HEADS_AND_TAILS
HEADS_AND_TAILS is a symbolic constant for a position
in the boolean array checkSpecial. |
static int |
HEAVENS_GRACE
A symbolic constant for one of the values which the private integer specialHand can take. |
private static int |
IMPERIAL_JADE
IMPERIAL_JADE is a symbolic constant for a position
in the boolean array checkSpecial. |
private static int |
IS_CONS_CHOW
IS_CONS_CHOW is a symbolic constant used
to reflect a check which the checkSet methods makes. |
private static int |
IS_GREEN_DRAGON
IS_GREEN_DRAGON is a symbolic constant used
to reflect a check which the checkSet methods makes. |
private static int |
IS_GREEN_TILE
IS_GREEN_TILE is a symbolic constant used
to reflect a check which the checkSet methods makes. |
private static int |
IS_HONOUR
IS_HONOUR is a symbolic constant used
to reflect a check which the checkSet methods makes. |
private static int |
IS_NORMAL_WIND
IS_NORMAL_WIND is a symbolic constant used
to reflect a check which the checkSet methods makes. |
private static int |
IS_SPEC_WIND
IS_SPEC_WIND is a symbolic constant used
to reflect a check which the checkSet methods makes. |
private static int |
IS_TERMINAL
IS_TERMINAL is a symbolic constant used
to reflect a check which the checkSet methods makes. |
static int |
LAST_DISCARD
LAST_DISCARD indicates the LAST_PICKUP
was the last discard possible in the Hand. |
static int |
LAST_PICKUP
LAST_PICKUP is an element of the
gameInfo array. |
static int |
LAST_TILE
LAST_TILE indicates the LAST_PICKUP was
the last tile in the Honour Wall. |
(package private) Tile |
lastTile
Used to store the last tile of the hand, ie the tile the winner went Mahjong with. |
static int |
LIMIT
LIMIT is an element of the gameInfo
array. |
static int |
LOOSE_TILE
LOOSE_TILE indicates the LAST_PICKUP
was one of the loose tiles in the Dead Wall. |
static int |
MAX_CONCEALED
The maximum number of concealed sets a player can have. |
static int |
MAX_EXPOSED
The maximum number of exposed sets a player can have. |
private static int |
MIXED_PUNG
MIXED_PUNG is a symbolic constant for a position in
the boolean array checkSpecial. |
static int |
MOON
A symbolic constant for one of the values which the private integer specialHand can take. |
static int |
NONE
A symbolic constant for one of the values which the private integer specialHand can take. |
static int |
NORM_WIND_SETS
NORM_WIND_SETS is a symbolic constant for a position
in the array of ints doubleInfo. |
static int |
ONE_CHANCE_HAND
ONE_CHANCE_HAND is an element of the
doubleFlags array. |
(package private) int[] |
payout
Holds how much each player has to payout. |
static int |
PAYOUT_SIZE
PAYOUT_SIZE is the size of the payout
array. |
(package private) PayoutInfo |
payoutData
The object sed to convert the data generated by Payout into
what is to be output by the PayoutGUI class. |
(package private) java.lang.String[] |
playerNames
Lists the names of all four players in the Game. |
(package private) int[] |
playerWinds
Lists the winds of all four players in the Game. |
static int |
PLUM_BLOSSOM
A symbolic constant for one of the values which the private integer specialHand can take. |
static int |
PURITY
PURITY is an element of the doubleFlags
array. |
static int |
REQ_CON_CHOWS
REQ_CON_CHOWS is the value of how many consecutive
chows are required in order to gain one extra double if the
player has an Ordinary Suit Hand. |
static int |
ROBBED_KONG
ROBBED_KONG indicates the LAST_PICKUP
was from Robbing the Kong. |
(package private) int |
score
Holds the score of the winning player's hand. |
static int |
SIMPLES
SIMPLES is an element of the
doubleFlags array. |
static int |
SPEC_WIND_SETS
SPEC_WIND_SETS is a symbolic constant for a position
in the array of ints doubleInfo. |
(package private) int |
specialHand
Indicates whether the player has formed a special hand. |
static int |
STANDING_HAND
STANDING_HAND is an element of the
gameDoubleFlags array. |
private static int |
THREE_GREAT_SCHOLARS
THREE_GREAT_SCHOLARS is a symbolic constant for a
position in the boolean array checkSpecial. |
static int |
UNIQUE_WONDER
A symbolic constant for one of the values which the private integer specialHand can take. |
static int |
WALL
WALL indicates the LAST_PICKUP was from
The Wall. |
static int |
WIN_WIND_PAIR
WIN_WIND_PAIR is a state which
EXTRA_PAIR in the groundInfo array can
take. |
(package private) int |
winnersPos
The position of the discarding player (if there was one) in the playerNames and playerWinds arrays. |
static int |
WOR
WOR is an element of the gameInfo
array. |
static int |
WOR_PAIR
WOR_PAIR is a state which EXTRA_PAIR in
the groundInfo array can take. |
static int |
WRIGGLY_SNAKE
A symbolic constant for one of the values which the private integer specialHand can take. |
| Constructor Summary | |
Payout()
Resets all scoring and payout variables by calling the resetPayOutData and initialiseScoreData
methods. |
|
| Method Summary | |
private void |
applyDoubles(Set[] exposedSets)
Determines and applies relevant doubles to the ground score of the ordinary suit hand. |
private void |
applyExtraPoints()
Applies relevant extra points to the ground score of the ordinary suit hand. |
private void |
calcFinalScore(Set[] exposedSets)
Using all information gathered from the methods which examine sets contained in the players hand ( scoreExposedSets, scoreConcealedSets
and all worker methods of these two methods)
calcFinalScore is used to determine whether the
player has won with a special hand or ordinary suit hand. |
private boolean |
checkSet(Set anySet,
int checkID)
Checks if a given set meets a given check ID. |
private void |
handleChows(Set anySet)
Gather the scoring details from a Chow. |
private void |
handleKongOrPung(Set anySet,
int baseNumber,
boolean isConc)
Gather the scoring details from a concealed Kong or Pung. |
private void |
handleOneChanceHand(Set anySet)
Checks whether the player won with a One Chance Hand. |
private void |
handlePair(Set anySet)
Gather the scoring details from a Pair. |
void |
handlePayout(Set[] concealedSet,
Set[] exposedSet,
Game gameReference)
The handlePayout method is called once a hand has
been completed, ie a player has gone Mahjong. |
int |
handleScoring(Set[] concealedSets,
Set[] exposedSets)
handleScoring first sets all scoring information
which the Payout class determines internally to the required
initial values by invoking the initialiseScoreData
method. |
private void |
initialiseScoreData()
The initialiseScoreData method sets all variables
used by the Payout class to their required initial values. |
void |
resetPayOutData()
Resets all variables need in calculating the payout to the winner. |
private void |
scoreConcealedSets(Set[] concealedSets)
Uses the hand's concealed sets to gather the scoring details for the concealed sets in a player's hand. |
private void |
scoreExposedSets(Set[] exposedSets)
Uses the hand's exposed sets to gather the scoring details for the exposed sets in a player's hand. |
private void |
scoreIfEasySpecial()
scoreIfEasySpecial checks firstly whether any of the
unusual special hands have been set and then makes trivial checks
to see if the given hand is one of 2 other special hands.
The unusual special hands are set by the Game
because they can only be checked for there. |
void |
setConcealedMahjong()
Sets that the player won with a concealed mahjong. |
void |
setEarthsGrace()
Sets that the hand is an Earths Grace |
void |
setFirstDiscardBonus(boolean bonusVal)
Sets that the player earnt a first discard bonus by punging/konging the first discard made by the east wind player at the start of the hand. |
void |
setGameLimit(int limit)
Sets the limit for the hand. |
void |
setGatesOfHeaven(Tile[] concealedHand)
Sets that the hand is a Gates of Heaven Hand. |
void |
setHeavensGrace()
Sets that the hand is a Heaven's Grace Special Hand. |
void |
setLastPickUp(int lastPickupID)
Sets the the ID of where the last pickup occurred in the game. |
void |
setLastTile(Tile finalTile)
Sets what the last tile to be picked up by the winner was. |
void |
setPlayerInfo(java.lang.String[] thePlayerNames,
int[] thePlayerWinds,
int theWinnersPos,
int theDiscardersPos)
Sets the info relating to all players. |
private void |
setSpecialDoubles(Set anySet)
Toggles doubleFlags boolean values depending on whether or not the hand satisfies any of the doubles of an Ordinary Suit Hand. |
void |
setStandingHand()
Sets the fact that the player won with a standing hand. |
void |
setUniqueWonder(Tile[] concealedHand)
Sets that the hand is a Unique Wonder Special Hand. |
void |
setWOR(int windID)
Sets the current wind of the round. |
void |
setWrigglySnake(Tile[] concealedHand)
Sets that the hand is a Wriggly Snake Hand |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int NONE
specialHand can take. NONE
indicates that the winner hasn't won with a special hand.
NONE is also used as a symbolic constant to reflect
that the DOUBLE_SUIT element of the
doubleInfo array hasn't yet been assigned a suit
value.public static final int UNIQUE_WONDER
specialHand can take.
UNIQUE_WONDER indicates that the player has won with
a Unique Wonder. As only the Game can check whether
the player has a Unique Wonder it is a public int.public static final int HEAVENS_GRACE
specialHand can take.
HEAVENS_GRACE indicates that the player has won with
a Heaven's Grace. As only the Game can check whether
the player has a Heaven's Grace it is a public int.public static final int GATES_OF_HEAVEN
specialHand can take.
GATES_OF_HEAVEN indicates that the player has won
with a Gates of Heaven (or Nine Gates) hand. As only the
Game can check whether the player has a Gates of
Heaven hand it is a public int.public static final int WRIGGLY_SNAKE
specialHand can take.
WRIGGLY_SNAKE indicates that the player has won with
a Wriggly Snake hand. As only the Game can check
whether the player has a Wriggly Snake hand it is a public int.public static final int EARTHS_GRACE
specialHand can take.
EARTHS_GRACE indicates that the player has won with
an Earth's Grace. As only the Game can check whether
the player has an Earth's Grace it's a public int.public static final int PLUM_BLOSSOM
specialHand can take.
PLUM_BLOSSOM indicates whether the player has
Plucked the Plum Blossom from the Roof. As only the
Game can check whether the player has managed to do
this it is a public int.public static final int MOON
specialHand can take. MOON
indicates that the player has Picked the Moon from the Bottom of
the Sea. As only the Game can check whether the
player has managed to do this it is a public int.private static final int IMPERIAL_JADE
IMPERIAL_JADE is a symbolic constant for a position
in the boolean array checkSpecial. It reflects
whether the player was won with an Imperial Jade special hand.private static final int ALL_KONG
ALL_KONG is a symbolic constant for a position in the
boolean array checkSpecial. It reflects whether the
player was won with an All Kong special hand.private static final int ALL_WINDS_AND_DRAGS
ALL_WINDS_AND_DRAGS is a symbolic constant
for a position in the boolean array checkSpecial. It
reflects whether the player was won with an All Winds and Dragons
special hand.private static final int HEADS_AND_TAILS
HEADS_AND_TAILS is a symbolic constant for a position
in the boolean array checkSpecial. It reflects
whether the player was won with a Heads and Tails special hand.private static final int MIXED_PUNG
MIXED_PUNG is a symbolic constant for a position in
the boolean array checkSpecial. It reflects whether
the player was won with a Mixed Pung special hand.private static final int FOUR_BIG_WINDS
FOUR_BIG_WINDS is a symbolic constant for a position
in the boolean array checkSpecial. It reflects
whether the player was won with a Four Big Winds special hand.private static final int FOUR_LITTLE_WINDS
FOUR_LITTLE_WINDS is a symbolic constant for a
position in the boolean array checkSpecial. It
reflects whether the player was won with a Four Little Winds
special hand.private static final int THREE_GREAT_SCHOLARS
THREE_GREAT_SCHOLARS is a symbolic constant for a
position in the boolean array checkSpecial. It
reflects whether the player was won with a Three Great Scholars
special hand.public static final int DOUBLE_SUIT
DOUBLE_SUIT is a symbolic constant for a position in
the array of ints doubleInfo. It is used to hold the
suit of the first Set that Payout uses
in its calculations. This then makes it possible to determine
whether the player has a Clean or Purity Hand which are booleans
in the
array.public static final int CHOWS
CHOWS is a symbolic constant for a position in the
array of ints doubleInfo. It is used to hold the
number of Chows the player has in their hand. Thus it can be
determined whether the player earns 1 double for either a non
scoring hand, ie a hand with only Chows and a pair, or for a hand
with no Chows.public static final int DRAGON_SETS
DRAGON_SETS is a symbolic constant for a position in
the array of ints doubleInfo. It is used to hold the
number of Pungs/Kongs of Dragons which the player has in their
hand.public static final int SPEC_WIND_SETS
SPEC_WIND_SETS is a symbolic constant for a position
in the array of ints doubleInfo. It is used to hold
the number of Pungs/Kongs of Special Winds, ie the Wind of the
Round or Winner's Wind, which the player has in their hand.public static final int NORM_WIND_SETS
NORM_WIND_SETS is a symbolic constant for a position
in the array of ints doubleInfo. It is used to hold
the number of Pungs/Kongs of Normal Winds, ie not the Wind of the
Round or Winner's Wind. Kongs/Pungs of Normal Winds don't earn
any doubles in an Ordinary Suit Hand.public static final int EXP_DOUBLE_SETS
EXP_DOUBLE_SETS is a symbolic constant for a
position in the array of ints doubleInfo. It is used
to hold the number of exposed Pungs/Kongs the player has. It's
used to check whether the player has 3 exposed Kongs/Pungs,
because if they do and also have an Ordinary Suit Hand they earn
one extra double.public static final int CONC_SIMPLE_SETS
CONC_SIMPLE_SETS is a symbolic constant for an
element in the array of ints groundInfo. It keeps
track of the amount of points the player has scored for concealed
Kongs and Pungs of Simple tiles, ie tiles 2-8 in any suit. This
is part of the Ground Score information of the player's hand (if
they have an Ordinary Suit Hand).public static final int EXP_SIMPLE_SETS
EXP_SIMPLE_SETS is a symbolic constant for an
element in the array of ints groundInfo. It keeps
track of the amount of points the player has scored for exposed
Kongs and Pungs of Simple tiles, ie tiles 2-8 in any suit. This
is part of the Ground Score information of the player's hand (if
they have an Ordinary Suit Hand).public static final int CONC_OTHER_SETS
CONC_OTHER_SETS is a symbolic constant for an
element in the array of ints groundInfo. It keeps
track of the amount of points the player has scored for concealed
Kongs and Pungs of all other tiles besides Simple tiles, ie
Terminal and Honour tiles. This is part of the Ground Score
information of the player's hand (if they have an Ordinary Suit
Hand).public static final int EXP_OTHER_SETS
EXP_OTHER_SETS is a symbolic constant for an element
in the array of ints groundInfo. It keeps track of
the amount of points the player has scored for exposed Kongs and
Pungs of all other tiles besides Simple tiles, ie Terminal and
Honour tiles. This is part of the Ground Score information of the
player's hand (if they have an Ordinary Suit Hand).public static final int EXTRA_PAIR
EXTRA_PAIR is a symbolic constant for an element in
the array of ints groundInfo. It keeps track of
whether the player has a pair that adds extra points to the
ground score.public static final int DRAGON_PAIR
DRAGON_PAIR is a state which EXTRA_PAIR
in the groundInfo array can take. It indicates that
the player has a pair of dragons.public static final int WIN_WIND_PAIR
WIN_WIND_PAIR is a state which
EXTRA_PAIR in the groundInfo array can
take. It indicates that the player has a pair of the Winner's
wind.public static final int WOR_PAIR
WOR_PAIR is a state which EXTRA_PAIR in
the groundInfo array can take. It indicates whether
the player has a pair of the Wind of the Round's wind.public static final int SIMPLES
SIMPLES is an element of the
doubleFlags array. It indicates whether the hand is
comprised entirely of Simple tiles, thus earning 1 double if the
player has an Ordinary Suit Hand.public static final int CLEAN
CLEAN is an element of the doubleFlags
array. It indicates whether the player has a clean hand, ie the
hand contains only sets from the same suit with/without honour
tiles. A clean hand gives 1 extra double if the player has an
Ordinary Suit Hand.public static final int PURITY
PURITY is an element of the doubleFlags
array. It indicates whether the player has a purity hand, thus
giving 3 doubles.public static final int ALL_HONOUR
ALL_HONOUR is an element of the
doubleFlags array. It indicates whether the player
has an all honour hand, which gives 3 doubles.public static final int AT_LEAST_DOUBLE
AT_LEAST_DOUBLE is an element of the
doubleFlags array. It indicates whether the player
has a hand in which every set contains at least one
honour/terminal tile. If the player has an Ordinary Suit Hand
they earn an extra double for this.public static final int GROUND_CM_BONUS
GROUND_CM_BONUS is an element of the
doubleFlags array. It indicates whether the player
has a earnt an extra 10 points to their Ground Score for completing
a Concealed Mahjong with a discard.public static final int ONE_CHANCE_HAND
ONE_CHANCE_HAND is an element of the
doubleFlags array. It indicates whether the player
has a One Chance Hand, ie they complete their hand with a pair,
they complete their hand in the middle of a Chow or they complete
their hand at the inside end of a terminal Chow. Thus 2 points
are added to a player's ground score if they have a One Chance
Hand.public static final int STANDING_HAND
STANDING_HAND is an element of the
gameDoubleFlags array. It indicates whether the
player has won with a Standing Hand (adding 100 points to the
Ground Score).public static final int FIRST_DISCARD_BONUS
FIRST_DISCARD_BONUS is an element of the
gameDoubleFlags array. It indicates whether the
player has Punged/Konged the first discard made by east at the
beginning of a hand.public static final int CONCEALED_MAHJONG
CONCEALED_MAHJONG is an element of the
gameDoubleFlags array. It indicates whether the
playerhas one with a Concealed Mahjong. Game has to
checkfor this because a Concealed Mahjong can include one exposed
set if it was made exposed by picking up the last discard.public static final int LAST_PICKUP
LAST_PICKUP is an element of the
gameInfo array. It indicates where the winning
player made their last pickup from in order to go Mahjong.public static final int WOR
WOR is an element of the gameInfo
array. It indicates the wind of the round.public static final int LIMIT
LIMIT is an element of the gameInfo
array. It indicates the limit of the hand.public static final int WALL
WALL indicates the LAST_PICKUP was from
The Wall.public static final int DISCARD
DISCARD indicates the LAST_PICKUP was
from the discard of another player.public static final int LOOSE_TILE
LOOSE_TILE indicates the LAST_PICKUP
was one of the loose tiles in the Dead Wall.public static final int ROBBED_KONG
ROBBED_KONG indicates the LAST_PICKUP
was from Robbing the Kong.public static final int LAST_DISCARD
LAST_DISCARD indicates the LAST_PICKUP
was the last discard possible in the Hand.public static final int LAST_TILE
LAST_TILE indicates the LAST_PICKUP was
the last tile in the Honour Wall.private static final int IS_SPEC_WIND
IS_SPEC_WIND is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set is the Wind of the Round's
wind or the Winner's Wind.private static final int IS_NORMAL_WIND
IS_NORMAL_WIND is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set is one of the winds besides
both the Wind of the Round's wind and the Winner's Wind.private static final int IS_HONOUR
IS_HONOUR is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set is a set of Honour tiles.private static final int IS_TERMINAL
IS_TERMINAL is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set is a set of Terminal tiles.private static final int IS_CONS_CHOW
IS_CONS_CHOW is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set could contribute to the
player having 3 consecutive chows.private static final int IS_GREEN_DRAGON
IS_GREEN_DRAGON is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set is a Kong/Pung of Green
Dragon tiles.private static final int IS_GREEN_TILE
IS_GREEN_TILE is a symbolic constant used
to reflect a check which the checkSet methods makes.
The check is to see whether the set is a "Green" tile set, ie a
2,3,4,6 or 8 of Bamboo set.public static final int REQ_CON_CHOWS
REQ_CON_CHOWS is the value of how many consecutive
chows are required in order to gain one extra double if the
player has an Ordinary Suit Hand.public static final int PAYOUT_SIZE
PAYOUT_SIZE is the size of the payout
array. The size is equal to the number of players + 1. The extra
one is required to accomodate the constants defined in the
Tile class. As the NORTH constant in
the Tile class has a value of 4 an extra element is
required in the payout array.public static final int MAX_EXPOSED
public static final int MAX_CONCEALED
int score
int[] payout
int specialHand
private boolean[] checkSpecial
int[] groundInfo
int[] doubleInfo
Payout class (in the handleScoring
method).boolean[] doubleFlags
int[] consecutiveChows
Tile lastTile
int[] gameInfo
Game required for
calculating the score of the hand.boolean[] gameDoubleFlags
Game required for
calculating the score of the hand.PayoutInfo payoutData
Payout into
what is to be output by the PayoutGUI class.java.lang.String[] playerNames
int[] playerWinds
int winnersPos
playerNames and playerWinds arrays.int discardersPos
playerNames and playerWinds arrays.Tile[] concealedHand
| Constructor Detail |
public Payout()
resetPayOutData and initialiseScoreData
methods.| Method Detail |
public void resetPayOutData()
private void initialiseScoreData()
initialiseScoreData method sets all variables
used by the Payout class to their required initial values. These
values are essential to the way in which the Payout class
works.For instance, some of the elements in the checkSpecial array are set to true initially and some are set to false. The reason for this is that some checks for special hands can be assumed to be true until seen to be false in the scoring methods, or vice versa. All initial values have been chosen to make calculating the score of the winning hand easier.
public void handlePayout(Set[] concealedSet,
Set[] exposedSet,
Game gameReference)
handlePayout method is called once a hand has
been completed, ie a player has gone Mahjong. It determines how
much all losing players must payout to the winner based on the
score calculated for the winning hand (which is determined by
calling the handleScoring method.
It then calls the drawPayoutInfo method in order to
display to the user in a dialog box the breakdown of the scoring
for that hand and how much each losing player had to payout.
concealedSet - The array of concealed tile sets which is
contained in the winning hand.exposedSet - The array of exposed tile sets which is
contained in the winning hand.
public int handleScoring(Set[] concealedSets,
Set[] exposedSets)
handleScoring first sets all scoring information
which the Payout class determines internally to the required
initial values by invoking the initialiseScoreData
method. This is required in order for handleScoring
to be used on multiple hands during the course of a hand.
After this a check is made as to whether the given hand is an
"easy" special hand via the scoreIfEasySpecial
method, and if it is then the score will be changed to reflect
the value of the hand. They are so called "easy" special hands
because they are very quick to check for and so don't need to be
part of the main score determining methods.
So if the given hand is not one of these "easy" special hands the score will not change and so the main scoring methods will be called.
concealedSet - - The array of concealed tile sets which is
contained in the winning hand.exposedSet - - The array of exposed tile sets which is
contained in the winning hand.private void scoreIfEasySpecial()
scoreIfEasySpecial checks firstly whether any of the
unusual special hands have been set and then makes trivial checks
to see if the given hand is one of 2 other special hands.
The unusual special hands are set by the Game
because they can only be checked for there. These unusual special
hands (Unique Wonder, Heaven's Grace, Gates of Heaven, Wriggly
Snake and Earth's Grace) are unlike other special hands and need
to be checked for specially.
private void scoreExposedSets(Set[] exposedSets)
exposedSets - - The array of exposed tile sets which is
contained in the winning hand.private void scoreConcealedSets(Set[] concealedSets)
concealedSets - - The array of concealed tile sets which is
contained in the winning hand.
private void handleKongOrPung(Set anySet,
int baseNumber,
boolean isConc)
anySet - - An exposed or concealed Kong/Pung.baseNumber - - The base number which the given set scores.
It reflects the lowest score which the
Kong/Pung can earn. This is used as part of
determining the ground score if the player
has an Ordinary Suit Hand.isConc - - Indicates whether anySet is concealed.private void handleChows(Set anySet)
anySet - - An exposed or concealed Kong/Pung.private void handlePair(Set anySet)
anySet - - A pair of tiles.private void setSpecialDoubles(Set anySet)
anySet - - An exposed or concealed kong/pung/chow/pair of
tiles.private void handleOneChanceHand(Set anySet)
ONE_CHANCE_HAND in the double flags array to
true.
- Parameters:
anySet - - An exposed or concealed kong/pung/chow/pair of
tiles.
private void calcFinalScore(Set[] exposedSets)
scoreExposedSets, scoreConcealedSets
and all worker methods of these two methods)
calcFinalScore is used to determine whether the
player has won with a special hand or ordinary suit hand. It
also establishes the final score of the hand. This is done
within the method for a special hand and through worker methods
for an ordinary suit hand.exposedSets - - Required if the player has an ordinary suit
hand to determine doubles to the ground
score.private void applyExtraPoints()
private void applyDoubles(Set[] exposedSets)
exposedSets - - needed to determine if a further extra
points should be added to the ground score
before applying doubles.
private boolean checkSet(Set anySet,
int checkID)
anySet - A given set.checkID - The check to be made on the set.public void setGameLimit(int limit)
limit - The limit of the hand.public void setUniqueWonder(Tile[] concealedHand)
public void setHeavensGrace()
public void setGatesOfHeaven(Tile[] concealedHand)
public void setWrigglySnake(Tile[] concealedHand)
public void setEarthsGrace()
public void setWOR(int windID)
windID - The current wind of the round.public void setLastPickUp(int lastPickupID)
lastPickupID - The ID of where the last tile came from.public void setLastTile(Tile finalTile)
finalTinal - The final tile to be picked up.public void setStandingHand()
public void setFirstDiscardBonus(boolean bonusVal)
public void setConcealedMahjong()
public void setPlayerInfo(java.lang.String[] thePlayerNames,
int[] thePlayerWinds,
int theWinnersPos,
int theDiscardersPos)
thePlayerNames - The names of all players.thePlayerWinds - The winds of all players.theWinnersPos - The winners position in thePlayerNames and
thePlayerWinds arrays.theDiscardersPos - The discarders position in thePlayeNames
and thePlayerWinds arrays.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||