soc.client
Class SOCPlayerInterface

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

public class SOCPlayerInterface
extends java.awt.Frame
implements java.awt.event.ActionListener, java.awt.event.MouseListener, SOCScenarioEventListener

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

Players' hands start with player 0 at top-left, and go clockwise; see doLayout() for details.

When we join a game, the client will update visible game state by calling methods here like addPlayer(String, int); when all this activity is complete, and the interface is ready for interaction, the client calls began(Vector).

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

Author:
Robert S. Thomas
See Also:
Serialized Form

Nested Class Summary
private  class SOCPlayerInterface.ChooseMoveRobberOrPirateDialog
          Modal dialog to ask whether to move the robber or the pirate ship.
private  class SOCPlayerInterface.ChooseRobClothOrResourceDialog
          Modal dialog to ask whether to rob cloth or a resource from the victim.
private static class SOCPlayerInterface.ClientBridge
          Client Bridge to translate interface to SOCPlayerInterface methods.
private static class SOCPlayerInterface.PIWindowAdapter
          React to window closing or losing focus (deactivation).
protected static class SOCPlayerInterface.ResetBoardConfirmDialog
          This is the modal dialog to confirm resetting the board after a practice game.
protected static class SOCPlayerInterface.ResetBoardVoteDialog
          This is the modal dialog to vote on another player's board reset request.
private static class SOCPlayerInterface.SOCPIDiscardOrPickMsgTask
          When timer fires, show discard message or picking-resource message for any other player (not client player) who must discard or pick.
private  class SOCPlayerInterface.SOCPITextDisplaysLargerTask
          For 6-player board, make the text displays larger/smaller when mouse enters/exits them.
private static class SOCPlayerInterface.SOCPITextfieldListener
          Used for chat textfield setting/clearing initial prompt text (TEXTINPUT_INITIAL_PROMPT_MSG).
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, 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.
private  boolean chatDisplayHasMouse
          Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp.
protected  SOCChoosePlayerDialog choosePlayerDialog
          the dialog for choosing a player from which to steal
protected  SOCPlayerClient client
           
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.
private  SOCPlayerInterface.ClientBridge clientListener
           
private  boolean didGameScenarioPopupCheck
          True if we've already shown game's scenario's descriptive text in a popup window when the client joined, or if the game has no scenario.
protected  SOCDiscardOrGainResDialog discardOrGainDialog
          The dialog for getting what resources the player wants to discard or gain.
protected  SOCGame game
          the game associated with this interface
protected  SOCPlayerClient.GameAwtDisplay gameDisplay
          the display that spawned us
protected  boolean gameIsStarting
          Flag to ensure interface is updated, when the first actual turn begins (state changes from SOCGame.START2B or SOCGame.START3B to SOCGame.PLAY).
private  SOCGameStatistics gameStats
           
protected  SOCHandPanel[] hands
          the display for the players' hands.
private  boolean is6player
          Is this game using the 6-player board? Checks SOCGame.maxPlayers.
private  boolean knowsGameState
          If true, updateAtGameState() has been called at least once, or the constructor was called with a non-zero SOCGame.getGameState().
private  boolean layoutNotReadyYet
          For perf/display-bugs during component layout (OSX firefox), show only background color in update(Graphics) when true.
protected  SOCMonopolyDialog monopolyDialog
          the dialog for choosing a resource to monopolize
protected  int ncols
          number of columns in the text output area
private  boolean needRepaintBorders
          Have we resized the board, and thus need to repaint the borders between panels? Determined in doLayout().
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  java.awt.Dimension prevSize
          Size of our window from Component.getSize(), not excluding insets.
private  boolean sbFixBHasMouse
          Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp and sbFixNeeded.
private  boolean sbFixLHasMouse
          Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp and sbFixNeeded.
private  boolean sbFixNeeded
          In 6-player games, text areas temporarily zoom when the mouse is over them.
private  boolean sbFixRHasMouse
          Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp and sbFixNeeded.
private  boolean showingPlayerDiscardOrPick
          Is one or more SOCHandPanel (of other players) showing a "Discarding..." or "Picking resource..." message?
private  java.lang.Object showingPlayerDiscardOrPick_lock
          Synchronize access to showingPlayerDiscardOrPick and showingPlayerDiscardOrPick_task
private  SOCPlayerInterface.SOCPIDiscardOrPickMsgTask showingPlayerDiscardOrPick_task
          May be null if not showingPlayerDiscardOrPick.
private static boolean SOCPI_isPlatformWindows
          Are we running on the Windows platform, according to SOCPI_osName?
private static java.lang.String SOCPI_osName
          System property os.name; For use by SOCPI_isPlatformWindows.
private static SOCStringManager strings
          i18n text strings
protected  SnippingTextArea textDisplay
          where text is displayed.
private  boolean textDisplayHasMouse
          Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp.
private  boolean textDisplaysLargerTemp
          In the 6-player layout, the text display fields (textDisplay, chatDisplay) aren't as large.
private  boolean textDisplaysLargerTemp_needsLayout
          When set, must return text display field sizes to normal in doLayout() after a previous textDisplaysLargerTemp flag set.
private  long textDisplaysLargerWhen
          If any text area is clicked in a 6-player game, give focus to the text input box; for use with mouseClicked(MouseEvent).
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
private  boolean textInputHasMouse
          Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp.
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.
 
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.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.GameAwtDisplay gd, SOCGame ga)
          Create and show 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(java.util.Vector<java.lang.String> members)
          start the game interface: 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)
           
(package private)  void clearTradeMsg(int pn)
          If the player's trade-offer panel is showing a message (not a trade offer), clear and hide it.
 boolean clientIsCurrentPlayer()
          Is the client player active in this game, and the current player? Assertion: If this returns true, getClientHand() will return non-null.
private  void discardOrPickTimerClear()
          Cancel any "discarding..." or "picking resources..." timer, and clear the message if showing.
private  void discardOrPickTimerSet(boolean isDiscard)
          Gamestate just became SOCGame.WAITING_FOR_DISCARDS or SOCGame.WAITING_FOR_PICK_GOLD_RESOURCE.
 void doLayout()
          Arrange the custom layout.
private  boolean doLocalCommand(java.lang.String cmd)
          Handle local client commands for games.
 void gameEvent(SOCGame ga, SOCScenarioGameEvent evt, java.lang.Object detail)
          Listener callback for scenario events on the large sea board which affect the game or board, not a specific player.
 SOCBoardPanel getBoardPanel()
           
 SOCBuildingPanel getBuildingPanel()
           
 SOCPlayerClient getClient()
           
 SOCHandPanel getClientHand()
          The client player's SOCHandPanel interface, if active in a game.
 PlayerClientListener getClientListener()
          Provide access to the client listener in case this class does not directly implement it.
 int getClientPlayerNumber()
          If client player is active in game, their player number.
 java.util.Timer getEventTimer()
           
 SOCGame getGame()
           
 SOCPlayerClient.GameAwtDisplay getGameDisplay()
           
 SOCGameStatistics getGameStats()
           
 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
protected  boolean isClientPlayer(SOCPlayer p)
           
 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 mouseClicked(java.awt.event.MouseEvent e)
          If any text area is clicked in a 6-player game, give focus to the text input box for ease-of-use.
 void mouseEntered(java.awt.event.MouseEvent e)
          Track TextField mouse cursor entry on 6-player board (MouseListener).
 void mouseExited(java.awt.event.MouseEvent e)
          Track TextField mouse cursor exit on 6-player board (MouseListener).
 void mousePressed(java.awt.event.MouseEvent e)
          Stub for MouseListener.
 void mouseReleased(java.awt.event.MouseEvent e)
          Stub for MouseListener.
 void over(java.lang.String s)
          an error occurred, stop playing
 void paint(java.awt.Graphics g)
          Paint each component, after (if needRepaintBorders) clearing stray pixels from the borders between the components.
private  void paintBorders(java.awt.Graphics g)
          Paint the borders after a resize, and set needRepaintBorders false.
private  void paintBordersHandColumn(java.awt.Graphics g, SOCHandPanel middlePanel)
          Paint the borders of one column of handpanels.
 void playerEvent(SOCGame ga, SOCPlayer pl, SOCScenarioPlayerEvent evt, boolean flagsChanged, java.lang.Object obj)
          Listener callback for per-player scenario events on the large sea board.
 void print(java.lang.String s)
          print text in the text window, followed by a new line ('\n').
 void printKeyed(java.lang.String key)
          Get and print a localized string (having no parameters) in the text window, followed by a new line ('\n').
 void printKeyed(java.lang.String key, java.lang.Object... params)
          Get and print a localized string (with parameters) in the text window, followed by a new line ('\n').
 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(boolean confirmDialogFirst)
          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.
(package private)  void setDebugFreePlacementMode(boolean setOn)
          Switch the game's Debug Paint Piece Mode on or off, as directed by the server.
(package private)  void setDebugFreePlacementPlayer(int pn)
          Set the board's 'client player' for the Debug Paint Piece Mode.
 void showChoosePlayerDialog(int count, int[] pnums, boolean allowChooseNone)
          show the SOCChoosePlayerDialog to choose a player for robbery.
 void showChooseRobClothOrResourceDialog(int vpn)
          Show the SOCPlayerInterface.ChooseRobClothOrResourceDialog to choose what to rob from a player.
 void showDiceResult(SOCPlayer cp, int roll)
          Server has just sent a dice result message.
 void showDiscardOrGainDialog(int nd, boolean isDiscard)
          Show the discard dialog or the gain-resources dialog.
 void showMonopolyDialog()
          show the Monopoly dialog box
 void showScenarioInfoDialog()
          If this game has a scenario (game option "SC"), show the scenario description, special rules, and number of victory points to win.
 void startGame()
          Game play is starting (leaving state SOCGame.NEW).
private  void textDisplaysLargerSetResizeTimer()
          For 6-player board, make the text displays larger/smaller when mouse enters/exits them.
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 updateAtClientPlayerResources()
          The client player's available resources have changed.
 void updateAtGameState()
          Update interface after game state has changed.
 void updateAtNewBoard()
          Update interface after the server sends us a new board layout.
 void updateAtOver(int[] finalScores)
          Game is over; server has sent us the revealed scores for each player.
 void updateAtPieceRemoved(SOCPlayer player, int pieceCoordinate, int pieceType)
          A player's piece has been removed from the board.
 void updateAtPiecesChanged()
          Handle updates after pieces have changed on the board.
 void updateAtPutPiece(int mesPn, int coord, int pieceType, boolean isMove, int moveToCoord)
          Handle updates after putting a piece on the board, or moving a ship that was already placed.
 void updateAtRollPrompt()
          A player is being asked to roll (or play a card) at the start of their turn.
 void updateAtSVPText(java.lang.String plName, int svp, java.lang.String desc)
          A player has been awarded Special Victory Points (SVP), so announce those details.
 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.
private  void updatePlayerLimitDisplay(boolean show, boolean isGameStart, int playerLeaving)
          Show the maximum and available number of player positions, if game parameter "PL" is less than SOCGame.maxPlayers.
 
Methods inherited from class java.awt.Frame
addNotify, 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, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, 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, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

strings

private static final SOCStringManager strings
i18n text strings


SOCPI_osName

private static final java.lang.String SOCPI_osName
System property os.name; For use by SOCPI_isPlatformWindows.

Since:
1.1.08

SOCPI_isPlatformWindows

private static final boolean SOCPI_isPlatformWindows
Are we running on the Windows platform, according to SOCPI_osName?

Since:
1.1.08

boardPanel

protected SOCBoardPanel boardPanel
the board display


boardIsScaled

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

See Also:
SOCBoardPanel.isScaled()

is6player

private boolean is6player
Is this game using the 6-player board? Checks SOCGame.maxPlayers.

Since:
1.1.08

layoutNotReadyYet

private boolean layoutNotReadyYet
For perf/display-bugs during component layout (OSX firefox), show only background color in update(Graphics) when true.

Since:
1.1.06

didGameScenarioPopupCheck

private boolean didGameScenarioPopupCheck
True if we've already shown game's scenario's descriptive text in a popup window when the client joined, or if the game has no scenario. Checked in doLayout(). Shown just once, not shown again at resetBoard(SOCGame, int, int).

Since:
2.0.00

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

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. In the 6-player layout, size expands when hovered over with mouse.

See Also:
textDisplaysLargerTemp

chatDisplay

protected SnippingTextArea chatDisplay
where chat text is displayed. In the 6-player layout, size expands when hovered over with mouse.

See Also:
textDisplaysLargerTemp

textDisplaysLargerWhen

private long textDisplaysLargerWhen
If any text area is clicked in a 6-player game, give focus to the text input box; for use with mouseClicked(MouseEvent). This is for ease-of-use because these boxes move/expand in the 6-player board just as the mouse is near them, so it's more difficult to click on the text input box.

If the user actually wants to click in the text box instead, they can click there again 1 second after the text displays are made larger.

When the text fields are un-expanded because the mouse moves away from them, that timer is reset to 0, and the next click will again give focus to the input text box.

Since:
1.1.13

textDisplaysLargerTemp

private boolean textDisplaysLargerTemp
In the 6-player layout, the text display fields (textDisplay, chatDisplay) aren't as large. When this flag is set, they've temporarily been made larger.

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask, textDisplaysLargerWhen

textDisplaysLargerTemp_needsLayout

private boolean textDisplaysLargerTemp_needsLayout
When set, must return text display field sizes to normal in doLayout() after a previous textDisplaysLargerTemp flag set.

Since:
1.1.08

textInputHasMouse

private boolean textInputHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp.

Set/cleared in mouseEntered(MouseEvent), mouseExited(MouseEvent).

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask

textDisplayHasMouse

private boolean textDisplayHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp.

Set/cleared in mouseEntered(MouseEvent), mouseExited(MouseEvent).

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask

chatDisplayHasMouse

private boolean chatDisplayHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp.

Set/cleared in mouseEntered(MouseEvent), mouseExited(MouseEvent).

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask

sbFixNeeded

private boolean sbFixNeeded
In 6-player games, text areas temporarily zoom when the mouse is over them. On windows, the scrollbars aren't considered part of the text areas, so we get a mouseExited when user is trying to scroll the text area. Workaround: Instead of looking for mouseExited, look for mouseEntered on handpanels or boardpanel.

See Also:
textDisplaysLargerTemp, sbFixBHasMouse

sbFixLHasMouse

private boolean sbFixLHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp and sbFixNeeded. Used only on platforms (windows) where the scrollbar isn't considered part of the textarea and triggers a mouseExited.

Set/cleared in mouseEntered(MouseEvent), mouseExited(MouseEvent).

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask

sbFixRHasMouse

private boolean sbFixRHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp and sbFixNeeded. Used only on platforms (windows) where the scrollbar isn't considered part of the textarea and triggers a mouseExited.

Set/cleared in mouseEntered(MouseEvent), mouseExited(MouseEvent).

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask

sbFixBHasMouse

private boolean sbFixBHasMouse
Mouse hover flags, for use on 6-player board with textDisplaysLargerTemp and sbFixNeeded. Used only on platforms (windows) where the scrollbar isn't considered part of the textarea and triggers a mouseExited.

Set/cleared in mouseEntered(MouseEvent), mouseExited(MouseEvent).

Since:
1.1.08
See Also:
SOCPlayerInterface.SOCPITextDisplaysLargerTask

buildingPanel

protected SOCBuildingPanel buildingPanel
interface for building pieces


hands

protected SOCHandPanel[] hands
the display for the players' hands. Hands start at top-left and go clockwise.

See Also:
clientHand

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 by calling setClientHand(SOCHandPanel).

See Also:
clientHandPlayerNum

clientHandPlayerNum

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


playerColors

protected java.awt.Color[] playerColors
the player colors. Indexes from 0 to SOCGame.maxPlayers - 1. Initialized in constructor.

See Also:
getPlayerColor(int, boolean)

playerColorsGhost

protected java.awt.Color[] playerColorsGhost
the player colors. Indexes from 0 to SOCGame.maxPlayers - 1. Initialized in constructor.

See Also:
getPlayerColor(int, boolean)

gameDisplay

protected SOCPlayerClient.GameAwtDisplay gameDisplay
the display that spawned us


client

protected SOCPlayerClient client

game

protected SOCGame game
the game associated with this interface


knowsGameState

private boolean knowsGameState
If true, updateAtGameState() has been called at least once, or the constructor was called with a non-zero SOCGame.getGameState(). If false, the 'known' game state (from the constructor) is 0.

Since:
2.0.00

gameIsStarting

protected boolean gameIsStarting
Flag to ensure interface is updated, when the first actual turn begins (state changes from SOCGame.START2B or SOCGame.START3B 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.


showingPlayerDiscardOrPick

private boolean showingPlayerDiscardOrPick
Is one or more SOCHandPanel (of other players) showing a "Discarding..." or "Picking resource..." message?


showingPlayerDiscardOrPick_lock

private java.lang.Object showingPlayerDiscardOrPick_lock
Synchronize access to showingPlayerDiscardOrPick and showingPlayerDiscardOrPick_task


showingPlayerDiscardOrPick_task

private SOCPlayerInterface.SOCPIDiscardOrPickMsgTask showingPlayerDiscardOrPick_task
May be null if not showingPlayerDiscardOrPick.


ncols

protected int ncols
number of columns in the text output area


npix

protected int npix
width of text output area in pixels


prevSize

private java.awt.Dimension prevSize
Size of our window from Component.getSize(), not excluding insets. Determined in doLayout(), or null.

Since:
1.1.11

needRepaintBorders

private boolean needRepaintBorders
Have we resized the board, and thus need to repaint the borders between panels? Determined in doLayout().

Since:
1.1.11

discardOrGainDialog

protected SOCDiscardOrGainResDialog discardOrGainDialog
The dialog for getting what resources the player wants to discard or gain.


choosePlayerDialog

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


monopolyDialog

protected SOCMonopolyDialog monopolyDialog
the dialog for choosing a resource to monopolize


gameStats

private SOCGameStatistics gameStats

clientListener

private final SOCPlayerInterface.ClientBridge clientListener
Constructor Detail

SOCPlayerInterface

public SOCPlayerInterface(java.lang.String title,
                          SOCPlayerClient.GameAwtDisplay gd,
                          SOCGame ga)
Create and show a new player interface. If the game options have a SOCScenario description, it will be shown now in a popup by showScenarioInfoDialog().

Parameters:
title - title for this interface - game name
gd - the player display that spawned us
ga - the game associated with this interface; must not be null
Method Detail

getClientListener

public PlayerClientListener getClientListener()
Provide access to the client listener in case this class does not directly implement it.


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. For performance and display-bug avoidance, checks layoutNotReadyYet flag.

Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paint each component, after (if needRepaintBorders) clearing stray pixels from the borders between the components.

Overrides:
paint in class java.awt.Window
Since:
1.1.11

paintBorders

private void paintBorders(java.awt.Graphics g)
Paint the borders after a resize, and set needRepaintBorders false. prevSize should be set before calling.

Parameters:
g - Graphics as passed to update()
Since:
1.1.11

paintBordersHandColumn

private final void paintBordersHandColumn(java.awt.Graphics g,
                                          SOCHandPanel middlePanel)
Paint the borders of one column of handpanels. prevSize must be set before calling.

Parameters:
g - Graphics as passed to update()
middlePanel - The middle handpanel (6-player) or the bottom (4-player) in this column
Since:
1.1.11

getClient

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

getGameDisplay

public SOCPlayerClient.GameAwtDisplay getGameDisplay()
Returns:
the game display associated with this interface
Since:
2.0.00

getGame

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

getGameStats

public SOCGameStatistics getGameStats()

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
isGhost - Do we want the "ghosted" color, not the normal color?
Returns:
the normal or "ghosted" color of a player

getPlayerHandPanel

public SOCHandPanel getPlayerHandPanel(int pn)
Parameters:
pn - the player's seat number
Returns:
a player's hand panel, or null if pn < 0
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.

See also SOCPlayerInterface.ClientBridge.simpleAction(int, int, int, int) with SOCSimpleAction.DEVCARD_BOUGHT.


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

updatePlayerLimitDisplay

private void updatePlayerLimitDisplay(boolean show,
                                      boolean isGameStart,
                                      int playerLeaving)
Show the maximum and available number of player positions, if game parameter "PL" is less than SOCGame.maxPlayers. Also, if show, and isGameStart, check for game-is-full, and hide or show "sit down" buttons if necessary. If the game has already started, and the client is playing in this game, will not show this display (it overlays the board, which is in use). It will still hide/show sit-here buttons if needed.

Parameters:
show - show the text, or clear the display (at game start)?
isGameStart - True if calling from startGame(); will be set true if gameState is SOCGame.NEW
playerLeaving - The player number if a player is leaving the game, otherwise -1.
Since:
1.1.07

clearTradeMsg

void clearTradeMsg(int pn)
If the player's trade-offer panel is showing a message (not a trade offer), clear and hide it.

Parameters:
pn - Player number, or -1 for all players
Since:
1.1.12
See Also:
SOCHandPanel.clearTradeMsg()

setDebugFreePlacementMode

void setDebugFreePlacementMode(boolean setOn)
Switch the game's Debug Paint Piece Mode on or off, as directed by the server.

Parameters:
setOn - Should the mode be turned on?
Since:
1.1.12
See Also:
setDebugFreePlacementPlayer(int)

setDebugFreePlacementPlayer

void setDebugFreePlacementPlayer(int pn)
Set the board's 'client player' for the Debug Paint Piece Mode. Returns to the true client player when setDebugPaintPieceMode(false) is called.

Parameters:
pn - Player number
Since:
1.1.12

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.
See Also:
clientIsCurrentPlayer(), isClientPlayer(SOCPlayer)

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? Assertion: If this returns true, getClientHand() will return non-null.

See Also:
getClientPlayerNumber(), isClientPlayer(SOCPlayer)

getClientPlayerNumber

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

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

showDiceResult

public void showDiceResult(SOCPlayer cp,
                           int roll)
Server has just sent a dice result message. Call this after updating game state with the roll result. Show the dice result in the game text panel and on the board.

Parameters:
cp - Current player who rolled
roll - The roll result, or 0
Since:
2.0.00

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

doLocalCommand

private boolean doLocalCommand(java.lang.String cmd)
Handle local client commands for games.

Before 2.0.00, this was SOCPlayerClient.doLocalCommand(SOCGame, String).

Parameters:
cmd - Local client command string, which starts with \
Returns:
true if a command was handled
Since:
2.0.00
See Also:
SOCPlayerClient.GameAwtDisplay.doLocalCommand(String, String)

leaveGame

public void leaveGame()
leave this game


resetBoardRequest

public void resetBoardRequest(boolean confirmDialogFirst)
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.

Before resetting a practice game, have the user confirm the reset with a dialog box. This is to prevent surprises if they click the "Restart" button at the end of a practice game, which is the same button as the "Done" button at the end of a turn.

Parameters:
confirmDialogFirst - If true, a practice game is over and the user should confirm the reset with a dialog box created and shown here. If the game is just starting, no need to confirm. If true, assumes resetBoardRequest is being called from the AWT event thread.

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.


printKeyed

public void printKeyed(java.lang.String key)
                throws java.util.MissingResourceException
Get and print a localized string (having no parameters) in the text window, followed by a new line ('\n'). Equivalent to print("* " + strings.get(key)).

Parameters:
key - Key to use for string retrieval
Throws:
java.util.MissingResourceException - if no string can be found for key; this is a RuntimeException
Since:
2.0.00

printKeyed

public void printKeyed(java.lang.String key,
                       java.lang.Object... params)
                throws java.util.MissingResourceException
Get and print a localized string (with parameters) in the text window, followed by a new line ('\n'). Equivalent to print ("* " + strings.get(key, params)).

Parameters:
key - Key to use for string retrieval
params - Objects to use with {0}, {1}, etc in the localized string by calling SOCStringManager.get(key, params...); the localized string should not contain the leading "* " or the ending \n, those are added here.
Throws:
java.util.MissingResourceException - if no string can be found for key; this is a RuntimeException
Since:
2.0.00

print

public void print(java.lang.String s)
print text in the text window, followed by a new line ('\n').

Parameters:
s - the text; you don't need to include "\n".
See Also:
chatPrint(String), printKeyed(String), printKeyed(String, Object...)

chatPrint

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

Parameters:
s - the text
See Also:
print(String)

over

public void over(java.lang.String s)
an error occurred, stop playing

Parameters:
s - an error message

began

public void began(java.util.Vector<java.lang.String> members)
start the game interface: 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. By now HandPanel has added "sit" buttons, or updatePlayerLimitDisplay has removed them if necessary.

If this game has observers, list them in the textDisplay now.

Parameters:
members - Game member names from SOCGameMembers.getMembers() (added in 1.1.12)

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. To prevent inconsistencies, call this before calling SOCGame.removePlayer(String).

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.

Call SOCGame.setGameState(int) before calling this method. Call this method before calling updateAtGameState().


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()

updateAtRollPrompt

public void updateAtRollPrompt()
A player is being asked to roll (or play a card) at the start of their turn. Update displays if needed.

If the client is the current player, calls SOCHandPanel.autoRollOrPromptPlayer().

Since:
1.1.11

updateAtClientPlayerResources

public void updateAtClientPlayerResources()
The client player's available resources have changed. Update displays if needed.

If any trade offers are currently showing, show or hide the offer Accept button depending on the updated set of available resources.

Since:
1.1.20

updateAtSVPText

public void updateAtSVPText(java.lang.String plName,
                            int svp,
                            java.lang.String desc)
A player has been awarded Special Victory Points (SVP), so announce those details. Example: "Lily gets 2 Special Victory Points for settling a new island." Only prints text, does not update SOCHandPanel's SVP or call SOCPlayer.addSpecialVPInfo(int, String).

Parameters:
plName - Player name
svp - Number of SVP awarded
desc - Description of player's action that led to SVP; example: "settling a new island"
Since:
2.0.00

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

showDiscardOrGainDialog

public void showDiscardOrGainDialog(int nd,
                                    boolean isDiscard)
Show the discard dialog or the gain-resources dialog. Used for discards, gold hexes, and the Discovery/Year of Plenty dev card.

Parameters:
nd - the number of resources to discard or gain
isDiscard - True for discard (after 7), false for gain (after gold hex)

showChoosePlayerDialog

public void showChoosePlayerDialog(int count,
                                   int[] pnums,
                                   boolean allowChooseNone)
show the SOCChoosePlayerDialog to choose a player for robbery.

Before v2.0.00, this was choosePlayer.

Parameters:
count - the number of players to choose from
pnums - the player ids of those players; length of this array may be larger than count (may be SOCGame.maxPlayers). Only the first count elements will be used. If allowChooseNone, pnums.length must be at least count + 1 to leave room for "no player".
allowChooseNone - if true, player can choose to rob no one (game scenario SC_PIRI)
See Also:
SOCPlayerClient.GameManager.choosePlayer(SOCGame, int), showChooseRobClothOrResourceDialog(int)

showChooseRobClothOrResourceDialog

public void showChooseRobClothOrResourceDialog(int vpn)
Show the SOCPlayerInterface.ChooseRobClothOrResourceDialog to choose what to rob from a player.

Parameters:
vpn - Victim player number
Since:
2.0.00
See Also:
showChoosePlayerDialog(int, int[], boolean)

showMonopolyDialog

public void showMonopolyDialog()
show the Monopoly dialog box


showScenarioInfoDialog

public void showScenarioInfoDialog()
If this game has a scenario (game option "SC"), show the scenario description, special rules, and number of victory points to win. Shown automatically when the SOCPlayerInterface is first shown.

Since:
2.0.00

updateAtNewBoard

public void updateAtNewBoard()
Update interface after the server sends us a new board layout. Call after setting game data and board data. Calls SOCBoardPanel.flushBoardLayoutAndRepaint(). Updates display of board-related counters, such as SOCBoardLarge.getCloth(). Not needed if calling resetBoard(SOCGame, int, int).

Since:
2.0.00

updateAtGameState

public void updateAtGameState()
Update interface after game state has changed. For example, if the client is current player, and state changed from PLAY to PLAY1, (Dice has been rolled, or card played), enable the player's Done and Bank buttons. Or, if the player must discard resources or pick free resources from the gold hex, calls discardOrPickTimerSet(boolean).

Please call SOCGame.setGameState(int) first.
If the game is now starting, please call in this order:

   game.setGameState(newState);
   playerInterface.startGame();
   playerInterface.updateAtGameState();


updateAtPiecesChanged

public void updateAtPiecesChanged()
Handle updates after pieces have changed on the board. For example, when scenario SOCGameOption.K_SC_PIRI converts players' ships to warships, changes the strength of a pirate fortress, etc.

Call after updating game state. This is different than updateAtPutPiece(int, int, int, boolean, int) which updates both the SOCGame and the board.

Currently, hand panels aren't updated (piece counts or VP total), only SOCBoardPanel.

Since:
2.0.00

updateAtPutPiece

public void updateAtPutPiece(int mesPn,
                             int coord,
                             int pieceType,
                             boolean isMove,
                             int moveToCoord)
Handle updates after putting a piece on the board, or moving a ship that was already placed. Place or move the piece within our SOCGame and visually on our SOCBoardPanel.

Parameters:
mesPn - The piece's player number
coord - The piece's coordinate. If isMove, the coordinate to move from.
pieceType - Piece type, like SOCPlayingPiece.CITY
isMove - If true, it's a move, not a new placement; valid only for ships.
moveToCoord - If isMove, the coordinate to move to. Otherwise ignored.
Since:
2.0.00
See Also:
updateAtPiecesChanged()

updateAtPieceRemoved

public void updateAtPieceRemoved(SOCPlayer player,
                                 int pieceCoordinate,
                                 int pieceType)
A player's piece has been removed from the board. Updates game state and refreshes the board display by calling updateAtPiecesChanged().

Currently, only ships can be removed, in game scenario _SC_PIRI. Other pieceTypes are ignored.

Parameters:
player - Player who owns the ship
pieceCoordinate - Ship's node coordinate
pieceType - The piece type identifier SOCPlayingPiece.SHIP
Since:
2.0.00

gameEvent

public void gameEvent(SOCGame ga,
                      SOCScenarioGameEvent evt,
                      java.lang.Object detail)
Listener callback for scenario events on the large sea board which affect the game or board, not a specific player. For example, a hex might be revealed from fog.

Threads: The game's treater thread handles incoming client messages and calls game methods that change state. Those same game methods will trigger the scenario events; so, the treater thread will also run this gameEvent callback. GUI code should use EventQueue.invokeLater(Runnable).

Specified by:
gameEvent in interface SOCScenarioEventListener
Parameters:
ga - Game
evt - Event code
detail - Game piece, coordinate, or other data about the event, or null, depending on evt
Since:
2.0.00
See Also:
playerEvent(SOCGame, SOCPlayer, SOCScenarioPlayerEvent, boolean, Object)

playerEvent

public void playerEvent(SOCGame ga,
                        SOCPlayer pl,
                        SOCScenarioPlayerEvent evt,
                        boolean flagsChanged,
                        java.lang.Object obj)
Listener callback for per-player scenario events on the large sea board. For example, there might be an SVP awarded for settlements.

Specified by:
playerEvent in interface SOCScenarioEventListener
Parameters:
ga - Game
pl - Player
evt - Event code
flagsChanged - True if this event changed SOCPlayer.getScenarioPlayerEvents(), SOCPlayer.getSpecialVP(), or another flag documented for evt in SOCScenarioPlayerEvent
obj - Object related to the event, or null; documented for evt in SOCScenarioPlayerEvent. Example: The SOCVillage for SOCScenarioPlayerEvent.CLOTH_TRADE_ESTABLISHED_VILLAGE.
Since:
2.0.00
See Also:
gameEvent(SOCGame, SOCScenarioGameEvent, Object)

discardOrPickTimerSet

private void discardOrPickTimerSet(boolean isDiscard)
Gamestate just became SOCGame.WAITING_FOR_DISCARDS or SOCGame.WAITING_FOR_PICK_GOLD_RESOURCE. Set up a timer to wait 1 second before showing "Discarding..." or "Picking Resources..." balloons in players' handpanels. Uses SOCPlayerInterface.SOCPIDiscardOrPickMsgTask.

Parameters:
isDiscard - True for discard, false for picking gold-hex resources

discardOrPickTimerClear

private void discardOrPickTimerClear()
Cancel any "discarding..." or "picking resources..." timer, and clear the message if showing.


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. Most GUI panels are destroyed and re-created. Player chat text is kept.

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()
Arrange the custom layout. If a player sits down in a 6-player game, will need to Container.invalidate() and call this again, because SOCHandPanel sizes will change. Also, on first call, resets mouse cursor to normal, in case it was WAIT_CURSOR. On first call, if the game options have a SOCScenario with any long description, it will be shown in a popup via showScenarioInfoDialog().

Overrides:
doLayout in class java.awt.Container

textDisplaysLargerSetResizeTimer

private void textDisplaysLargerSetResizeTimer()
For 6-player board, make the text displays larger/smaller when mouse enters/exits them. Timer will set textDisplaysLargerTemp_needsLayout, invalidate(), doLayout(). Wait 200 ms first, to avoid flicker in case of several related mouseExited(MouseEvent)/mouseEntered(MouseEvent) events (such as moving mouse from textDisplay to chatDisplay).

Since:
1.1.08

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Track TextField mouse cursor entry on 6-player board (MouseListener). Listener is not added unless is6player. For use by textDisplay, chatDisplay, textInput. Calls textDisplaysLargerSetResizeTimer().

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Since:
1.1.08

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Track TextField mouse cursor exit on 6-player board (MouseListener). Same details as mouseEntered(MouseEvent).

Specified by:
mouseExited in interface java.awt.event.MouseListener
Since:
1.1.08

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
If any text area is clicked in a 6-player game, give focus to the text input box for ease-of-use. For details see the textDisplaysLargerWhen javadoc.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Since:
1.1.13

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Stub for MouseListener.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Since:
1.1.08

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Stub for MouseListener.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Since:
1.1.08

isClientPlayer

protected boolean isClientPlayer(SOCPlayer p)