com.asdf.plugins.pokergames
Class PokerGameController

java.lang.Object
  extended by com.asdf.common.GameController
      extended by com.asdf.plugins.pokergames.PokerGameController
All Implemented Interfaces:
MessageHandler
Direct Known Subclasses:
TexasGameController

public abstract class PokerGameController
extends GameController

Provides control for receiving game updates and forwarding them to the players and GUI and sending actions to server


Field Summary
 GameInfo gameInfo
           
 
Constructor Summary
PokerGameController()
           
 
Method Summary
 void addBot(int seatNumber, java.lang.String name, Player bot, double cash)
          Adding a bot to the table, sends the info to the server Should be called only after the seat has been successfully reserved
 void addPlayer(int seatNumber, java.lang.String plrName, double cash)
          A player sits to the table, creates a new OurPlayer and sends the info to the Server Should be called only after the player has received confirmation of a successful reservation
 java.lang.String getAccountName()
          Returns the name of the account for the user
 GameInfo getGameInfo()
          Getter for current game state
 boolean getHasNextAction()
           
 int getNextAction()
          Getter for next action.
 double getNextAmount()
          Getter for next amount.
 int getOurPlayer()
          Getter for the main seat player.
 Player[] getPlayers()
          Getter for players
 PokerGameController getThis()
          Getter for myself.
 Hand[] getVisibleHands(int seat)
          Retrieves visible hands.
 void handleRequest(Request req)
          Handles a Request sent by the server.
 void handleResponse(Response rsp)
          Handles a response sent by players.
 void handleStateUpdate(StateUpdate stateUp)
          Handles StateUpdates sent by server.
 void init(GameResponse response, java.lang.String accountName, AccountType accountType)
          initialized the game controller for use.
 void playerBack(int seatNumber)
          Receives notification from GUI for a player wishing to come back from sit out and forwards it to the server
 void receiveConfirmationForReservation(int seat)
          Receives confirmation for a seat reservation.
 void receiveHand(Hand hand, int seat)
          Receives a hand for a given seat.
 void removePlayer(int seatNumber)
          Removes player from given seat and sends the action to leave to the server Always supposed to close the window
 void removePlayer(int seatNumber, boolean isLeavingTable)
          Removes player from given seat and sends the action to leave to the server
 boolean reserveSeat(int seat)
          called when a player wants to reserve a seat, adds a reserving object to the model (only for internal purposes) and sends a reserve action to server
 void sendAction(Action action, int currentPlayer)
          Sends an action message to server.
 void sendChat(java.lang.String message)
          Gets chat messages from the GUI to be send forwards to the server If the player is playing, uses the name given, otherwise uses accountname if logged in, or Guest
 void sendChat(java.lang.String name, java.lang.String message)
          Sends given chat to the server for distribution
 void sendVoice(byte[] data)
          Send voice data to server.
 void setHasNextAction(boolean has)
          Setter for has an action to process.
 void setNextAction(int nextAction)
          Setter for action.
 void setNextAction(int nextAction, double amount)
          Setter for the next action to be processed.
 void setNextAmount(double amount)
          Setter for nextAmount
 void standing()
          called to update the available seats, after not sitting down after reserving a seat, or only adding a bot
 void updateGameModel(GameModel newModel)
          Updates the game model given the new game model If the current player is one in this controller, starts a thread to get it's action
 void updateGUI()
          Updates game information for a GUI instance
 void updateGUIBigger()
          Updates game information and turn related information.
 void updateSeatAvailable()
          Calls GUI to update available seat positions
 void waitForNextAction()
          Waits for the next action.
 void zeroActions()
          Clears all current action information.
 
Methods inherited from class com.asdf.common.GameController
getConnectionHandler, getGameID, getID, setConnectionHandler, setGameID, setID, start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gameInfo

public GameInfo gameInfo
Constructor Detail

PokerGameController

public PokerGameController()
Method Detail

getThis

public PokerGameController getThis()
Getter for myself.

Returns:
me.

getAccountName

public java.lang.String getAccountName()
Returns the name of the account for the user


getPlayers

public Player[] getPlayers()
Getter for players

Returns:
All players participating in the game.

getOurPlayer

public int getOurPlayer()
Getter for the main seat player.

Returns:
the human controlled player's seat.

getGameInfo

public GameInfo getGameInfo()
Getter for current game state

Returns:
Model of current game state

waitForNextAction

public void waitForNextAction()
Waits for the next action.


setHasNextAction

public void setHasNextAction(boolean has)
Setter for has an action to process.

Parameters:
has - with value 'true' awakens waiting position to start handling actions.

getHasNextAction

public boolean getHasNextAction()

setNextAction

public void setNextAction(int nextAction,
                          double amount)
Setter for the next action to be processed.

Parameters:
nextAction - Integer description of the action.
amount - Cash amounts related to action, meaning depends on the value of action.

setNextAction

public void setNextAction(int nextAction)
Setter for action.

Parameters:
nextAction - Integer description of the action.

setNextAmount

public void setNextAmount(double amount)
Setter for nextAmount

Parameters:
amount - Cash amounts related to nextAction, meaning depends on the value of action.

zeroActions

public void zeroActions()
Clears all current action information.


getNextAction

public int getNextAction()
Getter for next action.

Returns:
integer description of the next action.

getNextAmount

public double getNextAmount()
Getter for next amount.

Returns:
Cash amounts related to the action. Meaning depends on the value of action.

updateGUI

public void updateGUI()
Updates game information for a GUI instance


updateGUIBigger

public void updateGUIBigger()
Updates game information and turn related information. Called only on inter-player turn changes.


updateSeatAvailable

public void updateSeatAvailable()
Calls GUI to update available seat positions


updateGameModel

public void updateGameModel(GameModel newModel)
Updates the game model given the new game model If the current player is one in this controller, starts a thread to get it's action

Parameters:
newModel - A new game model.

addPlayer

public void addPlayer(int seatNumber,
                      java.lang.String plrName,
                      double cash)
A player sits to the table, creates a new OurPlayer and sends the info to the Server Should be called only after the player has received confirmation of a successful reservation

Parameters:
seatNumber - the seat to sit at
plrName - name of the player
cash - amount of money brought to table

addBot

public void addBot(int seatNumber,
                   java.lang.String name,
                   Player bot,
                   double cash)
Adding a bot to the table, sends the info to the server Should be called only after the seat has been successfully reserved

Parameters:
seatNumber - the seat to sit the bot at
name - name of the bot
bot - object implementing the Player interface for the bot
cash - amount of money brought to table

removePlayer

public void removePlayer(int seatNumber)
Removes player from given seat and sends the action to leave to the server Always supposed to close the window

Parameters:
seatNumber -

removePlayer

public void removePlayer(int seatNumber,
                         boolean isLeavingTable)
Removes player from given seat and sends the action to leave to the server

Parameters:
seatNumber -
isLeavingTable - when the player leaving also closes the window

playerBack

public void playerBack(int seatNumber)
Receives notification from GUI for a player wishing to come back from sit out and forwards it to the server

Parameters:
seatNumber - seat of the returning player

reserveSeat

public boolean reserveSeat(int seat)
called when a player wants to reserve a seat, adds a reserving object to the model (only for internal purposes) and sends a reserve action to server

Parameters:
seat - the seat to reserve
Returns:
true if seat was free in the local model, this is useless, though

standing

public void standing()
called to update the available seats, after not sitting down after reserving a seat, or only adding a bot


getVisibleHands

public Hand[] getVisibleHands(int seat)
Retrieves visible hands. This includes the players own hand and the hands that are revealed.

Parameters:
seat - The user's seat.
Returns:
An array of hands.

sendAction

public void sendAction(Action action,
                       int currentPlayer)
Sends an action message to server.

Parameters:
action - Action of current player.
currentPlayer - Seat of the current player.

sendVoice

public void sendVoice(byte[] data)
Send voice data to server. Voice is wrapped in GZIP compressed Base-64 encoded string.

Parameters:
data - Voice data

sendChat

public void sendChat(java.lang.String name,
                     java.lang.String message)
Sends given chat to the server for distribution

Parameters:
name - The sender's name
message -

receiveHand

public void receiveHand(Hand hand,
                        int seat)
Receives a hand for a given seat.

Parameters:
hand - The hand received.
seat - The seat for which the hand was received.

receiveConfirmationForReservation

public void receiveConfirmationForReservation(int seat)
Receives confirmation for a seat reservation. Calls GUI to update view.

Parameters:
seat - Seat which is reserved.

sendChat

public void sendChat(java.lang.String message)
Gets chat messages from the GUI to be send forwards to the server If the player is playing, uses the name given, otherwise uses accountname if logged in, or Guest

Parameters:
message -

init

public void init(GameResponse response,
                 java.lang.String accountName,
                 AccountType accountType)
initialized the game controller for use. Sets the connection handler.

Specified by:
init in class GameController
Parameters:
response - Parameters received from server required to initialize this
accountName - Account name of the user who is associated with this GameController.
accountType - Type of the user account. Some users might have more privileges than others. GameController

handleResponse

public void handleResponse(Response rsp)
Handles a response sent by players.

Parameters:
rsp - Response sent by server. Response is an object generated from XML message using JAXB.

handleRequest

public void handleRequest(Request req)
Description copied from interface: MessageHandler
Handles a Request sent by the server. You may wish to leave this method as a stub in your implementation if you are not interested in receiving this kind of messages.

Parameters:
req - Request sent by server. Request is an object generated from XML message using JAXB.

handleStateUpdate

public void handleStateUpdate(StateUpdate stateUp)
Description copied from interface: MessageHandler
Handles StateUpdates sent by server. You may wish to leave this method as a stub in your implementation if you are not interested in receiving this kind of messages.

Parameters:
stateUp - StateUpdate sent by server. StateUpdate is an object generated from XML message using JAXB.