soc.client
Class SOCHandPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by soc.client.SOCHandPanel
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

public class SOCHandPanel
extends java.awt.Panel
implements java.awt.event.ActionListener, java.awt.event.MouseListener

This panel displays a player's information. If the player is us, then more information is displayed than in another player's hand panel.

To update most of the values shown in the handpanel, call updateValue(PlayerClientListener.UpdateType) after receiving a SOCPlayerElement message or after something else changes the game state.

Custom layout: see doLayout(). To set this panel's position or size, please use setBounds(int, int, int, int), because it is overridden to also update getBlankStandIn().

See Also:
Serialized Form

Nested Class Summary
protected  class SOCHandPanel.HandPanelAutoRollTask
          Used for countdown before auto-roll of the current player.
protected static class SOCHandPanel.ResourceTradeMenuItem
          Menu item for right-click on resource square to trade with bank/port.
(package private) static class SOCHandPanel.ResourceTradePopupMenu
          Menu for right-click on resource square to trade with bank/port.
(package private) static class SOCHandPanel.ResourceTradeTypeMenu
          Menu for right-click on resource square to trade one resource type with bank/port.
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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 static java.lang.String AUTOROLL_COUNTDOWN
           
static int AUTOROLL_TIME
          Auto-roll timer countdown, 5 seconds unless changed at program start.
protected  java.util.TimerTask autoRollTimerTask
           
protected static java.lang.String BANK
           
private static java.lang.String BANK_UNDO
           
protected  java.awt.Button bankBut
          Trade resources with the bank or port
private  SOCResourceSet bankGet
          Bank or port trade's give/get resource info; used for Undo.
private  SOCResourceSet bankGive
          Bank or port trade's give/get resource info; used for Undo.
protected  java.awt.Button bankUndoBut
          Undo previous trade with the bank or port
private  ColorSquare blankStandIn
          Blank area which is normally hidden, except during addPlayer when handpanel is hidden.
private  boolean canCancelInvItemPlay
          Flag for playCardBut in state SOCGame.PLACING_INV_ITEM.
private static java.lang.String CANCEL
          "Cancel" button label text, used temporarily in some game states
private static java.lang.String CARD
          " Play Card " button label text for playCardBut
protected  javax.swing.JLabel cityLab
           
protected  ColorSquare citySq
           
protected  java.awt.Label clayLab
           
protected  ColorSquare claySq
           
protected static java.lang.String CLEAR
           
protected  java.awt.Button clearOfferBut
          Clear the current trade offer at client and server
protected  SOCPlayerClient client
           
protected  javax.swing.JLabel clothLab
           
protected  ColorSquare clothSq
          Cloth count, for scenario _SC_CLVI; null otherwise.
protected static java.awt.Color COLOR_FOREGROUND
          Panel text color, and player name color when not current player
private  java.awt.Label createColorSqRetLbl
          Color square label created by most recent call to createAndAddResourceColorSquare(Color, String).
private  ColorSquare createColorSqRetSq
          Color square created by most recent call to createAndAddResourceColorSquare(Color, String).
private static java.lang.String DEVCARD_NEW
          Dev card list prefix "*NEW* " - includes trailing space
protected  java.awt.Label developmentLab
           
protected  ColorSquare developmentSq
          Development card count
private static boolean didSwingTooltipDefaults
          If true, our constructor has set the Swing tooltip default font/foreground/background.
protected static java.lang.String DONE
           
protected static java.lang.String DONE_RESTART
          Text of Done button at end of game becomes Restart button.
protected  java.awt.Button doneBut
          "Done" with turn during play; also "Restart" for board reset at end of game
protected  boolean doneButIsRestart
          True when doneBut's label is Restart (DONE_RESTART)
protected  SOCFaceButton faceImg
          Face icon; can right-click/triple-click for face chooser popup.
protected  SOCGame game
           
protected static java.lang.String GET
           
protected  java.awt.Label getLab
           
protected static java.lang.String GIVE
           
protected  java.awt.Label giveLab
           
protected  boolean inPlay
          Do we have any seated player? Set by addPlayer(String), cleared by removePlayer().
protected  boolean interactive
          When this flag is true, the panel is interactive.
protected  java.awt.List inventory
          Player's development card/inventory item names, from inventoryItems; updated frequently by updateDevCards(boolean)
private  java.util.ArrayList<SOCInventoryItem> inventoryItems
          Player's development cards/inventory items, in same order as inventory; updated frequently by updateDevCards(boolean)
protected  javax.swing.JLabel knightsLab
          Label for knightsSq.
protected  ColorSquare knightsSq
          Soldier/Knight count
static int LARGESTARMY
          Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement.
protected  javax.swing.JLabel larmyLab
          Largest Army label, usually invisible; placed to left of lroadLab
protected static java.lang.String LOCKSEAT
           
private static java.lang.String LOCKSEATTIP
           
static int LONGESTROAD
          Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement.
protected  javax.swing.JLabel lroadLab
          Longest Road label, usually invisible; placed to right of larmyLab
static int NUMDEVCARDS
          Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement.
static int NUMRESOURCES
          Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement.
protected  TradeOfferPanel offer
          Display other players' trade offers and related messages.
protected  java.awt.Button offerBut
          "Offer" button for player trading: send offer to server
protected  AWTToolTip offerButTip
          Hint for "Offer" button; non-null only if interactive and if playerTradingDisabled == false.
private static java.lang.String OFFERBUTTIP_DIS
           
private static java.lang.String OFFERBUTTIP_ENA
           
private  boolean offerCounterHidesFace
          If true, the handpanel isn't tall enough, so when the offer message panel is showing something, we must hide other controls.
private  boolean offerCounterHidingFace
          When handpanel isn't tall enough, are we currently in the situation described at offerHidesControls or offerCounterHidesFace?
private  boolean offerHidesControls
          If true, the handpanel isn't tall enough, so when the offer message panel is showing something, we must hide other controls.
private  boolean offerHidingControls
          When handpanel isn't tall enough, are we currently in the situation described at offerHidesControls or offerCounterHidesFace?
private  boolean offerIsDiscardOrPickMessage
          Board-reset voting: If true, offer is holding a discard message (TRADEMSG_DISCARD) or a gold hex pick-resources message (TRADEMSG_PICKING).
protected  boolean offerIsMessageWasTrade
          Board-reset voting: If true, offer was holding an active trade offer before offerIsResetMessage or offerIsDiscardOrPickMessage was set.
protected  boolean offerIsResetMessage
          Board-reset voting: If true, offer is holding a message related to a board-reset vote.
protected  java.awt.Label oreLab
           
protected  ColorSquare oreSq
           
protected  java.awt.Button playCardBut
          Play Card button for inventory.
protected  SOCPlayer player
           
protected  SOCPlayerInterface playerInterface
           
protected  boolean playerIsClient
          Does this panel represent our client's own hand? If true, implies interactive.
protected  boolean playerIsCurrent
          Is this panel's player the game's current player? Used for hilight - set in updateAtTurn()
private  int playerNumber
          Our player number.
protected  ColorSquare[] playerSend
          Checkboxes to send to the other 3 or 5 players.
private  boolean[] playerSendForPrevTrade
          The playerSend checkboxes selected during the previous trade offer; if no previous offer, all are selected.
protected  int[] playerSendMap
          Three player numbers to send trade offers to.
protected  boolean playerTradingDisabled
          Game option NT: If true, only bank trading is allowed, trading between players is disabled.
protected  java.awt.Label pname
           
protected  java.awt.Color pnameActiveBG
          Player name background color when current player (foreground does not change)
protected static java.lang.String QUIT
           
protected  java.awt.Button quitBut
           
protected  java.awt.Label resourceLab
           
private static java.lang.String RESOURCES
           
private static java.lang.String RESOURCES_TOTAL
           
protected  ColorSquare resourceSq
          Resource card count
protected  ColorSquare resourceSqDivLine
           
protected  int[] resourceTradeCost
          For right-click resource to trade - If playerIsClient, track cost of bank/port trade per resource.
protected  SOCHandPanel.ResourceTradeTypeMenu[] resourceTradeMenu
          For right-click resource to trade - If playerIsClient, popup menus to bank/port trade resources.
protected  javax.swing.JLabel roadLab
           
protected  ColorSquare roadSq
           
protected static java.lang.String ROBOT
           
protected  java.awt.Button robotBut
           
private static java.lang.String ROBOTLOCKBUT_L
           
private static java.lang.String ROBOTLOCKBUT_M
           
private static java.lang.String ROBOTLOCKBUT_U
           
protected  AWTToolTip robotLockButTip
          Hint for "Lock/Unlock" button (sittingRobotLockBut; non-null only if a robot is sitting there.
private static java.lang.String ROBOTLOCKBUTTIP_L
           
private static java.lang.String ROBOTLOCKBUTTIP_L_OLD
           
private static java.lang.String ROBOTLOCKBUTTIP_M
           
private static java.lang.String ROBOTLOCKBUTTIP_U
           
private static java.lang.String ROBOTLOCKBUTTIP_U_OLD
           
protected static java.lang.String ROLL
           
protected static java.lang.String ROLL_OR_PLAY_CARD
           
protected  java.awt.Button rollBut
           
protected  java.awt.Label rollPromptCountdownLab
          displays auto-roll countdown, or prompts to roll/play card.
protected  boolean rollPromptInUse
           
private static java.lang.String SEAT_LOCKED
           
protected static java.lang.String SEND
           
protected  javax.swing.JLabel settlementLab
           
protected  ColorSquare settlementSq
           
protected  java.awt.Label sheepLab
           
protected  ColorSquare sheepSq
           
protected  javax.swing.JLabel shipLab
           
protected  ColorSquare shipSq
          shipSq = the number of ships remaining, or null if not SOCGame.hasSeaBoard.
protected static java.lang.String SIT
           
protected  java.awt.Button sitBut
          When player has joined but not sat, the "Sit Here" button.
protected  boolean sitButIsLock
          When true, the game is still forming, player has chosen a seat; "Sit Here" button is labeled as "Lock" or "Unlock".
private  AWTToolTip sitButTip
          Hint for "Lock/Unlock" button before game starts (sitBut; non-null only if sitButIsLock.
protected static java.lang.String SITLOCKED
          Before game starts, use pname to show if a seat is no-robots-allowed.
protected  java.awt.Button sittingRobotLockBut
          Seat lock/unlock shown in robot handpanels during game play, to prevent/allow humans to join and take over a robot's seat.
static int SPECIALVICTORYPOINTS
          Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement.
protected  SquaresPanel sqPanel
          Trade offer resource squares; visible only for client's own player
protected static java.lang.String START
           
protected  java.awt.Button startBut
           
private static SOCStringManager strings
          i18n text strings.
private  java.awt.Label svpLab
          Label for Special Victory Points.
private  ColorSquare svpSq
          Special Victory Points, if > 0.
protected static java.lang.String TAKEOVER
           
protected  java.awt.Button takeOverBut
           
private static java.lang.String TRADEMSG_DISCARD
          Show that a non-client player is discarding resources after 7 is rolled.
private static java.lang.String TRADEMSG_PICKING
          Show that a non-client player is picking resources for the gold hex.
protected static java.lang.String UNLOCKSEAT
           
private static java.lang.String UNLOCKSEATTIP
           
static int VICTORYPOINTS
          Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement.
protected  java.awt.Label vpLab
           
protected  ColorSquare vpSq
           
protected  java.awt.Label wheatLab
           
protected  ColorSquare wheatSq
           
static int WIDTH_MIN
          Minimum desired width, in pixels
private  javax.swing.JLabel wonderLab
          Wonder Level label, for scenario _SC_WOND; null otherwise.
protected  java.awt.Label woodLab
           
protected  ColorSquare woodSq
           
protected static int[] zero
          Array of five zeroes, one per resource type; for sqPanel.
 
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
SOCHandPanel(SOCPlayerInterface pi, SOCPlayer pl)
          make a new hand panel
SOCHandPanel(SOCPlayerInterface pi, SOCPlayer pl, boolean in)
          make a new hand panel
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          handle interaction
 void addPlayer(java.lang.String name)
          Add a player (human or robot) at this currently-vacant seat position.
 void addRobotButton()
          DOCUMENT ME!
 void addSitButton(boolean clientHasSatAlready)
          Add the "Sit Here" button.
 void addSittingRobotLockBut()
          Add the "lock" button for when a robot is currently playing in this position.
 void addTakeOverBut()
          DOCUMENT ME!
 void autoRollOrPromptPlayer()
          If the player (client) has no playable cards, begin auto-roll countdown, Otherwise, prompt them to roll or pick a card.
protected  void autoRollSetupTimer()
          Player is client, is current, and has no playable cards, so begin auto-roll countdown.
 void changeFace(int id)
          Change the face image
 void clearDiscardOrPickMsg()
          Clear the "discarding..." or "picking resources..." message in the trade panel.
 void clearOffer(boolean updateSendCheckboxes)
          Clear the current offer.
 void clearTradeMsg()
          If the trade-offer panel is showing a message (not a trade offer), clear and hide it.
 void clickPlayCardButton()
          Handle a click on the "play card" button, or double-click on an item in the inventory/list of cards held.
private  void clickPlayInventorySpecialItem(SOCInventoryItem item)
          Handle a click on a special inventory item (not a SOCDevCard).
private  void clickRobotSeatLockButton(SOCGame.SeatLockState current)
          During game play, handle a click on a sitting robot's Lock/Unlock/Mark button, ask the server to advance to the next seat lock state.
 void clickRollButton()
          Handle a click on the roll button.
private  void createAndAddResourceColorSquare(java.awt.Color rc, java.lang.String rtxtkey)
          Create a ColorSquare and its Label, with the given text key, and add them to the layout.
private  void createSendBankTradeRequest(SOCGame game, int[] give, int[] get)
          Create and send a bank/port trade request.
protected  void creation(SOCPlayerInterface pi, SOCPlayer pl, boolean in)
          Stuff to do when a SOCHandPanel is created.
 void destroy()
          Remove elements to clean up this panel.
 void disableBankUndoButton()
          Disable the bank/port trade undo button.
 void doLayout()
          Custom layout for player hand panel.
 ColorSquare getBlankStandIn()
          For SOCPlayerInterface's use, to set its size and position
 SOCPlayerClient getClient()
           
 SOCGame getGame()
           
 SOCPlayer getPlayer()
           
 SOCPlayerInterface getPlayerInterface()
           
private  void hideTradeMsgShowOthers(boolean hideTradeMsg)
          If handpanel isn't tall enough, when the offer message panel is showing, we must hide other controls.
 boolean isClientAndCurrentlyCanRoll()
          Is this panel showing the client's player, and is that player the game's current player, and are they able to roll the dice right now?
 boolean isClientAndCurrentPlayer()
          Is this panel showing the client's player, and is that player the game's current player?
 boolean isClientPlayer()
          Is this panel showing the client's player?
 void mouseClicked(java.awt.event.MouseEvent e)
          Handle clicks on svpSq or svpLab to get more info.
 void mouseEntered(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void mouseExited(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void mousePressed(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void mouseReleased(java.awt.event.MouseEvent e)
          required stub for MouseListener
 void offerCounterOfferVisibleChanged(boolean counterVisible)
          Callback from TradeOfferPanel.
protected  void pnameCalcColors()
          During this player's first turn, calculate the player name label's background color for current player.
 void rejectOfferAtClient()
          Client is rejecting the current offer from another player.
 void rejectOfferShowNonClient()
          Show that this player (who isn't the client) has rejected another player's offer.
 void removePlayer()
          remove this player.
 void removeRobotBut()
          DOCUMENT ME!
 void removeSitBut()
          Remove the sit-here / lockout-robot button.
 void removeSitLockoutBut()
          Remove the sit-here/lockout-robot button, only if its label is currently "lockout".
 void removeSittingRobotLockBut()
          Remove the "lock" button seen when a robot is currently playing in this position.
 void removeStartBut()
          Internal mechanism to remove start button (if visible) and add VP label.
 void removeTakeOverBut()
          DOCUMENT ME!
 void renameSitButLock()
          If game is still forming (state NEW), and player has just chosen a seat, can lock empty seats for a game with fewer players/robots.
 void resetBoardSetMessage(java.lang.String message)
          Show or hide a message related to board-reset voting.
 void setBounds(int x, int y, int width, int height)
          Overriden to also update getBlankStandIn() bounds.
(package private)  void setCanCancelInvItemPlay(boolean canCancel)
          This player is playing or placing a special SOCInventoryItem, such as a gift trade port in scenario _SC_FTRI.
 boolean setDiscardOrPickMsg(boolean isDiscard)
          Show the "discarding..." or "picking resources..." message in the trade panel.
protected  void setLArmy(boolean haveIt)
          turn the "largest army" label on or off
protected  void setLRoad(boolean haveIt)
          Turn the "longest road" label on or off.
protected  void setRollPrompt(java.lang.String prompt, boolean cancelTimer)
          Set or clear the roll prompt / auto-roll countdown display.
 void sqPanelZerosChange(boolean notAllZero)
          If trade offer is set/cleared, enable/disable buttons accordingly.
private  void tradeSetMessage(java.lang.String message)
          Show or hide a message in the trade-panel.
(package private)  void updateAtOurGameState()
          Client is current player; state changed.
 void updateAtTurn()
          Handpanel interface updates at start of each turn (not just our turn).
private  void updateButtonsAtAdd()
          Enable,disable the proper buttons when the client (player) is added to a game.
 void updateCurrentOffer(boolean resourcesOnly)
          Display or update this player's trade offer, or hide if none.
 void updateDevCards(boolean addedPlayable)
          Update the displayed list of player's development cards and other inventory items, and enable or disable the "Play Card" button.
 void updatePickGoldHexResources()
          This player must pick this many gold hex resources, or no longer needs to pick them.
 void updateResourcesVP()
          Re-read player's resource info and victory points, update the display and resource trade costs and resourceTradeMenu text.
 void updateResourceTradeCosts(boolean doInit)
          If playerIsClient, update cost of bank/port trade per resource.
private  void updateRollDoneBankButtons()
          Client is current player; enable or disable buttons according to game state: rollBut, doneBut, bankBut.
 void updateSeatLockButton()
          update the seat lock button so that it allows a player to lock an unlocked seat and vice versa.
 void updateTakeOverButton()
          update the takeover button so that it only allows takover when it's not the robot's turn
 void updateValue(PlayerClientListener.UpdateType utype)
          update the value of a player element.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WIDTH_MIN

public static final int WIDTH_MIN
Minimum desired width, in pixels

See Also:
Constant Field Values

NUMRESOURCES

public static final int NUMRESOURCES
Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement. All these item numbers are negative, so they won't conflict with any SOCPlayerElement element type.

NUMDEVCARDS won't appear in the client's handpanel, only in other players'.

See Also:
Constant Field Values

NUMDEVCARDS

public static final int NUMDEVCARDS
Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement. All these item numbers are negative, so they won't conflict with any SOCPlayerElement element type.

NUMDEVCARDS won't appear in the client's handpanel, only in other players'.

See Also:
Constant Field Values

VICTORYPOINTS

public static final int VICTORYPOINTS
Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement. All these item numbers are negative, so they won't conflict with any SOCPlayerElement element type.

NUMDEVCARDS won't appear in the client's handpanel, only in other players'.

See Also:
Constant Field Values

LONGESTROAD

public static final int LONGESTROAD
Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement. All these item numbers are negative, so they won't conflict with any SOCPlayerElement element type.

NUMDEVCARDS won't appear in the client's handpanel, only in other players'.

See Also:
Constant Field Values

LARGESTARMY

public static final int LARGESTARMY
Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement. All these item numbers are negative, so they won't conflict with any SOCPlayerElement element type.

NUMDEVCARDS won't appear in the client's handpanel, only in other players'.

See Also:
Constant Field Values

SPECIALVICTORYPOINTS

public static final int SPECIALVICTORYPOINTS
Items to update via updateValue(PlayerClientListener.UpdateType); for items not appearing in SOCPlayerElement. All these item numbers are negative, so they won't conflict with any SOCPlayerElement element type.

NUMDEVCARDS won't appear in the client's handpanel, only in other players'.

See Also:
Constant Field Values

AUTOROLL_TIME

public static int AUTOROLL_TIME
Auto-roll timer countdown, 5 seconds unless changed at program start.


zero

protected static final int[] zero
Array of five zeroes, one per resource type; for sqPanel.


strings

private static final SOCStringManager strings
i18n text strings.

Since:
2.0.00

SITLOCKED

protected static final java.lang.String SITLOCKED
Before game starts, use pname to show if a seat is no-robots-allowed.


SIT

protected static final java.lang.String SIT

START

protected static final java.lang.String START

ROBOT

protected static final java.lang.String ROBOT

TAKEOVER

protected static final java.lang.String TAKEOVER

SEAT_LOCKED

private static final java.lang.String SEAT_LOCKED

LOCKSEAT

protected static final java.lang.String LOCKSEAT

UNLOCKSEAT

protected static final java.lang.String UNLOCKSEAT

LOCKSEATTIP

private static final java.lang.String LOCKSEATTIP

UNLOCKSEATTIP

private static final java.lang.String UNLOCKSEATTIP

ROLL

protected static final java.lang.String ROLL

QUIT

protected static final java.lang.String QUIT

DONE

protected static final java.lang.String DONE

DONE_RESTART

protected static final java.lang.String DONE_RESTART
Text of Done button at end of game becomes Restart button. If you set this, set doneButIsRestart.


CLEAR

protected static final java.lang.String CLEAR

SEND

protected static final java.lang.String SEND

BANK

protected static final java.lang.String BANK

BANK_UNDO

private static final java.lang.String BANK_UNDO

CARD

private static final java.lang.String CARD
" Play Card " button label text for playCardBut


CANCEL

private static final java.lang.String CANCEL
"Cancel" button label text, used temporarily in some game states


GIVE

protected static final java.lang.String GIVE

GET

protected static final java.lang.String GET

DEVCARD_NEW

private static final java.lang.String DEVCARD_NEW
Dev card list prefix "*NEW* " - includes trailing space


RESOURCES

private static final java.lang.String RESOURCES

RESOURCES_TOTAL

private static final java.lang.String RESOURCES_TOTAL

AUTOROLL_COUNTDOWN

protected static final java.lang.String AUTOROLL_COUNTDOWN

ROLL_OR_PLAY_CARD

protected static final java.lang.String ROLL_OR_PLAY_CARD

OFFERBUTTIP_ENA

private static final java.lang.String OFFERBUTTIP_ENA

OFFERBUTTIP_DIS

private static final java.lang.String OFFERBUTTIP_DIS

ROBOTLOCKBUT_U

private static final java.lang.String ROBOTLOCKBUT_U

ROBOTLOCKBUT_L

private static final java.lang.String ROBOTLOCKBUT_L

ROBOTLOCKBUT_M

private static final java.lang.String ROBOTLOCKBUT_M

ROBOTLOCKBUTTIP_L

private static final java.lang.String ROBOTLOCKBUTTIP_L

ROBOTLOCKBUTTIP_U

private static final java.lang.String ROBOTLOCKBUTTIP_U

ROBOTLOCKBUTTIP_M

private static final java.lang.String ROBOTLOCKBUTTIP_M

ROBOTLOCKBUTTIP_L_OLD

private static final java.lang.String ROBOTLOCKBUTTIP_L_OLD

ROBOTLOCKBUTTIP_U_OLD

private static final java.lang.String ROBOTLOCKBUTTIP_U_OLD

TRADEMSG_DISCARD

private static final java.lang.String TRADEMSG_DISCARD
Show that a non-client player is discarding resources after 7 is rolled. Call setDiscardOrPickMsg(boolean) to show. Same methods are used by discard and by TRADEMSG_PICKING.

Since:
1.1.00

TRADEMSG_PICKING

private static final java.lang.String TRADEMSG_PICKING
Show that a non-client player is picking resources for the gold hex. Uses same variables and methods as TRADEMSG_DISCARD: offerIsDiscardOrPickMessage, setDiscardOrPickMsg(boolean), etc.

Since:
2.0.00

COLOR_FOREGROUND

protected static final java.awt.Color COLOR_FOREGROUND
Panel text color, and player name color when not current player


didSwingTooltipDefaults

private static boolean didSwingTooltipDefaults
If true, our constructor has set the Swing tooltip default font/foreground/background. Currently SOCHandPanel is the only JSettlers class using Swing tooltips.

Since:
2.0.00

pnameActiveBG

protected java.awt.Color pnameActiveBG
Player name background color when current player (foreground does not change)


blankStandIn

private ColorSquare blankStandIn
Blank area which is normally hidden, except during addPlayer when handpanel is hidden. This prevents a big black area on the display (which looks like a crash). For perf/display-bugs during component layout (OSX firefox). Added to pi's layout by SOCPlayerInterface.initInterfaceElements(boolean).

Since:
1.1.06

sitBut

protected java.awt.Button sitBut
When player has joined but not sat, the "Sit Here" button. After they sit down, this button is used for the anti-robot "Lock" button. (LOCKSEAT / UNLOCKSEAT, when sitButIsLock true.) Disappears when the game begins.

See Also:
renameSitButLock(), sittingRobotLockBut

sitButTip

private AWTToolTip sitButTip
Hint for "Lock/Unlock" button before game starts (sitBut; non-null only if sitButIsLock.

Since:
1.1.12
See Also:
LOCKSEATTIP, UNLOCKSEATTIP

robotBut

protected java.awt.Button robotBut

startBut

protected java.awt.Button startBut

takeOverBut

protected java.awt.Button takeOverBut

sittingRobotLockBut

protected java.awt.Button sittingRobotLockBut
Seat lock/unlock shown in robot handpanels during game play, to prevent/allow humans to join and take over a robot's seat. Used during different game states than sitBut.

Labels are ROBOTLOCKBUT_U, ROBOTLOCKBUT_L, ROBOTLOCKBUT_M. Tooltip is robotLockButTip. Click method is clickRobotSeatLockButton(soc.game.SOCGame.SeatLockState).

See Also:
sitBut

sitButIsLock

protected boolean sitButIsLock
When true, the game is still forming, player has chosen a seat; "Sit Here" button is labeled as "Lock" or "Unlock". Humans can use this to lock robots out of that seat, to start a game with fewer players and some vacant seats.

Set by renameSitButLock(), cleared elsewhere. This affects sitBut and not sittingRobotLockBut.

See Also:
addPlayer(String), updateSeatLockButton()

faceImg

protected SOCFaceButton faceImg
Face icon; can right-click/triple-click for face chooser popup.

Since:
1.1.00

pname

protected java.awt.Label pname

vpLab

protected java.awt.Label vpLab

vpSq

protected ColorSquare vpSq

svpLab

private java.awt.Label svpLab
Label for Special Victory Points. Hidden if SOCPlayer.getSpecialVP() is 0. Null unless SOCGame.hasSeaBoard.

Since:
2.0.00

svpSq

private ColorSquare svpSq
Special Victory Points, if > 0. Hidden if 0. Null unless SOCGame.hasSeaBoard.

Since:
2.0.00

larmyLab

protected javax.swing.JLabel larmyLab
Largest Army label, usually invisible; placed to left of lroadLab


lroadLab

protected javax.swing.JLabel lroadLab
Longest Road label, usually invisible; placed to right of larmyLab


claySq

protected ColorSquare claySq

oreSq

protected ColorSquare oreSq

sheepSq

protected ColorSquare sheepSq

wheatSq

protected ColorSquare wheatSq

woodSq

protected ColorSquare woodSq

resourceSqDivLine

protected ColorSquare resourceSqDivLine

clayLab

protected java.awt.Label clayLab

oreLab

protected java.awt.Label oreLab

sheepLab

protected java.awt.Label sheepLab

wheatLab

protected java.awt.Label wheatLab

woodLab

protected java.awt.Label woodLab

resourceTradeCost

protected int[] resourceTradeCost
For right-click resource to trade - If playerIsClient, track cost of bank/port trade per resource. Index 0 unused; index 1 is SOCResourceConstants.CLAY, etc. Highest index is 5. Null, unless playerIsClient and addPlayer has been called.


resourceTradeMenu

protected SOCHandPanel.ResourceTradeTypeMenu[] resourceTradeMenu
For right-click resource to trade - If playerIsClient, popup menus to bank/port trade resources. Index 0 unused; index 1 is SOCResourceConstants.CLAY, etc. Highest index is 5. Null, unless playerIsClient and addPlayer has been called.


settlementSq

protected ColorSquare settlementSq

citySq

protected ColorSquare citySq

roadSq

protected ColorSquare roadSq

shipSq

protected ColorSquare shipSq
shipSq = the number of ships remaining, or null if not SOCGame.hasSeaBoard. @since 2.0.00


settlementLab

protected javax.swing.JLabel settlementLab

cityLab

protected javax.swing.JLabel cityLab

roadLab

protected javax.swing.JLabel roadLab

shipLab

protected javax.swing.JLabel shipLab

resourceSq

protected ColorSquare resourceSq
Resource card count


resourceLab

protected java.awt.Label resourceLab

developmentSq

protected ColorSquare developmentSq
Development card count


developmentLab

protected java.awt.Label developmentLab

knightsSq

protected ColorSquare knightsSq
Soldier/Knight count


knightsLab

protected javax.swing.JLabel knightsLab
Label for knightsSq. This and related labels (settlements, cities, ...) are transparent-background JLabels to avoid z-order overlap problems between the labels' padding and the count squares next to them (seen during v2.0.00 development).


inventory

protected java.awt.List inventory
Player's development card/inventory item names, from inventoryItems; updated frequently by updateDevCards(boolean)


inventoryItems

private java.util.ArrayList<SOCInventoryItem> inventoryItems
Player's development cards/inventory items, in same order as inventory; updated frequently by updateDevCards(boolean)


playCardBut

protected java.awt.Button playCardBut
Play Card button for inventory.

v2.0.00+: In state SOCGame.PLACING_INV_ITEM only, this button's label becomes CANCEL, and inventory is disabled, while the player places an item on the board. They can hit Cancel to return the item to their inventory instead. In any other state, label text is CARD. Updated in updateRollDoneBankButtons() which checks canCancelInvItemPlay.


canCancelInvItemPlay

private boolean canCancelInvItemPlay
Flag for playCardBut in state SOCGame.PLACING_INV_ITEM. Checked in updateRollDoneBankButtons(). For details, see setCanCancelInvItemPlay(boolean).


sqPanel

protected SquaresPanel sqPanel
Trade offer resource squares; visible only for client's own player


clothSq

protected ColorSquare clothSq
Cloth count, for scenario _SC_CLVI; null otherwise. Appears in same area as wonderLab.

Since:
2.0.00

clothLab

protected javax.swing.JLabel clothLab

wonderLab

private javax.swing.JLabel wonderLab
Wonder Level label, for scenario _SC_WOND; null otherwise. Blank ("") if player has no current wonder level. Appears in same areas as clothLab and clothSq.

Since:
2.0.00

playerTradingDisabled

protected boolean playerTradingDisabled
Game option NT: If true, only bank trading is allowed, trading between players is disabled.

Since:
1.1.07

giveLab

protected java.awt.Label giveLab

getLab

protected java.awt.Label getLab

offerBut

protected java.awt.Button offerBut
"Offer" button for player trading: send offer to server


offerButTip

protected AWTToolTip offerButTip
Hint for "Offer" button; non-null only if interactive and if playerTradingDisabled == false.

See Also:
OFFERBUTTIP_DIS, OFFERBUTTIP_ENA, interactive

robotLockButTip

protected AWTToolTip robotLockButTip
Hint for "Lock/Unlock" button (sittingRobotLockBut; non-null only if a robot is sitting there.

Since:
1.1.12
See Also:
ROBOTLOCKBUTTIP_L, ROBOTLOCKBUTTIP_U, ROBOTLOCKBUTTIP_M

clearOfferBut

protected java.awt.Button clearOfferBut
Clear the current trade offer at client and server


bankBut

protected java.awt.Button bankBut
Trade resources with the bank or port


bankGive

private SOCResourceSet bankGive
Bank or port trade's give/get resource info; used for Undo.

Since:
1.1.13

bankGet

private SOCResourceSet bankGet
Bank or port trade's give/get resource info; used for Undo.

Since:
1.1.13

bankUndoBut

protected java.awt.Button bankUndoBut
Undo previous trade with the bank or port

Since:
1.1.13

playerSend

protected ColorSquare[] playerSend
Checkboxes to send to the other 3 or 5 players. Enabled/disabled at removeStartBut(). Updated at start of each turn in clearOffer(boolean).

This is null if playerTradingDisabled.

See Also:
playerSendMap, playerSendForPrevTrade

playerSendForPrevTrade

private boolean[] playerSendForPrevTrade
The playerSend checkboxes selected during the previous trade offer; if no previous offer, all are selected.

This is null if playerTradingDisabled, because playerSend is null.

Since:
1.1.13

rollPromptCountdownLab

protected java.awt.Label rollPromptCountdownLab
displays auto-roll countdown, or prompts to roll/play card.

See Also:
setRollPrompt(String, boolean)

rollPromptInUse

protected boolean rollPromptInUse

autoRollTimerTask

protected java.util.TimerTask autoRollTimerTask

rollBut

protected java.awt.Button rollBut

doneBut

protected java.awt.Button doneBut
"Done" with turn during play; also "Restart" for board reset at end of game


doneButIsRestart

protected boolean doneButIsRestart
True when doneBut's label is Restart (DONE_RESTART)


quitBut

protected java.awt.Button quitBut

playerInterface

protected SOCPlayerInterface playerInterface

client

protected SOCPlayerClient client

game

protected SOCGame game

player

protected SOCPlayer player

playerNumber

private int playerNumber
Our player number. Set in creation(SOCPlayerInterface, SOCPlayer, boolean) to player.getPlayerNumber()

Since:
1.1.16

playerIsClient

protected boolean playerIsClient
Does this panel represent our client's own hand? If true, implies interactive.


playerIsCurrent

protected boolean playerIsCurrent
Is this panel's player the game's current player? Used for hilight - set in updateAtTurn()


inPlay

protected boolean inPlay
Do we have any seated player? Set by addPlayer(String), cleared by removePlayer().


playerSendMap

protected int[] playerSendMap
Three player numbers to send trade offers to. For i from 0 to 2, playerSendMap[i] is playerNumber for checkbox i. This is null if playerTradingDisabled.

See Also:
playerSend

offer

protected TradeOfferPanel offer
Display other players' trade offers and related messages. Does not apply to client's hand panel (playerIsClient == true). Both offer and counter-offer display are part of this object. Also used to display board-reset vote messages. When displaying a message, looks like a SpeechBalloon.

If the handpanel is not tall enough, other controls will be obscured by this one. This low height is indicated by offerHidesControls and possibly offerCounterHidesFace.

See Also:
offerIsResetMessage, offerIsDiscardOrPickMessage

offerHidesControls

private boolean offerHidesControls
If true, the handpanel isn't tall enough, so when the offer message panel is showing something, we must hide other controls. Does not apply to client's hand panel.

Since:
1.1.08
See Also:
hideTradeMsgShowOthers(boolean)

offerCounterHidesFace

private boolean offerCounterHidesFace
If true, the handpanel isn't tall enough, so when the offer message panel is showing something, we must hide other controls. Does not apply to client's hand panel.

Since:
1.1.08
See Also:
hideTradeMsgShowOthers(boolean)

offerHidingControls

private boolean offerHidingControls
When handpanel isn't tall enough, are we currently in the situation described at offerHidesControls or offerCounterHidesFace?

Since:
1.1.08

offerCounterHidingFace

private boolean offerCounterHidingFace
When handpanel isn't tall enough, are we currently in the situation described at offerHidesControls or offerCounterHidesFace?

Since:
1.1.08

offerIsResetMessage

protected boolean offerIsResetMessage
Board-reset voting: If true, offer is holding a message related to a board-reset vote.

See Also:
offerIsDiscardOrPickMessage

offerIsDiscardOrPickMessage

private boolean offerIsDiscardOrPickMessage
Board-reset voting: If true, offer is holding a discard message (TRADEMSG_DISCARD) or a gold hex pick-resources message (TRADEMSG_PICKING). Set by setDiscardOrPickMsg(boolean), cleared by clearDiscardOrPickMsg().

See Also:
offerIsResetMessage

offerIsMessageWasTrade

protected boolean offerIsMessageWasTrade
Board-reset voting: If true, offer was holding an active trade offer before offerIsResetMessage or offerIsDiscardOrPickMessage was set.


interactive

protected boolean interactive
When this flag is true, the panel is interactive. If playerIsClient true, implies interactive.


createColorSqRetLbl

private java.awt.Label createColorSqRetLbl
Color square label created by most recent call to createAndAddResourceColorSquare(Color, String).


createColorSqRetSq

private ColorSquare createColorSqRetSq
Color square created by most recent call to createAndAddResourceColorSquare(Color, String).

Constructor Detail

SOCHandPanel

public SOCHandPanel(SOCPlayerInterface pi,
                    SOCPlayer pl,
                    boolean in)
make a new hand panel

Parameters:
pi - the interface that this panel is a part of
pl - the player associated with this panel
in - the interactive flag setting

SOCHandPanel

public SOCHandPanel(SOCPlayerInterface pi,
                    SOCPlayer pl)
make a new hand panel

Parameters:
pi - the interface that this panel is a part of
pl - the player associated with this panel
Method Detail

creation

protected void creation(SOCPlayerInterface pi,
                        SOCPlayer pl,
                        boolean in)
Stuff to do when a SOCHandPanel is created. Calls removePlayer() as part of creation.

Parameters:
pi - player interface
pl - the player data, cannot be null
in - the interactive flag setting

createAndAddResourceColorSquare

private final void createAndAddResourceColorSquare(java.awt.Color rc,
                                                   java.lang.String rtxtkey)
Create a ColorSquare and its Label, with the given text key, and add them to the layout. The new colorsquare and label will be "returned" by setting the createColorSqRetSq and createColorSqRetLbl fields.

Parameters:
rc - Color for the square, such as ColorSquare.CLAY
rtxtkey - Text key for i18n, such as "resources.clay". If this key gives the text "Clay", the label will be "Clay:" and the tooltip will be "Right-click to trade clay".
Since:
2.0.00

getPlayerInterface

public SOCPlayerInterface getPlayerInterface()
Returns:
the player interface

getPlayer

public SOCPlayer getPlayer()
Returns:
the player

getClient

public SOCPlayerClient getClient()
Returns:
the client

getGame

public SOCGame getGame()
Returns:
the game

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
handle interaction

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

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Handle clicks on svpSq or svpLab to get more info.

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

mousePressed

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

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

mouseReleased

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

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

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
required stub for MouseListener

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

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
required stub for MouseListener

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

createSendBankTradeRequest

private void createSendBankTradeRequest(SOCGame game,
                                        int[] give,
                                        int[] get)
Create and send a bank/port trade request. Remember the resources for the "undo" button.

Parameters:
game - Our game
give - Resources to give, same format as SOCResourceSet.SOCResourceSet(int[])
get - Resources to get, same format as SOCResourceSet.SOCResourceSet(int[])
Since:
1.1.13

disableBankUndoButton

public void disableBankUndoButton()
Disable the bank/port trade undo button. Call when a non-trade game action is sent by the client.

Since:
1.1.13

clickRobotSeatLockButton

private final void clickRobotSeatLockButton(SOCGame.SeatLockState current)
During game play, handle a click on a sitting robot's Lock/Unlock/Mark button, ask the server to advance to the next seat lock state. Called from actionPerformed(ActionEvent).

Parameters:
current - Current lock state/button label
Since:
2.0.00

clickPlayCardButton

public void clickPlayCardButton()
Handle a click on the "play card" button, or double-click on an item in the inventory/list of cards held.

Inventory items are almost always SOCDevCards. Some scenarios may place other items in the player's inventory, such as a "gift" port being moved in _SC_FTRI. If one of these is chosen, this method calls clickPlayInventorySpecialItem(SOCInventoryItem).

Called from actionPerformed()


clickPlayInventorySpecialItem

private final void clickPlayInventorySpecialItem(SOCInventoryItem item)
Handle a click on a special inventory item (not a SOCDevCard). Used only in certain scenarios.

Parameters:
item - Special item picked by player
Since:
2.0.00

clickRollButton

public void clickRollButton()
Handle a click on the roll button. Called from actionPerformed() and the auto-roll timer task.


addSittingRobotLockBut

public void addSittingRobotLockBut()
Add the "lock" button for when a robot is currently playing in this position. This is not the large "lock" button seen in empty positions when the game is forming, which prevents a robot from sitting down. That button is actually sitBut with a different label.

This method was addSeatLockBut() before 1.1.07.


addTakeOverBut

public void addTakeOverBut()
DOCUMENT ME!


addSitButton

public void addSitButton(boolean clientHasSatAlready)
Add the "Sit Here" button. If this button has been used as a "lock" button to keep out a robot, revert the label to "Sit Here" unless clientHasSatAlready.

If the game's already started (state SOCGame.START2A or later), the player can't sit there; this method will hide the Sit button if ! clientHasSatAlready.

Note: Does not check if the seat is vacant (in case we're removing a player, and game state is not yet updated); please call SOCGame.isSeatVacant(int) before calling this.

Parameters:
clientHasSatAlready - Is the client seated in this game? If so, button label should be "lock"/"unlock" (about robots). (Added in 1.1.07)
See Also:
renameSitButLock()

addRobotButton

public void addRobotButton()
DOCUMENT ME!


changeFace

public void changeFace(int id)
Change the face image

Parameters:
id - the id of the image

removePlayer

public void removePlayer()
remove this player. To prevent inconsistencies, call this before calling SOCGame.removePlayer(String). Also called from constructor, before doLayout().

See Also:
addPlayer(String)

destroy

public void destroy()
Remove elements to clean up this panel. Calls removePlayer() as part of cleanup.


addPlayer

public void addPlayer(java.lang.String name)
Add a player (human or robot) at this currently-vacant seat position. Update controls at this handpanel. Also update ALL OTHER handpanels in our playerInterface this way: Remove all of the sit and take over buttons. If game still forming, can lock seats (for fewer players/robots).

Parameters:
name - Name of player to add
See Also:
removePlayer()

autoRollSetupTimer

protected void autoRollSetupTimer()
Player is client, is current, and has no playable cards, so begin auto-roll countdown. Called by autoRollOrPromptPlayer when that condition is met. Countdown begins with AUTOROLL_TIME seconds.

See Also:
autoRollOrPromptPlayer()

updateAtTurn

public void updateAtTurn()
Handpanel interface updates at start of each turn (not just our turn). Calls updateTakeOverButton(), and checks if current player (for hilight). Called from client when server sends SOCMessage.TURN. Called also at start of game by SOCPlayerInterface.updateAtGameState(), because the server sends no TURN between the last road (gamestate START2B) and the first player's turn (state PLAY).


updateAtOurGameState

void updateAtOurGameState()
Client is current player; state changed. Enable or disable the Roll, Done and Bank buttons.

Should not be called except by client's playerinterface. Call only when if player is client and is current player.

Before 2.0.00, this was updateAtPlay1().


updateButtonsAtAdd

private void updateButtonsAtAdd()
Enable,disable the proper buttons when the client (player) is added to a game. Call only if playerIsClient.


pnameCalcColors

protected void pnameCalcColors()
During this player's first turn, calculate the player name label's background color for current player.


sqPanelZerosChange

public void sqPanelZerosChange(boolean notAllZero)
If trade offer is set/cleared, enable/disable buttons accordingly.


offerCounterOfferVisibleChanged

public void offerCounterOfferVisibleChanged(boolean counterVisible)
Callback from TradeOfferPanel. For players who aren't the client: If our TradeOfferPanel shows/hides the counter offer, may need to rearrange or hide controls under it. This should be called when in TradeOfferPanel.OFFER_MODE, not in TradeOfferPanel.MESSAGE_MODE.

Parameters:
counterVisible - Is the counter-offer showing?
Since:
1.1.08

autoRollOrPromptPlayer

public void autoRollOrPromptPlayer()
If the player (client) has no playable cards, begin auto-roll countdown, Otherwise, prompt them to roll or pick a card.

Call only if panel's player is the client, and the game's current player.

Called when server sends a ROLLDICEPROMPT message.

See Also:
updateAtTurn(), autoRollSetupTimer()

updateDevCards

public void updateDevCards(boolean addedPlayable)
Update the displayed list of player's development cards and other inventory items, and enable or disable the "Play Card" button.

Enables the "Play Card" button for PLAYABLE cards, and also for KEPT cards (VP cards) so the user can pick those and get a message that that they've already been played, instead of wondering why they're listed but can't be played.

Updates inventory and inventoryItems to keep them in sync.

Parameters:
addedPlayable - True if the update added a dev card or item that's playable now

removeSittingRobotLockBut

public void removeSittingRobotLockBut()
Remove the "lock" button seen when a robot is currently playing in this position.

This method was removeSeatLockBut() before 1.1.07.

See Also:
addSittingRobotLockBut(), removeSitBut()

removeTakeOverBut

public void removeTakeOverBut()
DOCUMENT ME!


removeSitBut

public void removeSitBut()
Remove the sit-here / lockout-robot button. If it's currently "lockout", revert button text to "sit-here", and hide the "locked, no robot" text label.

See Also:
renameSitButLock(), addSittingRobotLockBut()

removeSitLockoutBut

public void removeSitLockoutBut()
Remove the sit-here/lockout-robot button, only if its label is currently "lockout". (sitButIsLock == true). This button is also used for newly joining players to choose a seat. If the button label is "sit here", our interface is a newly joining player to a game that's already started; otherwise they arrived while the game was forming, and now it's started, so clean up the window.


renameSitButLock

public void renameSitButLock()
If game is still forming (state NEW), and player has just chosen a seat, can lock empty seats for a game with fewer players/robots. This uses the same server-interface as the "lock" button shown when robot is playing in the position, but a different button in the client (the sit-here button).

See Also:
addSitButton(boolean), updateSeatLockButton()

removeRobotBut

public void removeRobotBut()
DOCUMENT ME!


removeStartBut

public void removeStartBut()
Internal mechanism to remove start button (if visible) and add VP label. Also refreshes status of "send-offer" checkboxes vs. vacant seats.


updateCurrentOffer

public void updateCurrentOffer(boolean resourcesOnly)
Display or update this player's trade offer, or hide if none. If a game reset request is in progress, don't show the offer, because they use the same display component (offer). In that case the trade offer will be refreshed after the reset is cancelled.

Does not display if playerIsClient.

Parameters:
resourcesOnly - If true, instead of updating the entire offer, only show or hide "Accept" button based on the client player's resources. Calls TradeOfferPanel.updateOfferButtons(). If no offer is currently visible, does nothing.

rejectOfferShowNonClient

public void rejectOfferShowNonClient()
Show that this player (who isn't the client) has rejected another player's offer. For robots, do nothing unless SOCGame.hasTradeOffers(), because the bots will sometimes reject another player's offer after a bank trade.


rejectOfferAtClient

public void rejectOfferAtClient()
Client is rejecting the current offer from another player. Send to the server, hide the trade message, trigger a repaint.

Since:
1.1.08

clearTradeMsg

public void clearTradeMsg()
If the trade-offer panel is showing a message (not a trade offer), clear and hide it. Assumes this hand's player is not the client.

See Also:
tradeSetMessage(String)

hideTradeMsgShowOthers

private void hideTradeMsgShowOthers(boolean hideTradeMsg)
If handpanel isn't tall enough, when the offer message panel is showing, we must hide other controls.

This method does not hide/show the trade offer; other methods do that, and then call this method to show/hide the controls that would be obscured by it.

If offerCounterHidesFace, will check TradeOfferPanel.isCounterOfferMode() and redo layout (to hide/move) if needed.

Parameters:
hideTradeMsg - Are we hiding, or showing, the trade offer message panel?
Since:
1.1.08
See Also:
tradeSetMessage(String), clearTradeMsg(), offerHidesControls

clearOffer

public void clearOffer(boolean updateSendCheckboxes)
Clear the current offer. If player is client, clear the numbers in the resource "offer" squares, and disable the "offer" and "clear" buttons (since no resources are selected). Otherwise just hide the last-displayed offer.

Parameters:
updateSendCheckboxes - If true, and player is client, update the selection checkboxes for which opponents are sent the offer. If it's currently our turn, check all boxes where the seat isn't empty. Otherwise, check only the box for the opponent whose turn it is.

tradeSetMessage

private void tradeSetMessage(java.lang.String message)
Show or hide a message in the trade-panel. Should not be client player, only other players. Sets offerIsMessageWasTrade, but does not set boolean modes (offerIsResetMessage, offerIsDiscardMessage, etc.) Will clear boolean modes if message null.

Parameters:
message - Message to show, or null to hide (and return tradepanel to previous display, if any)

resetBoardSetMessage

public void resetBoardSetMessage(java.lang.String message)
                          throws java.lang.IllegalStateException
Show or hide a message related to board-reset voting.

Parameters:
message - Message to show, or null to hide
Throws:
java.lang.IllegalStateException - if offerIsDiscardMessage true when called

setDiscardOrPickMsg

public boolean setDiscardOrPickMsg(boolean isDiscard)
Show the "discarding..." or "picking resources..." message in the trade panel. Indicates discard on a 7, or picking resources on a gold hex. Assumes player can't be discarding and asking for board-reset at same time. Not called for the client player, only for other players.

Normally, this will be cleared by updateValue(PlayerClientListener.UpdateType) for NUMRESOURCES, because that's what the server sends all other players on the player's discard or pick.

Parameters:
isDiscard - True to show TRADEMSG_DISCARD, false for TRADEMSG_PICKING.
Returns:
true if set, false if not set because was in reset-mode already.
See Also:
clearDiscardOrPickMsg(), SOCPlayerInterface.discardOrPickTimerSet(boolean)

clearDiscardOrPickMsg

public void clearDiscardOrPickMsg()
Clear the "discarding..." or "picking resources..." message in the trade panel. Assumes player can't be discarding and asking for board-reset at same time. If wasn't in discardMessage mode, do nothing.

See Also:
setDiscardOrPickMsg(boolean)

updateTakeOverButton

public void updateTakeOverButton()
update the takeover button so that it only allows takover when it's not the robot's turn


updateRollDoneBankButtons

private void updateRollDoneBankButtons()
Client is current player; enable or disable buttons according to game state: rollBut, doneBut, bankBut. Call only if playerIsCurrent and playerIsClient.

v2.0.00+: In game state SOCGame.PLACING_INV_ITEM, the Play Card button's label becomes CANCEL, and inventory is disabled, while the player places an item on the board. They can hit Cancel to return the item to their inventory instead. (Checks the flag set in setCanCancelInvItemPlay(boolean).) Once that state is over, button and inventory return to normal.


updateSeatLockButton

public void updateSeatLockButton()
update the seat lock button so that it allows a player to lock an unlocked seat and vice versa. Called from client when server sends a SETSEATLOCK message. Updates both buttons: The robot-seat-lock (when robot playing at this position) and the robot-lockout (game forming, seat vacant, no robot here please) buttons.


setLArmy

protected void setLArmy(boolean haveIt)
turn the "largest army" label on or off

Parameters:
haveIt - true if this player has the largest army

setLRoad

protected void setLRoad(boolean haveIt)
Turn the "longest road" label on or off. If the game uses the large sea board, the label shows "L. Route" instead of "L. Road".

Parameters:
haveIt - true if this player has the longest road

setCanCancelInvItemPlay

void setCanCancelInvItemPlay(boolean canCancel)
This player is playing or placing a special SOCInventoryItem, such as a gift trade port in scenario _SC_FTRI. Set a flag that indicates if this play or placement can be canceled (returned to player's inventory).

Should be called only for our own client player, not other players.

Should be called before entering game state PLACING_INV_ITEM. In that state, updateRollDoneBankButtons() checks this flag to see if the "Cancel" button should be enabled.

Parameters:
canCancel - True if SOCInventoryItem.canCancelPlay

updateValue

public void updateValue(PlayerClientListener.UpdateType utype)
update the value of a player element. Call this after updating game data.

If VICTORYPOINTS is updated, and game state is SOCGame.OVER, check for winner and update (player name label, victory-points tooltip, disable bank/trade btn)

Parameters:
utype - the type of value update, such as VICTORYPOINTS or PlayerClientListener.UpdateType.Sheep.

updatePickGoldHexResources

public void updatePickGoldHexResources()
This player must pick this many gold hex resources, or no longer needs to pick them. Called after SOCPlayer.setNeedToPickGoldHexResources(int). Informational only: do not display a SOCDiscardOrGainResDialog.

"Clear" is handled here (has picked, numPick == 0, no longer needs to pick some). "Set" (numPick > 0) is handled in SOCPlayerInterface.updateAtGameState() which will display "Picking resources..." in the handpanel for any non-client players who need to pick.


updateResourcesVP

public void updateResourcesVP()
Re-read player's resource info and victory points, update the display and resource trade costs and resourceTradeMenu text.


updateResourceTradeCosts

public void updateResourceTradeCosts(boolean doInit)
If playerIsClient, update cost of bank/port trade per resource. Update resourceTradeCost numbers and resourceTradeMenu text.

Parameters:
doInit - If true, fill resourceTradeMenu[] with newly constructed menus.

isClientPlayer

public boolean isClientPlayer()
Is this panel showing the client's player?

See Also:
isClientAndCurrentPlayer(), SOCPlayerInterface.getClientHand()

isClientAndCurrentPlayer

public boolean isClientAndCurrentPlayer()
Is this panel showing the client's player, and is that player the game's current player?

Note that because of the order of network messages, after this player's turn, there's a brief time when the state becomes PLAY again, before the current player is changed to the next player. So, it appears that this player can roll again, but they cannot. To guard against this, use isClientAndCurrentlyCanRoll() instead.


isClientAndCurrentlyCanRoll

public boolean isClientAndCurrentlyCanRoll()
Is this panel showing the client's player, and is that player the game's current player, and are they able to roll the dice right now?

Since:
1.1.09

setRollPrompt

protected void setRollPrompt(java.lang.String prompt,
                             boolean cancelTimer)
Set or clear the roll prompt / auto-roll countdown display.

Parameters:
prompt - The message to display, or null to clear it.
cancelTimer - Cancel autoRollTimerTask, for use with null prompt

getBlankStandIn

public ColorSquare getBlankStandIn()
For SOCPlayerInterface's use, to set its size and position

Returns:
the stand-in blank colorsquare: not a subcomponent, but shows up when handpanel is hidden
Since:
1.1.06
See Also:
setBounds(int, int, int, int)

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overriden to also update getBlankStandIn() bounds.

Overrides:
setBounds in class java.awt.Component
Since:
1.1.06

doLayout

public void doLayout()
Custom layout for player hand panel. Different arrangements for our hand, other player's hand, or empty seat. See comments for arrangement details.

Overrides:
doLayout in class java.awt.Container