soc.client
Class SOCPlayerInterface

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended bysoc.client.SOCPlayerInterface
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class SOCPlayerInterface
extends java.awt.Frame
implements java.awt.event.ActionListener

Window with interface for a player in one game of Settlers of Catan. Contains board, client and other players' hands, chat interface, game message window, and building/buying panel.

A separate SOCPlayerClient window holds the list of current games and channels.

Author:
Robert S. Thomas
See Also:
Serialized Form

Nested Class Summary
private static class SOCPlayerInterface.MyWindowAdapter
           
protected static class SOCPlayerInterface.ResetBoardVoteDialog
          This is the dialog to vote on another player's board reset request.
private static class SOCPlayerInterface.SOCPIDiscardMsgTask
          When timer fires, show discard message in any other player (not client player) who must discard.
private static class SOCPlayerInterface.SOCPITextfieldListener
          Used for chat textfield setting/clearing initial prompt text (TEXTINPUT_INITIAL_PROMPT_MSG).
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean boardIsScaled
          Is the boardpanel stretched beyond normal size in doLayout()?
protected  SOCBoardPanel boardPanel
          the board display
protected  SOCHandPanel boardResetRequester
          this other player has requested a board reset; voting is under way.
protected  SOCPlayerInterface.ResetBoardVoteDialog boardResetVoteDia
          Board reset voting: If voting is active and we haven't yet voted, track our dialog; this lets us dispose of it if voting is cancelled.
protected  SOCBuildingPanel buildingPanel
          interface for building pieces
protected  SnippingTextArea chatDisplay
          where chat text is displayed
protected  SOCChoosePlayerDialog choosePlayerDialog
          the dialog for choosing a player from which to steal
protected  SOCPlayerClient client
          the client that spawned us
protected  SOCHandPanel clientHand
          Tracks our own hand within hands[], if we are active in a game.
private  int clientHandPlayerNum
          Player ID of clientHand, or -1.
protected  SOCDiscardDialog discardDialog
          the dialog for getting what resources the player wants to discard
protected  SOCDiscoveryDialog discoveryDialog
          the dialog for choosing 2 resources to discover
protected  java.util.Timer eventTimer
          Utility for time-driven events in the interface.
protected  SOCGame game
          the game associated with this interface
protected  boolean gameIsStarting
          Flag to ensure interface is updated, when the first actual turn begins (state changes from SOCGame.START2B to SOCGame.PLAY).
protected  SOCHandPanel[] hands
          the display for the players' hands
protected  SOCMonopolyDialog monopolyDialog
          the dialog for choosing a resource to monopolize
protected  int ncols
          number of columns in the text output area
protected  int npix
          width of text output area in pixels
protected  java.awt.Color[] playerColors
          the player colors.
protected  java.awt.Color[] playerColorsGhost
          the player colors.
private  boolean showingPlayerDiscards
          Is one or more handpanel (of other players) showing a "Discarding..." message?
private  java.lang.Object showingPlayerDiscards_lock
          Synchronize access to showingPlayerDiscards and showingPlayerDiscardsTask
private  SOCPlayerInterface.SOCPIDiscardMsgTask showingPlayerDiscardsTask
          May be null if not active.
protected  SnippingTextArea textDisplay
          where text is displayed
protected  int textDisplayRollExpected
          To reduce text clutter: server has just sent a dice result message.
protected  java.awt.TextField textInput
          where the player types in text
static java.lang.String TEXTINPUT_INITIAL_PROMPT_MSG
          Not yet typed-in; display prompt message.
protected  int textInputGreyCountdown
          Number of change-of-turns during game, after which the initial prompt message fades to light grey.
protected static int textInputGreyCountFrom
          Initial value (20 turns) for textInputGreyCountdown
protected  boolean textInputHasSent
          At least one text chat line has been sent by the player.
protected  boolean textInputIsInitial
          Not yet typed-in; display prompt message.
protected  SOCPlayerInterface.SOCPITextfieldListener textInputListener
          Used for responding to textfield changes by setting/clearing prompt message.
static java.lang.String TITLEBAR_GAME
          Titlebar text for game in progress
static java.lang.String TITLEBAR_GAME_OVER
          Titlebar text for game when over
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SOCPlayerInterface(java.lang.String title, SOCPlayerClient cl, SOCGame ga)
          create a new player interface
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          send the message that was just typed in
 void addPlayer(java.lang.String n, int pn)
          a player has sat down to play
 void began()
          start the game interface: add "sit" buttons, set chat input (textInput) to initial prompt.
 void changeFace(int pn, int id)
          set the face icon for a player
 void chatPrint(java.lang.String s)
          print text in the chat window
 void chatPrintDebug(java.lang.String debugMsg)
          if debug is enabled, print this in the chat display.
 void chatPrintStackTrace(java.lang.Throwable th)
          if debug is enabled, print this exception's stack trace in the chat display.
private  void chatPrintStackTrace(java.lang.Throwable th, boolean isNested)
           
 void choosePlayer(int count, int[] pnums)
          show the choose player dialog box
 boolean clientIsCurrentPlayer()
          Is the client player active in this game, and the current player?
private  void discardTimerClear()
           
private  void discardTimerSet()
          Gamestate just became SOCGame.WAITING_FOR_DISCARDS.
 void doLayout()
          do the layout
 SOCBoardPanel getBoardPanel()
           
 SOCBuildingPanel getBuildingPanel()
           
 SOCPlayerClient getClient()
           
 SOCHandPanel getClientHand()
          The client player's SOCHandPanel interface, if active in a game.
 int getClientPlayerNumber()
          If client player is active in game, their player number.
 java.util.Timer getEventTimer()
           
 SOCGame getGame()
           
 java.awt.Color getPlayerColor(int pn)
           
 java.awt.Color getPlayerColor(int pn, boolean isGhost)
           
 SOCHandPanel getPlayerHandPanel(int pn)
           
protected  void initInterfaceElements(boolean firstCall)
          Setup the interface elements
 void leaveGame()
          leave this game
static java.awt.Color makeGhostColor(java.awt.Color srcColor)
          Calculate a color towards gray, for a hilight or the robber ghost.
 void over(java.lang.String s)
          an error occured, stop editing
 void print(java.lang.String s)
          print text in the text window
 void removePlayer(int pn)
          remove a player from the game
 void resetBoard(SOCGame newGame, int rejoinPlayerNumber, int requesterNumber)
          Handle board reset (new game with same players, same game name).
 void resetBoardAskVote(int pnRequester)
          Creates and shows a new ResetBoardVoteDialog.
private  void resetBoardClearDia()
          Callback from ResetBoardVoteDialog, to clear our reference when button is clicked and dialog is going away.
 void resetBoardRejected()
          Voting complete, board reset was rejected.
 void resetBoardRequest()
          Player wants to request to reset the board (same players, new game, new layout).
 void resetBoardVoted(int pn, boolean vyes)
          Another player has voted on a board reset request.
 void setClientHand(SOCHandPanel h)
          Update the client player's SOCHandPanel interface, for joining or leaving a game.
 void setTextDisplayRollExpected(int roll)
          To reduce text clutter: server has just sent a dice result message.
 void showDiscardDialog(int nd)
          show the discard dialog
 void showDiscoveryDialog()
          show the Discovery dialog box
 void showMonopolyDialog()
          show the Monopoly dialog box
 void startGame()
          Game play is starting (leaving state SOCGame.NEW).
protected  void textInputSetToInitialPrompt(boolean setToInitial)
          Set or clear the chat text input's initial prompt.
 void update(java.awt.Graphics g)
          Overriden so the peer isn't painted, which clears background.
 void updateAtGameState()
          Update interface after game state has changed.
 void updateAtOver(int[] finalScores)
          Game is over; server has sent us the revealed scores for each player.
 void updateAtPlay1()
          Client is current player; state changed from PLAY to PLAY1.
 void updateAtTurn(int pnum)
          Game's current player has changed.
 void updateDevCardCount()
          The game's count of development cards remaining has changed.
 void updateLongestLargest(boolean isRoadNotArmy, SOCPlayer oldp, SOCPlayer newp)
          The game's longest road or largest army may have changed.
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

boardPanel

protected SOCBoardPanel boardPanel
the board display


boardIsScaled

protected boolean boardIsScaled
Is the boardpanel stretched beyond normal size in doLayout()?

See Also:
SOCBoardPanel.isScaled()

textInput

protected java.awt.TextField textInput
where the player types in text


textInputIsInitial

protected boolean textInputIsInitial
Not yet typed-in; display prompt message.

See Also:
textInput, TEXTINPUT_INITIAL_PROMPT_MSG

textInputHasSent

protected boolean textInputHasSent
At least one text chat line has been sent by the player. Don't show the initial prompt message if the text field becomes blank again.

See Also:
textInput, TEXTINPUT_INITIAL_PROMPT_MSG

textInputGreyCountdown

protected int textInputGreyCountdown
Number of change-of-turns during game, after which the initial prompt message fades to light grey.

See Also:
textInput, textInputGreyCountFrom

textInputGreyCountFrom

protected static int textInputGreyCountFrom
Initial value (20 turns) for textInputGreyCountdown

See Also:
textInputGreyCountdown

TEXTINPUT_INITIAL_PROMPT_MSG

public static final java.lang.String TEXTINPUT_INITIAL_PROMPT_MSG
Not yet typed-in; display prompt message.

See Also:
textInput, Constant Field Values

TITLEBAR_GAME

public static final java.lang.String TITLEBAR_GAME
Titlebar text for game in progress

See Also:
Constant Field Values

TITLEBAR_GAME_OVER

public static final java.lang.String TITLEBAR_GAME_OVER
Titlebar text for game when over

See Also:
Constant Field Values

textInputListener

protected SOCPlayerInterface.SOCPITextfieldListener textInputListener
Used for responding to textfield changes by setting/clearing prompt message.

See Also:
textInput

textDisplay

protected SnippingTextArea textDisplay
where text is displayed


chatDisplay

protected SnippingTextArea chatDisplay
where chat text is displayed


buildingPanel

protected SOCBuildingPanel buildingPanel
interface for building pieces


hands

protected SOCHandPanel[] hands
the display for the players' hands


clientHand

protected SOCHandPanel clientHand
Tracks our own hand within hands[], if we are active in a game. Null otherwise. Set by SOCHandPanel's removePlayer() and addPlayer() methods.


clientHandPlayerNum

private int clientHandPlayerNum
Player ID of clientHand, or -1. Set by SOCHandPanel's removePlayer() and addPlayer() methods.


playerColors

protected java.awt.Color[] playerColors
the player colors. Indexes from 0 to SOCGame.MAXPLAYERS - 1.


playerColorsGhost

protected java.awt.Color[] playerColorsGhost
the player colors. Indexes from 0 to SOCGame.MAXPLAYERS - 1.


client

protected SOCPlayerClient client
the client that spawned us


game

protected SOCGame game
the game associated with this interface


gameIsStarting

protected boolean gameIsStarting
Flag to ensure interface is updated, when the first actual turn begins (state changes from SOCGame.START2B to SOCGame.PLAY). Initially set in startGame(). Checked/cleared in updateAtGameState();


boardResetRequester

protected SOCHandPanel boardResetRequester
this other player has requested a board reset; voting is under way. Null if no board reset vote is under way.

See Also:
SOCServer.resetBoardAndNotify(String, int)

boardResetVoteDia

protected SOCPlayerInterface.ResetBoardVoteDialog boardResetVoteDia
Board reset voting: If voting is active and we haven't yet voted, track our dialog; this lets us dispose of it if voting is cancelled.


showingPlayerDiscards

private boolean showingPlayerDiscards
Is one or more handpanel (of other players) showing a "Discarding..." message?


showingPlayerDiscards_lock

private java.lang.Object showingPlayerDiscards_lock
Synchronize access to showingPlayerDiscards and showingPlayerDiscardsTask


showingPlayerDiscardsTask

private SOCPlayerInterface.SOCPIDiscardMsgTask showingPlayerDiscardsTask
May be null if not active. @see #showingPlayerDiscards


ncols

protected int ncols
number of columns in the text output area


npix

protected int npix
width of text output area in pixels


textDisplayRollExpected

protected int textDisplayRollExpected
To reduce text clutter: server has just sent a dice result message. If the next text message from server is the roll, replace: * It's Player's turn to roll the dice. \n * Player rolled a 4 and a 5. with: * It's Player's turn to roll. Rolled a 9.

Set to 0 at most times. Set to the roll result when roll text is expected. Will be cleared to 0 in print(String). Whenever this field is nonzero, textmessages from the server will be scanned for " rolled a ".


eventTimer

protected java.util.Timer eventTimer
Utility for time-driven events in the interface. See getEventTimer() for some users.


discardDialog

protected SOCDiscardDialog discardDialog
the dialog for getting what resources the player wants to discard


choosePlayerDialog

protected SOCChoosePlayerDialog choosePlayerDialog
the dialog for choosing a player from which to steal


discoveryDialog

protected SOCDiscoveryDialog discoveryDialog
the dialog for choosing 2 resources to discover


monopolyDialog

protected SOCMonopolyDialog monopolyDialog
the dialog for choosing a resource to monopolize

Constructor Detail

SOCPlayerInterface

public SOCPlayerInterface(java.lang.String title,
                          SOCPlayerClient cl,
                          SOCGame ga)
create a new player interface

Parameters:
title - title for this interface - game name
cl - the player client that spawned us
ga - the game associated with this interface
Method Detail

initInterfaceElements

protected void initInterfaceElements(boolean firstCall)
Setup the interface elements

Parameters:
firstCall - First setup call for this window; do global things such as windowListeners, not just component-specific things.

update

public void update(java.awt.Graphics g)
Overriden so the peer isn't painted, which clears background. Don't call this directly, use Component.repaint() instead.


getClient

public SOCPlayerClient getClient()
Returns:
the client that spawned us

getGame

public SOCGame getGame()
Returns:
the game associated with this interface

getPlayerColor

public java.awt.Color getPlayerColor(int pn)
Parameters:
pn - the player number
Returns:
the color of a player

getPlayerColor

public java.awt.Color getPlayerColor(int pn,
                                     boolean isGhost)
Parameters:
pn - the player number
Returns:
the "ghosted" color of a player

getPlayerHandPanel

public SOCHandPanel getPlayerHandPanel(int pn)
Parameters:
pn - the player's seat number
Returns:
a player's hand panel
See Also:
getClientHand()

getBoardPanel

public SOCBoardPanel getBoardPanel()
Returns:
the board panel

getEventTimer

public java.util.Timer getEventTimer()
Returns:
the timer for time-driven events in the interface
See Also:
SOCHandPanel.autoRollSetupTimer(), SOCBoardPanel.popupSetBuildRequest(int, int)

updateDevCardCount

public void updateDevCardCount()
The game's count of development cards remaining has changed. Update the display.


updateLongestLargest

public void updateLongestLargest(boolean isRoadNotArmy,
                                 SOCPlayer oldp,
                                 SOCPlayer newp)
The game's longest road or largest army may have changed. Update each player's handpanel (victory points and longest-road/ largest-army indicator). If it changed, print an announcement in the message window.

Call this only after updating the SOCGame objects.

Parameters:
isRoadNotArmy - Longest-road, not largest-army, has just changed
oldp - Previous player with longest/largest, or null if none
newp - New player with longest/largest, or null if none

getBuildingPanel

public SOCBuildingPanel getBuildingPanel()
Returns:
the building panel

getClientHand

public SOCHandPanel getClientHand()
The client player's SOCHandPanel interface, if active in a game.

Returns:
our player's hand interface, or null if not in a game.

setClientHand

public void setClientHand(SOCHandPanel h)
Update the client player's SOCHandPanel interface, for joining or leaving a game. Set by SOCHandPanel's removePlayer() and addPlayer() methods.

Parameters:
h - The SOCHandPanel for us, or null if none (leaving).

clientIsCurrentPlayer

public boolean clientIsCurrentPlayer()
Is the client player active in this game, and the current player?

See Also:
getClientPlayerNumber()

getClientPlayerNumber

public int getClientPlayerNumber()
If client player is active in game, their player number.

Returns:
client's player ID, or -1.
See Also:
clientIsCurrentPlayer()

setTextDisplayRollExpected

public void setTextDisplayRollExpected(int roll)
To reduce text clutter: server has just sent a dice result message. If the next text message from server is the roll, replace: * It's Player's turn to roll the dice. \n * Player rolled a 4 and a 5. with: * It's Player's turn to roll. Rolled a 9.

Set to 0 at most times. Set to the roll result when roll text is expected. Will be cleared to 0 in print(String).

Whenever this field is nonzero, textmessages from the server will be scanned for " rolled a ".

Parameters:
roll - The expected roll result, or 0.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
send the message that was just typed in

Specified by:
actionPerformed in interface java.awt.event.ActionListener

leaveGame

public void leaveGame()
leave this game


resetBoardRequest

public void resetBoardRequest()
Player wants to request to reset the board (same players, new game, new layout). If acceptable, send request to server. If not, say so in text area. Not acceptable if they've already done so this turn, or if voting is active because another player called for a vote.

Board reset was added in version 1.1.00. Older servers won't support it. If this happens, give user a message.


resetBoardVoted

public void resetBoardVoted(int pn,
                            boolean vyes)
Another player has voted on a board reset request. Show the vote.


resetBoardRejected

public void resetBoardRejected()
Voting complete, board reset was rejected. Display text message and clear the offer.


resetBoardAskVote

public void resetBoardAskVote(int pnRequester)
Creates and shows a new ResetBoardVoteDialog. If the game is over, the "Reset" button is the default; otherwise, "No" is default. Also announces the vote request (text) and sets boardResetRequester. Dialog is shown in a separate thread, to continue message treating and screen redraws as the other players vote.

If we are the requester, we update local game state but don't vote.

Parameters:
pnRequester - Player number of the player requesting the board reset

resetBoardClearDia

private void resetBoardClearDia()
Callback from ResetBoardVoteDialog, to clear our reference when button is clicked and dialog is going away.


print

public void print(java.lang.String s)
print text in the text window

Parameters:
s - the text

chatPrint

public void chatPrint(java.lang.String s)
print text in the chat window

Parameters:
s - the text

over

public void over(java.lang.String s)
an error occured, stop editing

Parameters:
s - an error message

began

public void began()
start the game interface: add "sit" buttons, set chat input (textInput) to initial prompt. This doesn't mean that game play or placement is starting, only that the window is ready for players to choose where to sit.


addPlayer

public void addPlayer(java.lang.String n,
                      int pn)
a player has sat down to play

Parameters:
n - the name of the player
pn - the seat number of the player

removePlayer

public void removePlayer(int pn)
remove a player from the game

Parameters:
pn - the number of the player

startGame

public void startGame()
Game play is starting (leaving state SOCGame.NEW). Remove the start buttons and robot-lockout buttons. Next move is for players to make their starting placements.


updateAtOver

public void updateAtOver(int[] finalScores)
Game is over; server has sent us the revealed scores for each player. Refresh the display.

Parameters:
finalScores - Final score for each player position

updateAtTurn

public void updateAtTurn(int pnum)
Game's current player has changed. Update displays.

Parameters:
pnum - New current player number; should match game.getCurrentPlayerNumber()

textInputSetToInitialPrompt

protected void textInputSetToInitialPrompt(boolean setToInitial)
                                    throws java.lang.IllegalStateException
Set or clear the chat text input's initial prompt. Sets its status, foreground color, and the prompt text if true.

Parameters:
setToInitial - If false, clear initial-prompt status, and clear contents (if they are the initial-prompt message); If true, set initial-prompt status, and set the prompt (if contents are blank when trimmed).
Throws:
java.lang.IllegalStateException - if setInitial true, but player already sent chat text (textInputHasSent).
See Also:
TEXTINPUT_INITIAL_PROMPT_MSG

showDiscardDialog

public void showDiscardDialog(int nd)
show the discard dialog

Parameters:
nd - the number of discards

choosePlayer

public void choosePlayer(int count,
                         int[] pnums)
show the choose player dialog box

Parameters:
count - the number of players to choose from
pnums - the player ids of those players

showDiscoveryDialog

public void showDiscoveryDialog()
show the Discovery dialog box


showMonopolyDialog

public void showMonopolyDialog()
show the Monopoly dialog box


updateAtPlay1

public void updateAtPlay1()
Client is current player; state changed from PLAY to PLAY1. (Dice has been rolled, or card played.) Update interface accordingly.


updateAtGameState

public void updateAtGameState()
Update interface after game state has changed. Please call after SOCGame.setGameState(int). If the game is now starting, please call in this order: playerInterface.startGame(); game.setGameState(newState); playerInterface.updateAtGameState();


discardTimerSet

private void discardTimerSet()
Gamestate just became SOCGame.WAITING_FOR_DISCARDS. Set up a timer to wait 1 second before showing "Discarding..." balloons in players' handpanels.


discardTimerClear

private void discardTimerClear()

resetBoard

public void resetBoard(SOCGame newGame,
                       int rejoinPlayerNumber,
                       int requesterNumber)
Handle board reset (new game with same players, same game name). The reset message will be followed with others which will fill in the game state.

Parameters:
newGame - New game object
rejoinPlayerNumber - Sanity check - must be our correct player number in this game
requesterNumber - Player who requested the board reset
See Also:
SOCServer.resetBoardAndNotify(String, int)

changeFace

public void changeFace(int pn,
                       int id)
set the face icon for a player

Parameters:
pn - the number of the player
id - the id of the face image

chatPrintDebug

public void chatPrintDebug(java.lang.String debugMsg)
if debug is enabled, print this in the chat display.


chatPrintStackTrace

public void chatPrintStackTrace(java.lang.Throwable th)
if debug is enabled, print this exception's stack trace in the chat display. This eases tracing of exceptions when our code is called in AWT threads (such as EventDispatch).


chatPrintStackTrace

private void chatPrintStackTrace(java.lang.Throwable th,
                                 boolean isNested)

makeGhostColor

public static java.awt.Color makeGhostColor(java.awt.Color srcColor)
Calculate a color towards gray, for a hilight or the robber ghost. If srcColor is light, ghost color is darker. (average with gray) If it's dark or midtone, ghost should be lighter. (average with white)

Parameters:
srcColor - The color to ghost from
Returns:
Ghost color based on srcColor

doLayout

public void doLayout()
do the layout