Blackjack

com.amoebacode.blackjack.display
Class PlayerHandDisplay

java.lang.Object
  |
  +--com.amoebacode.blackjack.display.DisplayElement
        |
        +--com.amoebacode.blackjack.display.HandDisplay
              |
              +--com.amoebacode.blackjack.display.PlayerHandDisplay
All Implemented Interfaces:
BlackjackEventListener, java.util.EventListener, HandEventListener, PlayerHandEventListener

public class PlayerHandDisplay
extends HandDisplay
implements PlayerHandEventListener

PlayerHandDisplay handles the GUI display of a player hand

Version:
0.9
Author:
Jason Gurney

Field Summary
private  LabelWrapper betLabel
          The bet label for this hand
private  HandButtonSet handButtonSet
          The set of hand buttons (hit, stand, double down, etc.)
private  boolean isShowingNetGain
          Indicates whether the net gain is currently being displayed
 
Fields inherited from class com.amoebacode.blackjack.display.HandDisplay
cardDisplays, currentScore, hand, isAnimating, xPos, yPos
 
Fields inherited from class com.amoebacode.blackjack.display.DisplayElement
parent
 
Constructor Summary
protected PlayerHandDisplay(PlayerDisplay player)
          Default protected constructor.
 
Method Summary
 void buyInsurance()
          Executes a buy insurance command.
 void checkAction(java.lang.String action)
          Checks whether the specified user action is the proper basic strategy play.
 void clear(BlackjackEvent event)
          Clears this hand display object.
 void declineInsurance()
          Executes a decline insurance command.
 void disableButtons()
          Disables the buttons corresponding to this hand.
 void doubleDown()
          Executes a double down command.
 void drawNetGain(BlackjackEvent event)
          Draws the net gain for this player hand display object.
private  void drawNetGain(int netGain)
          Draws the specified net gain on the bet label.
 int getBetXPos()
          Returns the horizontal location of the bet label.
 int getBetYPos()
          Returns the vertical location of the bet label.
protected  Coordinate getCoordinates()
          Returns the horizontal and vertical position of this hand.
 int getCurrentScoreYPos()
          Returns the vertical position of the current score label.
private  IPlayerHand getPlayerHand()
          Returns the player hand being displayed.
 int getXButtonPos()
          Returns the horizontal location of the hand buttons.
 int getYButtonPos()
          Returns the vertical location of the hand buttons.
 void hit()
          Executes a hit command.
 void performDrawNetGainAction(int netGain)
          Draws the specified net gain for this player hand display object and resumes the action queue.
 void performUpdateCommandsAction(AvailableHandCommands availableCommands)
          Updates the availability of the hand buttons and resumes the action queue.
protected  void setupDisplay()
          Draws the buttons, cards, and bet label.
 void split()
          Executes a split command.
 void stand()
          Executes a stand command.
 void startAnimatedCard()
          Sets up the animation for the most recently added card.
 void stopAnimatedCard()
          Turns off the card animation.
 void surrender()
          Executes a surrender command.
 void updateAvailableCommands(BlackjackEvent event)
          Updates the set of commands available to this player hand display object.
 void updateBetLabel(BlackjackEvent event)
          Updates the bet label for this player hand display object.
 
Methods inherited from class com.amoebacode.blackjack.display.HandDisplay
addCard, clearCards, clearCurrentScore, drawCard, drawCard, drawCards, getCardDisplay, getCardDisplayAt, getCurrentScoreXPos, getHand, getNumberOfCardDisplays, performAddCardAction, removeCard, resume, setCoordinates, setHand
 
Methods inherited from class com.amoebacode.blackjack.display.DisplayElement
executeGameCommand, getDisplayManager, getGameDisplay, getParent, hasParent, playGameClip, queueAction, resumeQueue
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface com.amoebacode.blackjack.event.HandEventListener
addCard, removeCard
 

Field Detail

isShowingNetGain

private boolean isShowingNetGain
Indicates whether the net gain is currently being displayed

betLabel

private LabelWrapper betLabel
The bet label for this hand

handButtonSet

private HandButtonSet handButtonSet
The set of hand buttons (hit, stand, double down, etc.)
Constructor Detail

PlayerHandDisplay

protected PlayerHandDisplay(PlayerDisplay player)
Default protected constructor.
Parameters:
player - the PlayerDisplay parent
Method Detail

setupDisplay

protected void setupDisplay()
Draws the buttons, cards, and bet label.
Overrides:
setupDisplay in class HandDisplay

getCoordinates

protected Coordinate getCoordinates()
Description copied from class: HandDisplay
Returns the horizontal and vertical position of this hand.
Overrides:
getCoordinates in class HandDisplay
See Also:
HandDisplay.getCoordinates()

getCurrentScoreYPos

public int getCurrentScoreYPos()
Description copied from class: HandDisplay
Returns the vertical position of the current score label.
Overrides:
getCurrentScoreYPos in class HandDisplay
See Also:
HandDisplay.getCurrentScoreYPos()

getBetXPos

public int getBetXPos()
Returns the horizontal location of the bet label.
Returns:
horizontal position of the bet label

getBetYPos

public int getBetYPos()
Returns the vertical location of the bet label.
Returns:
vertical position of the bet label

getXButtonPos

public int getXButtonPos()
Returns the horizontal location of the hand buttons.
Returns:
horizontal position of the hand buttons

getYButtonPos

public int getYButtonPos()
Returns the vertical location of the hand buttons.
Returns:
vertical position of the hand buttons

drawNetGain

private void drawNetGain(int netGain)
Draws the specified net gain on the bet label.
Parameters:
netGain - the net gain for this hand

clear

public void clear(BlackjackEvent event)
Description copied from interface: HandEventListener
Clears this hand display object.
Specified by:
clear in interface HandEventListener
Overrides:
clear in class HandDisplay
See Also:
HandEventListener.clear(BlackjackEvent)

disableButtons

public void disableButtons()
Disables the buttons corresponding to this hand.

getPlayerHand

private IPlayerHand getPlayerHand()
Returns the player hand being displayed.
Returns:
the IPlayerHand being displayed

doubleDown

public void doubleDown()
Executes a double down command.

hit

public void hit()
Executes a hit command.

buyInsurance

public void buyInsurance()
Executes a buy insurance command.

declineInsurance

public void declineInsurance()
Executes a decline insurance command.

split

public void split()
Executes a split command.

stand

public void stand()
Executes a stand command.

surrender

public void surrender()
Executes a surrender command.

checkAction

public void checkAction(java.lang.String action)
Checks whether the specified user action is the proper basic strategy play.
Parameters:
action - a String representing the decision chosen

startAnimatedCard

public void startAnimatedCard()
Description copied from class: HandDisplay
Sets up the animation for the most recently added card.
Overrides:
startAnimatedCard in class HandDisplay
See Also:
HandDisplay.startAnimatedCard()

stopAnimatedCard

public void stopAnimatedCard()
Description copied from class: HandDisplay
Turns off the card animation.
Overrides:
stopAnimatedCard in class HandDisplay
See Also:
HandDisplay.stopAnimatedCard()

updateBetLabel

public void updateBetLabel(BlackjackEvent event)
Description copied from interface: PlayerHandEventListener
Updates the bet label for this player hand display object.
Specified by:
updateBetLabel in interface PlayerHandEventListener
See Also:
PlayerHandEventListener.updateBetLabel(BlackjackEvent)

drawNetGain

public void drawNetGain(BlackjackEvent event)
Description copied from interface: PlayerHandEventListener
Draws the net gain for this player hand display object.
Specified by:
drawNetGain in interface PlayerHandEventListener
See Also:
PlayerHandEventListener.drawNetGain(BlackjackEvent)

performDrawNetGainAction

public void performDrawNetGainAction(int netGain)
Draws the specified net gain for this player hand display object and resumes the action queue.
Parameters:
netGain - the amount to display

updateAvailableCommands

public void updateAvailableCommands(BlackjackEvent event)
Description copied from interface: PlayerHandEventListener
Updates the set of commands available to this player hand display object.
Specified by:
updateAvailableCommands in interface PlayerHandEventListener
See Also:
PlayerHandEventListener.updateAvailableCommands(BlackjackEvent)

performUpdateCommandsAction

public void performUpdateCommandsAction(AvailableHandCommands availableCommands)
Updates the availability of the hand buttons and resumes the action queue.
Parameters:
availableCommands - the available set of hand commands

Blackjack

Copyright © 2002 amoebacode.com.