|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectglassfrog.model.Dealer
public class Dealer
The Dealer class will handle all of the methods of dealing cards, evaluating hands, pots, and betting actions. There should be one Dealer per Room, and each dealer is assigned a list of Players and a Gamedef to which they will use to play. Dealers may also be assigned a Room in which they can report game outcomes and similar information. The Room may also be used to handle the player requests and actions, although I am not sure that will be the case
Field Summary | |
---|---|
private static int |
ACTION_DELAY
|
private Hand |
currentHand
|
private int |
currentPlayer
|
private Deck |
deck
|
private static java.lang.String |
DEFAULT_ACTION
|
private boolean |
disconnected
|
private java.io.FileWriter |
divatLog
|
private java.io.BufferedWriter |
divatLogWriter
|
private boolean |
error
|
private java.io.FileWriter |
errorLog
|
private java.io.BufferedWriter |
errorLogWriter
|
private Gamedef |
gamedef
|
private boolean |
gameOver
|
private Gamestate |
gamestate
|
private int |
handsPlayed
|
private boolean |
hasReported
|
private java.lang.String |
lastAction
|
private java.io.FileWriter |
matchLog
|
private java.io.BufferedWriter |
matchLogWriter
|
private java.lang.String |
name
|
private int |
numHands
|
private static int |
PLAYER_TIMEOUT
|
private java.util.LinkedList<Player> |
players
|
private boolean |
shuffle
|
private java.io.FileWriter |
summaryLog
|
private java.io.BufferedWriter |
summaryLogWriter
|
Constructor Summary | |
---|---|
Dealer(java.lang.String name,
int numHands,
Gamedef gamedef,
int seed,
java.util.LinkedList<Player> players)
|
Method Summary | |
---|---|
void |
deal()
Deal will deal a game until the Gamedef.gameOver is true. |
private void |
evaluateHand()
The evaluateHand function runs the routine for determining which players won and how much each of them won. |
private java.lang.String |
getGameState(Player p)
Get the gamestate for the specified player in the AAAI competition format This is a string representation of the betting, and the private and public cards |
private Player |
getNextPlayer()
This function returns the next active player. |
private java.lang.String |
getShowdownGameState(Player p)
Get the Full Showdown Gamestate to send to the players at HandOver |
java.lang.String |
getStats()
Return stats about the game. |
private void |
handleDisconnect()
On a disconnect, for now we are going to do a few things. |
private void |
initLogging()
Initialize the logs for the game. |
boolean |
isDisconnected()
Check to see if one of the players has disconnected |
boolean |
isError()
Check to see if the game error'd out |
boolean |
isGameOver()
Check to see whether or not the games is over |
private boolean |
isHandOver()
Check to see if everyone is all in or has folded (basically nobody can act anymore) |
private boolean |
isRoundOver()
Check to see if the round is over according to the rules of the game For this to be satisfied, all the players must now be unable to act. |
private static void |
loadSettings()
|
private void |
logDivat()
Log a divat readable gamestate into a divat log. |
void |
logError(java.lang.Exception ex)
Utility for logging an error message to the errorLogger |
void |
logState(java.lang.String matchstate)
Log a gamesate to the matchlogger |
private void |
logStats()
Log the game stats |
private void |
logSummary()
|
void |
logWarning(java.lang.String warningMessage)
Utility for logging a warning message to the errorLogger |
private int |
nextPlayer()
Increments the currentPlayer index to the next player and returns that index. |
private void |
nextRound()
Update the game to the next round. |
private java.lang.String |
parseAction(java.lang.String response)
Parse out the last token of the response string and return it as the action the player took |
private void |
playHand()
Plays a single hand of poker. |
private void |
playRound()
This function follows the following algorithm: while(! |
private void |
postBlinds()
This posts the "antes" or blinds for the game. |
private void |
readObject(java.io.ObjectInputStream in)
An overriden function used when loading the object. |
boolean |
reconnectPlayers(java.util.LinkedList<Player> players)
Set the players of the game. |
boolean |
restorePlayer(java.lang.String name,
int seat,
int stack,
int position,
int score)
Restores a player matching the name. |
void |
restoreToHand(int handNumber)
Used to restore the game to a specific hand. |
void |
run()
Run the dealer in a thread |
private void |
sendPlayerInfos()
Send the gui players the player info for correct display. |
void |
setCurrentHand(Hand testHand)
Only used for test purposed, this is a method to create a specific hand |
void |
setDisconnected(boolean disconnected)
Set the disconnected flag |
private void |
shutdownLogging()
Close the log files |
private void |
updateGamestate()
Update the current gamestate. |
private void |
updatePlayers()
Send the players thier new gamestates |
private void |
writeObject(java.io.ObjectOutputStream out)
An overriden function used to change the default serialization behavior on a write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Gamedef gamedef
private Gamestate gamestate
private Hand currentHand
private java.util.LinkedList<Player> players
private Deck deck
private int currentPlayer
private int handsPlayed
private int numHands
private java.lang.String lastAction
private java.lang.String name
private boolean gameOver
private boolean hasReported
private boolean error
private boolean shuffle
private transient java.io.FileWriter errorLog
private transient java.io.FileWriter matchLog
private transient java.io.FileWriter divatLog
private transient java.io.FileWriter summaryLog
private transient java.io.BufferedWriter errorLogWriter
private transient java.io.BufferedWriter matchLogWriter
private transient java.io.BufferedWriter divatLogWriter
private transient java.io.BufferedWriter summaryLogWriter
private boolean disconnected
private static java.lang.String DEFAULT_ACTION
private static int PLAYER_TIMEOUT
private static int ACTION_DELAY
Constructor Detail |
---|
public Dealer(java.lang.String name, int numHands, Gamedef gamedef, int seed, java.util.LinkedList<Player> players)
name
- A String to represent the name of the game for the log filenumHands
- the number of hands of which the dealer will playgamedef
- The @Gamedef that will be used to playseed
- An integer representing the seed in which to seed the deck RNGplayers
- A list of Players that will be seated in the game.Method Detail |
---|
public boolean reconnectPlayers(java.util.LinkedList<Player> players)
players
- LinkedList containing player objects for the game
private void initLogging()
public void logError(java.lang.Exception ex)
ex
- An exception to logpublic void logWarning(java.lang.String warningMessage)
warningMessage
- A message to log to the error logpublic void logState(java.lang.String matchstate)
matchstate
- the gamestate message to log to the match logprivate void logStats()
private void logDivat()
value
- The value of the game for the first playerprivate void logSummary()
public void deal()
private void shutdownLogging()
private void sendPlayerInfos()
public void setCurrentHand(Hand testHand)
testHand
- private void playHand()
private void playRound()
private void handleDisconnect()
private void nextRound()
private void postBlinds()
private int nextPlayer()
private Player getNextPlayer()
private boolean isRoundOver()
private void updateGamestate()
private boolean isHandOver()
private void evaluateHand()
private java.lang.String getGameState(Player p)
p
- The player for whom to show the gamestate
private java.lang.String getShowdownGameState(Player p)
position
- The position of the player to send this too.
private void updatePlayers()
private java.lang.String parseAction(java.lang.String response)
playerResponse
-
public void run()
run
in interface java.lang.Runnable
public java.lang.String getStats()
public boolean isGameOver()
public boolean isDisconnected()
public boolean isError()
public void setDisconnected(boolean disconnected)
disconnected
- a boolean to set the disconnected flagprivate void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
out
- the output stream to write the object to
java.io.IOException
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- The input stream to load the object from
java.io.IOException
java.lang.ClassNotFoundException
public boolean restorePlayer(java.lang.String name, int seat, int stack, int position, int score)
name
- The players name to restoreseat
- The seat to restore the player tostack
- The stacksize the player needs restoring toposition
- The positions to restore the player toscore
- The score of the player to be restored
public void restoreToHand(int handNumber)
handNumber
- The hand to restore toprivate static void loadSettings() throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXParseException, org.xml.sax.SAXException, java.io.IOException, java.lang.InterruptedException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXParseException
org.xml.sax.SAXException
java.io.IOException
java.lang.InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |