|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.game.AbstractGame
com.antelmann.game.card.BlackJack
public class BlackJack
BlackJack implements the rules for playing BlackJack. The casino rules of the game are embedded in this class with the implementations of listLegalMoves(), dealerMove() and getResult(int playerRole). Todo for a future version: strip out casino rules and make them available as options that can be changed through public methods.
| Field Summary | |
|---|---|
static int |
BURN_CARDS
|
static int |
MINIMUM_CARDS
|
static int |
NUMBER_OF_DECKS
|
| Constructor Summary | |
|---|---|
BlackJack()
|
|
BlackJack(CardDeck deck,
float[] bet)
|
|
BlackJack(CardDeck deck,
float[] bet,
Random random)
|
|
BlackJack(float bet)
|
|
BlackJack(float[] bet)
|
|
BlackJack(float[] bet,
Random random)
|
|
| Method Summary | |
|---|---|
Object |
clone()
Note: the cloned object will have a separate Random object assiciated with it, so that operations on the cloned object will not affect the random numbers of the original. |
boolean |
gameOver()
This convenience function gameOver() simply checks whether there are any legal moves left; consequently, unless this function is overridden, listLegalMoves() must not check for gameOver(). |
static int |
getCardValue(Card card,
boolean softCount)
|
com.antelmann.game.card.BJHand |
getCurrentHand(int playerRole)
getCurrentHand() is internally a wrapper which returns a clone of the actual BJHand used in the game |
Vector<Card> |
getDealerCards()
|
CardDeck |
getDeck()
|
static int |
getHandValue(Collection cards)
|
Card |
getOpenDealerCard()
|
double |
getResult(int playerRole)
a default implementation for convenience which may suit most games that do not involve betting or any form of measuring how 'big' the win was. |
int[] |
getWinner()
getWinner() returns an array of all winning game roles - as there could be more than one winner. |
static boolean |
isBlackJack(Collection cards)
Note that a Vector of cards may not be considered BlackJack even though this function returns true, which is the case if the particular hand is derived from an Ace split. |
static boolean |
isSoft(Collection cards)
|
protected GameMove[] |
listLegalMoves()
listLegalMoves() returns the legal moves for this game. |
int |
nextPlayer()
nextPlayer() returns the integer representing the game role of the next player. |
protected boolean |
popMove()
popMove undoes the last move by altering the game board to the stage before the last move happened. |
protected boolean |
pushMove(GameMove move)
pushMove takes a GameMove and alters the game according to to the move. |
String |
toString()
overridden to provide useful information about the game |
| Methods inherited from class com.antelmann.game.AbstractGame |
|---|
addObserver, clearRedoList, getGameName, getLastMove, getLastPlayer, getLegalMoves, getLegalMoves, getMoveHistory, getNumberOfRedoMoves, getObservers, getRedoList, isLegalMove, isWinner, loadFromFile, makeMove, numberOfMoves, numberOfPlayers, redoMove, removeObserver, resetLegalMoves, resetLists, saveToFile, spawnChild, undoLastMove, undoMoves |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static int NUMBER_OF_DECKS
public static int MINIMUM_CARDS
public static int BURN_CARDS
| Constructor Detail |
|---|
public BlackJack()
public BlackJack(float bet)
public BlackJack(float[] bet)
public BlackJack(float[] bet,
Random random)
public BlackJack(CardDeck deck,
float[] bet)
public BlackJack(CardDeck deck,
float[] bet,
Random random)
| Method Detail |
|---|
public Card getOpenDealerCard()
public Vector<Card> getDealerCards()
public CardDeck getDeck()
public com.antelmann.game.card.BJHand getCurrentHand(int playerRole)
public static int getHandValue(Collection cards)
public static boolean isSoft(Collection cards)
public static int getCardValue(Card card,
boolean softCount)
public static boolean isBlackJack(Collection cards)
public boolean gameOver()
AbstractGame
gameOver in class AbstractGamepublic int[] getWinner()
GamePlay
public double getResult(int playerRole)
AbstractGame
getResult in interface GamePlaygetResult in class AbstractGamepublic int nextPlayer()
GamePlay
protected GameMove[] listLegalMoves()
AbstractGame
listLegalMoves in class AbstractGameprotected boolean pushMove(GameMove move)
AbstractGame
pushMove in class AbstractGameprotected boolean popMove()
AbstractGame
popMove in class AbstractGame
public Object clone()
throws CloneNotSupportedException
clone in interface GamePlayclone in class AbstractGameCloneNotSupportedExceptionAbstractGame.spawnChild(GameMove)public String toString()
AbstractGame
toString in class AbstractGame
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||