soc.client
Class SOCHandPanel

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

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

This panel displays a player's information. If the player is us, then more information is displayed than in another player's hand panel. Custom layout: @see #doLayout()

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 inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected 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
           
protected  java.awt.Button bankBut
           
protected static java.lang.String CARD
           
protected  java.awt.List cardList
           
private  boolean chatExcepTested
           
static int CITIES
           
protected  java.awt.Label cityLab
           
protected  ColorSquare citySq
           
static int CLAY
           
protected  java.awt.Label clayLab
           
protected  ColorSquare claySq
           
protected static java.lang.String CLEAR
           
protected  java.awt.Button clearBut
           
protected  SOCPlayerClient client
           
protected static java.awt.Color COLOR_FOREGROUND
          Panel text color, and player name color when not current player
protected  java.awt.Label developmentLab
           
protected  ColorSquare developmentSq
           
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
           
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
           
protected  boolean interactive
          When this flag is true, the panel is interactive.
protected  java.awt.Label knightsLab
           
protected  ColorSquare knightsSq
           
static int LARGESTARMY
           
protected  java.awt.Label larmyLab
           
protected static java.lang.String LOCKSEAT
           
static int LONGESTROAD
           
protected  java.awt.Label lroadLab
           
static int NUMDEVCARDS
           
static int NUMKNIGHTS
           
static int NUMRESOURCES
           
protected  TradeOfferPanel offer
          Display other players' trade offers and related messages.
protected  boolean offerIsDiscardMessage
          Board-reset voting: If true, offer is holding a discard message.
protected  boolean offerIsMessageWasTrade
          Board-reset voting: If true, offer was holding an active trade offer before offerIsResetMessage or offerIsDiscardMessage was set.
protected  boolean offerIsResetMessage
          Board-reset voting: If true, offer is holding a message related to a board-reset vote.
static int ORE
           
protected  java.awt.Label oreLab
           
protected  ColorSquare oreSq
           
protected  java.awt.Button playCardBut
           
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()
protected  ColorSquare[] playerSend
          Checkboxes to send to the other three players.
protected  int[] playerSendMap
          Three player numbers to send trade offers to.
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
           
protected  ColorSquare resourceSq
           
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  java.awt.Label roadLab
           
static int ROADS
           
protected  ColorSquare roadSq
           
protected static java.lang.String ROBOT
           
protected  java.awt.Button robotBut
           
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
           
protected  java.awt.Button seatLockBut
          Seat lock/unlock shown in robot handpanels during game play, to prevent/allow humans to join and take over a robot's seat
protected static java.lang.String SEND
           
protected  java.awt.Button sendBut
           
protected  AWTToolTip sendButTip
          Hint for "Offer" button; non-null only if interactive.
protected static java.lang.String SENDBUTTIP_DIS
           
protected static java.lang.String SENDBUTTIP_ENA
           
protected  java.awt.Label settlementLab
           
static int SETTLEMENTS
           
protected  ColorSquare settlementSq
           
static int SHEEP
           
protected  java.awt.Label sheepLab
           
protected  ColorSquare sheepSq
           
protected static java.lang.String SIT
           
protected  java.awt.Button sitBut
           
protected  boolean sitButIsLock
          When true, the game is still forming, player has chosen a seat; "Sit Here" button is labeled as "Lock".
protected static java.lang.String SITLOCKED
          Before game starts, use pname to show if a seat is no-robots-allowed.
protected  SquaresPanel sqPanel
           
protected static java.lang.String START
           
protected  java.awt.Button startBut
           
protected static java.lang.String TAKEOVER
           
protected  java.awt.Button takeOverBut
           
protected static java.lang.String TRADEMSG_DISCARD
           
protected static java.lang.String UNLOCKSEAT
           
static int VICTORYPOINTS
           
protected  java.awt.Label vpLab
           
protected  ColorSquare vpSq
           
static int WHEAT
           
protected  java.awt.Label wheatLab
           
protected  ColorSquare wheatSq
           
static int WIDTH_MIN
          Minimum desired width, in pixels
protected static java.lang.String WINNER_SUFFIX
          If player has won the game, update pname label
static int WOOD
           
protected  java.awt.Label woodLab
           
protected  ColorSquare woodSq
           
protected static int[] zero
          Array of five zeroes; for sqPanel.
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
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)
          DOCUMENT ME!
 void addRobotButton()
          DOCUMENT ME!
 void addSeatLockBut()
          Add the "lock" button for when a robot is currently playing in this position.
 void addSitButton()
          Add the "Sit Here" button.
 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 clearDiscardMsg()
          Clear the "discarding..." message in the trade panel.
 void clearOffer(boolean updateSendCheckboxes)
          Clear the current offer.
 void clearTradeMsg()
          DOCUMENT ME!
 void clickPlayCardButton()
          Handle a click on the "play card" button, or double-click on an item in the list of cards held.
 void clickRollButton()
          Handle a click on the roll button.
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 doLayout()
          Custom layout for player hand panel.
 SOCPlayerClient getClient()
           
 SOCGame getGame()
           
 SOCPlayer getPlayer()
           
 SOCPlayerInterface getPlayerInterface()
           
 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?
protected  void pnameCalcColors()
          During this player's first turn, calculate the player name label's background color for current player.
 void rejectOffer()
          Show that this player has rejected another player's offer.
 void removePlayer()
          remove this player
 void removeRobotBut()
          DOCUMENT ME!
 void removeSeatLockBut()
          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 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.
 boolean setDiscardMsg()
          Show the "discarding..." 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)
          Set or clear the roll prompt / auto-roll countdown display.
 void sqPanelZerosChange(boolean notAllZero)
          If enable/disable buttons accordingly.
private  void tradeSetMessage(java.lang.String message)
          Show or hide a message in the trade-panel.
 void updateAtPlay1()
          Client is current player; state changed from PLAY to PLAY1.
 void updateAtTurn()
          Handpanel interface updates at start of each turn (not just our turn).
 void updateButtonsAtAdd()
          Enable,disable the proper buttons when the client (player) is added to a game.
 void updateCurrentOffer()
          Display or update this player's trade offer, or hide if none.
 void updateDevCards()
          DOCUMENT ME!
 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.
 void updateRollButton()
          Client is current player, turn has just begun.
 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(int vt)
          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, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, 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, 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, isOpaque, 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, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, 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

ROADS

public static final int ROADS
See Also:
Constant Field Values

SETTLEMENTS

public static final int SETTLEMENTS
See Also:
Constant Field Values

CITIES

public static final int CITIES
See Also:
Constant Field Values

NUMRESOURCES

public static final int NUMRESOURCES
See Also:
Constant Field Values

NUMDEVCARDS

public static final int NUMDEVCARDS
See Also:
Constant Field Values

NUMKNIGHTS

public static final int NUMKNIGHTS
See Also:
Constant Field Values

VICTORYPOINTS

public static final int VICTORYPOINTS
See Also:
Constant Field Values

LONGESTROAD

public static final int LONGESTROAD
See Also:
Constant Field Values

LARGESTARMY

public static final int LARGESTARMY
See Also:
Constant Field Values

CLAY

public static final int CLAY
See Also:
Constant Field Values

ORE

public static final int ORE
See Also:
Constant Field Values

SHEEP

public static final int SHEEP
See Also:
Constant Field Values

WHEAT

public static final int WHEAT
See Also:
Constant Field Values

WOOD

public static final int WOOD
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; for sqPanel.


SITLOCKED

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

See Also:
Constant Field Values

SIT

protected static final java.lang.String SIT
See Also:
Constant Field Values

START

protected static final java.lang.String START
See Also:
Constant Field Values

ROBOT

protected static final java.lang.String ROBOT
See Also:
Constant Field Values

TAKEOVER

protected static final java.lang.String TAKEOVER
See Also:
Constant Field Values

LOCKSEAT

protected static final java.lang.String LOCKSEAT
See Also:
Constant Field Values

UNLOCKSEAT

protected static final java.lang.String UNLOCKSEAT
See Also:
Constant Field Values

ROLL

protected static final java.lang.String ROLL
See Also:
Constant Field Values

QUIT

protected static final java.lang.String QUIT
See Also:
Constant Field Values

DONE

protected static final java.lang.String DONE
See Also:
Constant Field Values

DONE_RESTART

protected static final java.lang.String DONE_RESTART
Text of Done button at end of game becomes Restart button

See Also:
Constant Field Values

CLEAR

protected static final java.lang.String CLEAR
See Also:
Constant Field Values

SEND

protected static final java.lang.String SEND
See Also:
Constant Field Values

BANK

protected static final java.lang.String BANK
See Also:
Constant Field Values

CARD

protected static final java.lang.String CARD
See Also:
Constant Field Values

GIVE

protected static final java.lang.String GIVE
See Also:
Constant Field Values

GET

protected static final java.lang.String GET
See Also:
Constant Field Values

AUTOROLL_COUNTDOWN

protected static final java.lang.String AUTOROLL_COUNTDOWN
See Also:
Constant Field Values

ROLL_OR_PLAY_CARD

protected static final java.lang.String ROLL_OR_PLAY_CARD
See Also:
Constant Field Values

SENDBUTTIP_ENA

protected static final java.lang.String SENDBUTTIP_ENA
See Also:
Constant Field Values

SENDBUTTIP_DIS

protected static final java.lang.String SENDBUTTIP_DIS
See Also:
Constant Field Values

TRADEMSG_DISCARD

protected static final java.lang.String TRADEMSG_DISCARD
See Also:
Constant Field Values

WINNER_SUFFIX

protected static final java.lang.String WINNER_SUFFIX
If player has won the game, update pname label

See Also:
Constant Field Values

COLOR_FOREGROUND

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


pnameActiveBG

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


sitBut

protected java.awt.Button sitBut

robotBut

protected java.awt.Button robotBut

startBut

protected java.awt.Button startBut

takeOverBut

protected java.awt.Button takeOverBut

seatLockBut

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


sitButIsLock

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


faceImg

protected SOCFaceButton faceImg

pname

protected java.awt.Label pname

vpLab

protected java.awt.Label vpLab

vpSq

protected ColorSquare vpSq

larmyLab

protected java.awt.Label larmyLab

lroadLab

protected java.awt.Label lroadLab

claySq

protected ColorSquare claySq

oreSq

protected ColorSquare oreSq

sheepSq

protected ColorSquare sheepSq

wheatSq

protected ColorSquare wheatSq

woodSq

protected ColorSquare woodSq

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

settlementLab

protected java.awt.Label settlementLab

cityLab

protected java.awt.Label cityLab

roadLab

protected java.awt.Label roadLab

resourceSq

protected ColorSquare resourceSq

resourceLab

protected java.awt.Label resourceLab

developmentSq

protected ColorSquare developmentSq

developmentLab

protected java.awt.Label developmentLab

knightsSq

protected ColorSquare knightsSq

knightsLab

protected java.awt.Label knightsLab

cardList

protected java.awt.List cardList

playCardBut

protected java.awt.Button playCardBut

sqPanel

protected SquaresPanel sqPanel

giveLab

protected java.awt.Label giveLab

getLab

protected java.awt.Label getLab

sendBut

protected java.awt.Button sendBut

sendButTip

protected AWTToolTip sendButTip
Hint for "Offer" button; non-null only if interactive.

See Also:
SENDBUTTIP_DIS, SENDBUTTIP_ENA, interactive

clearBut

protected java.awt.Button clearBut

bankBut

protected java.awt.Button bankBut

playerSend

protected ColorSquare[] playerSend
Checkboxes to send to the other three players. Enabled/disabled at removeStartBut().

See Also:
playerSendMap

rollPromptCountdownLab

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

See Also:
setRollPrompt(String)

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

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

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.

See Also:
playerSend

offer

protected TradeOfferPanel offer
Display other players' trade offers and related messages. Not used if playerIsClient. Also used to display board-reset vote messages.

See Also:
offerIsResetMessage, offerIsDiscardMessage

offerIsResetMessage

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


offerIsDiscardMessage

protected boolean offerIsDiscardMessage
Board-reset voting: If true, offer is holding a discard message.


offerIsMessageWasTrade

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


interactive

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


chatExcepTested

private boolean chatExcepTested
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
in - the interactive flag setting

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

clickPlayCardButton

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


clickRollButton

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


addSeatLockBut

public void addSeatLockBut()
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.


addTakeOverBut

public void addTakeOverBut()
DOCUMENT ME!


addSitButton

public void addSitButton()
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".


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


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)
DOCUMENT ME!

Parameters:
name - DOCUMENT ME!

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


updateAtPlay1

public void updateAtPlay1()
Client is current player; state changed from PLAY to PLAY1. (Dice has been rolled, or card played.) Update interface accordingly. Should not be called except by client's playerinterface.


updateButtonsAtAdd

public void updateButtonsAtAdd()
Enable,disable the proper buttons when the client (player) is added to a game.


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 enable/disable buttons accordingly.


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 SOCRollDicePrompt message.

See Also:
updateAtTurn(), autoRollSetupTimer()

updateDevCards

public void updateDevCards()
DOCUMENT ME!


removeSeatLockBut

public void removeSeatLockBut()
DOCUMENT ME!


removeTakeOverBut

public void removeTakeOverBut()
DOCUMENT ME!


removeSitBut

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


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


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


rejectOffer

public void rejectOffer()
Show that this player has rejected another player's offer.


clearTradeMsg

public void clearTradeMsg()
DOCUMENT ME!


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

setDiscardMsg

public boolean setDiscardMsg()
Show the "discarding..." message in the trade panel. Assumes player can't be discarding and asking for board-reset at same time. Normally, this will be cleared by updateValue(int) for NUMRESOURCES, because that's what the server sends all other players on discard.

Returns:
true if set, false if not set because was in reset-mode already.
See Also:
clearDiscardMsg(), TRADEMSG_DISCARD

clearDiscardMsg

public void clearDiscardMsg()
Clear the "discarding..." 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:
setDiscardMsg()

updateTakeOverButton

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


updateRollButton

public void updateRollButton()
Client is current player, turn has just begun. Enable any previously disabled buttons.


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

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

updateValue

public void updateValue(int vt)
update the value of a player element. If VICTORYPOINTS is updated, and game state is over, check for winner and update (player name label, victory-points tooltip, disable bank/trade btn)

Parameters:
vt - the type of value

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

isClientAndCurrentPlayer

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


setRollPrompt

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

Parameters:
prompt - The message to display, or null to clear it.

doLayout

public void doLayout()
Custom layout for player hand panel.