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

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

public class Human
extends Player

The Human class represents the user on the MMC of the current game thread. All moves that require input from the user are made through this inherited class of the Player, and the requests are run in the UserGUI.

The class will perform two important input functions from the user. The first is to retrieve a discard tile. Once a move has been selected the Tile is inserted into the Moves class and is passed to the Game to handle the action. The player is prompted for moves until a discard tile has been selected.

The second important function is the search for possible moves with the last discarded tile. The player's Hand is searched for possible moves and if it is possible, Human will need to enable the corresponding button in the ActionPane. The checks that need to be made are draw tile, Chow(2 sides, 2 up, 2 down), Pung, Kong and if the Player is fishing, Mahjong. The user will then need to make their selection. This is retrieved and sent back to the Game.

Author:
Dean Cortinovis

Field Summary
static int ALL_CHOW
           
private  int[] chow
          List of different Chows that the player can make
static int FIRST2CHOW
           
private  HumanDiscard humanDiscard
          Class used for interaction with the UserGUI to retrieve discard selections
private  HumanSelection humanSelection
          Class used for interaction with the UserGUI to retrieve the users selection on the next move with the last player's discard
static int LAST2CHOW
           
static int LEFT_CHOW
           
static int MID_CHOW
           
static int RIGHT_CHOW
           
static int SPLIT_CHOW
           
 
Fields inherited from class au.com.solidsoftware.multimahjong.mmc.game.Player
CHOW2DOWN, CHOW2SIDES, CHOW2UP, DECLARED_KONG, DISCARD, EAST, EITHER_MOVE, EXTEND_PUNG, icon, isFishing, KONG, MAHJONG, name, NO_MOVE, NORTH, NOT_ROBBED, payout, PICKUP, playArea, playerHand, playerId, PUNG, ROBBED_KONG, score, selectedTile, SOUTH, standingHand, userGUI, WEST, wind, WONT_ROB
 
Constructor Summary
Human(java.lang.String name, javax.swing.ImageIcon icon, int score, int playerId)
          Initialises the Player's name, icon and inserts the initial score.
 
Method Summary
 int determineCanRob(Tile selectedTile)
          Determines whether the Player can rob the Kong with the given tile.
 int getDiscard(boolean playerFishing, Moves currentMove)
          Retrieves the discard or special Kong move from the current player.
 int getPlayerSelection(Tile lastDiscard, int next)
          Displays all the selections that the player can make for their next move.
 int multipleChow()
          Returns a value that represents to the UserGUI the location of and the number of different Chow selections that are possible.
 void setMove(Tile tile, int move)
          Inserts a selected move made by the player from the UserGUI.
 void setSelection(int move)
          Inserts the selected move that a player has chosen with the last discarded tile if it is possible.
 
Methods inherited from class au.com.solidsoftware.multimahjong.mmc.game.Player
checkFishing, checkKong, checkMahjong, checkPung2Kong, declareKong, discard, findKong, findPung2Kong, getIcon, getId, getName, getScore, getWind, initPlayer, insertTile, insertTile, isStandingHand, mahjong, notStandingHand, robbedKong, runChow, runKong, runMahjong, runPung, runPung2Kong, setIcon, setName, setPlayArea, setPlayArea, setScore, setWind
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

LEFT_CHOW

public static final int LEFT_CHOW

MID_CHOW

public static final int MID_CHOW

RIGHT_CHOW

public static final int RIGHT_CHOW

FIRST2CHOW

public static final int FIRST2CHOW

SPLIT_CHOW

public static final int SPLIT_CHOW

LAST2CHOW

public static final int LAST2CHOW

ALL_CHOW

public static final int ALL_CHOW

humanDiscard

private HumanDiscard humanDiscard
Class used for interaction with the UserGUI to retrieve discard selections

humanSelection

private HumanSelection humanSelection
Class used for interaction with the UserGUI to retrieve the users selection on the next move with the last player's discard

chow

private int[] chow
List of different Chows that the player can make
Constructor Detail

Human

public Human(java.lang.String name,
             javax.swing.ImageIcon icon,
             int score,
             int playerId)
Initialises the Player's name, icon and inserts the initial score.

Parameters:
name - Name of the player.
icon - Player's selected icon.
score - Initial score of the player.
playerId - Player's ID.
Method Detail

getDiscard

public int getDiscard(boolean playerFishing,
                      Moves currentMove)
Retrieves the discard or special Kong move from the current player. Tile selection is enabled and then this moves to the HumanDiscard class to retrieve the player's selection. If the selection can be run (i.e. not Pung2Kong and fishing) then it will be directly run from this function before leaving.

Parameters:
playerFishing - True if any player is fishing in the game.
currentMove - Storage for player's selected move.
Returns:
Selected move made.
Overrides:
getDiscard in class Player

determineCanRob

public int determineCanRob(Tile selectedTile)
Determines whether the Player can rob the Kong with the given tile. If this is the case then the user will be prompted to select whether they wish to rob the Kong.

Parameters:
selectedTile - Tile that has the potential to be robbed.
Returns:
Selected action of player.
Overrides:
determineCanRob in class Player

getPlayerSelection

public int getPlayerSelection(Tile lastDiscard,
                              int next)
Displays all the selections that the player can make for their next move. The possible moves that are checked for in the Hand are: Chow2Down, Chow2Sides, Chow2Up, Pung, Kong and Mahjong. A flag is sent from the Game if the player can pickup from the Wall. If a choice is possible then the function will move to the HumanSelection class to retrieve the selection. Before exiting the function disables the ActionPane.

Parameters:
lastDiscard - Last discarded tile.
next - Flag that indicates whether this player can draw a tile.
Returns:
The player's selection.
Overrides:
getPlayerSelection in class Player

setMove

public void setMove(Tile tile,
                    int move)
Inserts a selected move made by the player from the UserGUI.

Parameters:
tile - Tile selected by the player.
move - Move selected by the player.
Overrides:
setMove in class Player

setSelection

public void setSelection(int move)
Inserts the selected move that a player has chosen with the last discarded tile if it is possible.

Parameters:
move - Selection made by the player.
Overrides:
setSelection in class Player

multipleChow

public int multipleChow()
Returns a value that represents to the UserGUI the location of and the number of different Chow selections that are possible. If a multiple number of different selections are possible then the player will need to be prompted to choose one of the selections that can be made.

Returns:
Number representing the location and number of different Chows possible.