|
Blackjack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.amoebacode.blackjack.core.GameObject
|
+--com.amoebacode.blackjack.core.CardCollection
|
+--com.amoebacode.blackjack.core.Hand
|
+--com.amoebacode.blackjack.core.PlayerHand
PlayerHand manages one player's hand.
| Field Summary | |
private int |
bet
The current bet for this hand |
private static int |
DECLINED_INSURANCE
Indicates that the player has declined insurance |
private int |
handIndex
This hand's position relative to the player's other hands |
private static int |
HAS_INSURANCE
Indicates that the player has purchased insurance |
private int |
hasInsurance
Indicates whether the player has purchased or declined insurance for this hand |
private boolean |
isStanding
Indicates whether the player is standing on this hand |
private boolean |
isSurrendering
Indicates whether the player has surrendered this hand |
private double |
netGain
The net gain for this hand |
private static int |
NO_INSURANCE_SELECTION
Indicates that the player has not made an insurance selection |
private static int |
PLAYER_LOSES
Outcome signifying a player loss |
private static int |
PLAYER_PUSHES
Outcome signifying a push (tie) |
private static int |
PLAYER_SURRENDERS
Outcome signifying a player surrender |
private static int |
PLAYER_WINS
Outcome signifying a player victory |
| Fields inherited from class com.amoebacode.blackjack.core.Hand |
MAXIMUM_HARD_CARD_SCORE, MAXIMUM_NUMBER_OF_CARDS, MAXIMUM_SCORE |
| Fields inherited from class com.amoebacode.blackjack.core.CardCollection |
cards |
| Fields inherited from class com.amoebacode.blackjack.core.GameObject |
listeners, parent |
| Constructor Summary | |
protected |
PlayerHand(IPlayer player,
int bet,
int handIndex)
Default public constructor. |
| Method Summary | |
void |
buyInsurance()
Accepts the insurance offer. |
boolean |
canAct()
Indicates whether the player can act on this hand. |
boolean |
canDoubleDown()
Indicates whether the player can double down this hand. |
private boolean |
canEarlySurrender()
Indicates whether the player can accept early surrender on this hand. |
boolean |
canHit()
Indicates whether the player can hit this hand. |
boolean |
canSplit()
Indicates whether the player can split this hand. |
boolean |
canStand()
Indicates whether the player can stand on this hand. |
boolean |
canSurrender()
Indicates whether the player can accept surrender on this hand. |
void |
checkAction(java.lang.String action)
Checks whether the specified user action is the proper basic strategy play. |
void |
computeNetGain(int dealerScore)
Calculates the net gain for this hand based on the specified dealer score, the current bet, and the outcome. |
private boolean |
dealerHasBlackjack()
Indicates whether the dealer has blackjack. |
void |
declineInsurance()
Declines the insurance offer. |
void |
doubleBet()
Doubles the current bet and notifies the GUI listeners. |
int |
getBet()
Returns the amount of the current bet for this hand. |
int |
getHandIndex()
Returns the relative index of this hand within the player's collection of hands. |
double |
getNetGain()
Returns the user's net gain for this hand. |
Card |
getNextCard()
Removes and returns the first card in this collection and notifies the GUI listeners. |
private int |
getOutcome(int dealerScore)
Returns this hand's outcome based on the specified dealer score. |
private IPlayer |
getPlayer()
Returns the player that manages this hand. |
private PlayerHandEventListenerCollection |
getPlayerHandEventListenerCollection()
Returns the event listener collection for this player hand. |
protected java.lang.String |
getTotalLabel()
Returns the prefix for the current score label (for example, "Score:"). |
boolean |
hasBlackjack()
Indicates whether this hand has blackjack. |
private boolean |
hasInsurance()
Indicates whether the player purchased insurance. |
boolean |
hasSurrendered()
Indicates whether the player has surrendered this hand. |
private void |
makeInsuranceDecision(int decision)
Makes the specified insurance decision and checks for dealer blackjack. |
private boolean |
noInsuranceSelection()
Indicates whether the player has made an insurance selection. |
boolean |
offerInsurance()
Indicates whether the player should be offered insurance. |
void |
split()
Splits this hand's pair into two different hands. |
void |
stand()
Stands on this hand. |
void |
surrender()
Accepts surrender on this hand. |
void |
updateAvailableCommands()
Updates the set of available player hand commands for each GUI listener. |
| Methods inherited from class com.amoebacode.blackjack.core.Hand |
addCard, clear, getBestTotal, getBestTotal, getCurrentScore, getHandEventListenerCollection, getHardTotal, getHardTotal, getHouseRules, getMaximumSafeHitScore, getRound, getSoftTotal, getSoftTotal, hasBusted, hasMaximumNumberOfCards, hasMaximumScore, hasPair, hasSoftTotal, hit, shouldUseMixedTotal |
| Methods inherited from class com.amoebacode.blackjack.core.CardCollection |
getCardAt, getNumberOfCards, setCards |
| Methods inherited from class com.amoebacode.blackjack.core.GameObject |
addEventListener, getEventListenerCollection, getGame, getParent, hasParent, setEventListenerCollection |
| Methods inherited from class java.lang.Object |
|
| Methods inherited from interface com.amoebacode.blackjack.core.IHand |
clear, getBestTotal, getBestTotal, getCurrentScore, getHardTotal, getSoftTotal, hasBusted, hasPair, hasSoftTotal, hit |
| Methods inherited from interface com.amoebacode.blackjack.core.ICardCollection |
addCard, getCardAt, getNumberOfCards, setCards |
| Methods inherited from interface com.amoebacode.blackjack.core.IGameObject |
addEventListener, getGame, getParent |
| Field Detail |
private int bet
private double netGain
private boolean isStanding
private boolean isSurrendering
private int hasInsurance
private int handIndex
private static final int PLAYER_WINS
private static final int PLAYER_LOSES
private static final int PLAYER_PUSHES
private static final int PLAYER_SURRENDERS
private static final int NO_INSURANCE_SELECTION
private static final int HAS_INSURANCE
private static final int DECLINED_INSURANCE
| Constructor Detail |
protected PlayerHand(IPlayer player,
int bet,
int handIndex)
player - the IPlayer that is instantiating this hand| Method Detail |
public void updateAvailableCommands()
IPlayerHandupdateAvailableCommands in interface IPlayerHandIPlayerHand.updateAvailableCommands()public boolean canAct()
IPlayerHandcanAct in interface IPlayerHandIPlayerHand.canAct()private boolean canEarlySurrender()
public boolean canSplit()
IPlayerHandcanSplit in interface IPlayerHandIPlayerHand.canSplit()public boolean canDoubleDown()
IPlayerHandcanDoubleDown in interface IPlayerHandIPlayerHand.canDoubleDown()public boolean canHit()
IPlayerHandcanHit in interface IPlayerHandIPlayerHand.canHit()public boolean canStand()
IPlayerHandcanStand in interface IPlayerHandIPlayerHand.canStand()public boolean canSurrender()
IPlayerHandcanSurrender in interface IPlayerHandIPlayerHand.canSurrender()public void stand()
IPlayerHandstand in interface IPlayerHandIPlayerHand.stand()public void surrender()
IPlayerHandsurrender in interface IPlayerHandIPlayerHand.surrender()public void doubleBet()
IPlayerHanddoubleBet in interface IPlayerHandIPlayerHand.doubleBet()public void split()
IPlayerHandsplit in interface IPlayerHandIPlayerHand.split()private int getOutcome(int dealerScore)
dealerScore - the score of the dealer handprivate boolean dealerHasBlackjack()
public boolean offerInsurance()
IPlayerHandofferInsurance in interface IPlayerHandIPlayerHand.offerInsurance()public void computeNetGain(int dealerScore)
IPlayerHandcomputeNetGain in interface IPlayerHandIPlayerHand.computeNetGain(int)public double getNetGain()
IPlayerHandgetNetGain in interface IPlayerHandIPlayerHand.getNetGain()public boolean hasBlackjack()
IHandhasBlackjack in interface IHandhasBlackjack in class HandIHand.hasBlackjack()public boolean hasSurrendered()
IPlayerHandhasSurrendered in interface IPlayerHandIPlayerHand.hasSurrendered()private void makeInsuranceDecision(int decision)
decision - the insurance decision (accept or decline)public void buyInsurance()
IPlayerHandbuyInsurance in interface IPlayerHandIPlayerHand.buyInsurance()public void declineInsurance()
IPlayerHanddeclineInsurance in interface IPlayerHandIPlayerHand.declineInsurance()private boolean hasInsurance()
private boolean noInsuranceSelection()
protected java.lang.String getTotalLabel()
HandgetTotalLabel in class HandHand.getTotalLabel()public void checkAction(java.lang.String action)
IPlayerHandcheckAction in interface IPlayerHandIPlayerHand.checkAction(String)public int getBet()
IPlayerHandgetBet in interface IPlayerHandIPlayerHand.getBet()public int getHandIndex()
IPlayerHandgetHandIndex in interface IPlayerHandIPlayerHand.getHandIndex()public Card getNextCard()
ICardCollectiongetNextCard in interface ICardCollectiongetNextCard in class CardCollectionICardCollection.getNextCard()private PlayerHandEventListenerCollection getPlayerHandEventListenerCollection()
private IPlayer getPlayer()
|
Blackjack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||