soc.client
Class SOCPlayerClient

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

public class SOCPlayerClient
extends java.applet.Applet
implements java.lang.Runnable, java.awt.event.ActionListener

Applet/Standalone client for connecting to the SOCServer. Prompts for name and password, displays list of games and channels available. The actual game is played in a separate SOCPlayerInterface window.

If you want another connection port, you have to specify it as the "port" argument in the html source. If you run this as a stand-alone, you have to specify the port.

At startup or init, will try to connect to server via connect(). See that method for more details.

Author:
Robert S Thomas
See Also:
Serialized Form

Nested Class Summary
private static class SOCPlayerClient.MyWindowAdapter
          React to windowOpened, windowClosing events for SOCPlayerClient's Frame.
protected  class SOCPlayerClient.SOCPlayerLocalRobotRunner
          For local practice games, each robot gets its own thread.
protected  class SOCPlayerClient.SOCPlayerLocalStringReader
          For local practice games, reader thread to get messages from the local server to be treated and reacted to.
 
Nested classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
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  java.applet.AppletContext ac
           
protected  java.awt.CardLayout cardLayout
          SOCPlayerClient displays one of several panels to the user: MAIN_PANEL, MESSAGE_PANEL or (if launched from jar, or with no command-line arguments) CONNECT_OR_PRACTICE_PANEL.
protected  java.awt.TextField channel
           
protected  java.util.Hashtable channels
          the channels
protected  java.awt.List chlist
           
protected static java.lang.String CONNECT_OR_PRACTICE_PANEL
          connect-or-practice panel (if jar launch), in cardlayout
protected  boolean connected
           
protected  SOCConnectOrPracticePanel connectOrPracticePane
          If applicable, is set up in initVisualElements().
static java.lang.String DEFAULT_PLAYER_NAME
          For local practice games, default player name.
static java.lang.String DEFAULT_PRACTICE_GAMENAME
          For local practice games, default game name.
protected  java.lang.Exception ex
           
protected  java.lang.Exception ex_L
           
protected  java.awt.TextField game
           
protected  java.util.Hashtable games
          the games
protected  java.awt.List gmlist
           
protected  boolean gotPassword
          true if we've stored the password
protected  boolean hasConnectOrPractice
          If true, we'll give the user a choice to connect to a server, start a local server, or a local practice game.
protected  boolean hasJoinedServer
          Once true, disable "nick" textfield, etc.
protected  java.lang.String host
           
protected  java.util.Vector ignoreList
          the ignore list
protected  java.io.DataInputStream in
           
protected  java.awt.Button jc
           
protected  java.awt.Button jg
           
protected  int lastFaceChange
          face ID chosen most recently (for use in new games)
protected  java.lang.String lastMessage_L
          For debug, our last messages sent, over the net and locally (pipes)
protected  java.lang.String lastMessage_N
          For debug, our last messages sent, over the net and locally (pipes)
protected  java.awt.Label localTCPPortLabel
           
protected  SOCServer localTCPServer
          Client-hosted TCP server.
protected static java.lang.String MAIN_PANEL
          main panel, in cardlayout
protected static java.lang.String MESSAGE_PANEL
          message panel, in cardlayout
protected  java.awt.Label messageLabel
           
protected  java.awt.Label messageLabel_top
           
static java.lang.String NEED_NICKNAME_BEFORE_JOIN
          Hint message if they try to join game without entering a nickname.
static java.lang.String NEED_NICKNAME_BEFORE_JOIN_2
          Stronger hint message if they still try to join game without entering a nickname.
static java.lang.String NET_UNAVAIL_CAN_PRACTICE_MSG
          For local practice games, reminder message for network problems.
protected  java.awt.TextField nick
           
protected  java.lang.String nickname
          the nickname
protected  int numPracticeGames
           
protected  java.io.DataOutputStream out
           
protected  java.awt.TextField pass
           
protected  java.lang.String password
          the password
protected  java.awt.Button pg
           
protected  java.awt.Button pgm
           
protected  java.util.Hashtable playerInterfaces
          the player interfaces for the games
protected  int port
           
protected  SOCServer practiceServer
          for local-practice game via prCli
protected  StringConnection prCli
          for connection to local-practice server practiceServer
protected  java.lang.Thread reader
           
protected  java.net.Socket s
           
protected  int sLocalVersion
          Server version number, sent soon after connect, or -1 if unknown
static int SOC_PORT_DEFAULT
          Default tcp port number 8880 to listen, and to connect to remote server
protected static java.lang.String STATSPREFEX
           
protected  java.awt.TextField status
           
protected  int sVersion
          Server version number, sent soon after connect, or -1 if unknown
 
Fields inherited from class java.applet.Applet
 
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
SOCPlayerClient()
          Create a SOCPlayerClient connecting to localhost port SOC_PORT_DEFAULT
SOCPlayerClient(boolean cp)
          Create a SOCPlayerClient either connecting to localhost port SOC_PORT_DEFAULT, or initially showing 'Connect or Practice' panel.
SOCPlayerClient(java.lang.String h, int p)
          Constructor for connecting to the specified host, on the specified port.
SOCPlayerClient(java.lang.String h, int p, boolean cp)
          Constructor for connecting to the specified host, on the specified port.
 
Method Summary
 void acceptOffer(SOCGame ga, int from)
          the user is accepting an offer
 void actionPerformed(java.awt.event.ActionEvent e)
          Handle mouse clicks and keyboard
 void addToGameList(java.lang.String gameName)
          add a new game to the initial window's list of games
protected  void addToIgnoreList(java.lang.String name)
          add this name to the ignore list
 void addToList(java.lang.String thing, java.awt.List lst)
          add a new channel or game, put it in the list in alphabetical order
protected  boolean anyHostedActiveGames()
          Look for active games that we're hosting (state >= START1A, not yet OVER).
 void bankTrade(SOCGame ga, SOCResourceSet give, SOCResourceSet get)
          the user wants to trade with the bank
 void buildRequest(SOCGame ga, int piece)
          request to build something
 void buyDevCard(SOCGame ga)
          request to buy a development card
 void cancelBuildRequest(SOCGame ga, int piece)
          request to cancel building something
 void changeFace(SOCGame ga, int id)
          the user is changing the face image
 void choosePlayer(SOCGame ga, int pn)
          the user chose a player to steal from
 void chSend(java.lang.String ch, java.lang.String mes)
          send a text message to a channel
 void clearOffer(SOCGame ga)
          the user is clearing an offer
 void clickPracticeButton()
          Act as if the "practice game" button has been clicked.
 void connect()
          Attempts to connect to the server.
 void connect(java.lang.String chost, int cport, java.lang.String cuser, java.lang.String cpass)
          Connect and give feedback by showing MESSAGE_PANEL.
 void considerMove(SOCGame ga, java.lang.String pname, SOCPlayingPiece piece)
          send a command to the server with a message asking a robot to show the debug info for a possible move after a move has been made
 void considerTarget(SOCGame ga, java.lang.String pname, SOCPlayingPiece piece)
          send a command to the server with a message asking a robot to show the debug info for a possible move before a move has been made
private  java.awt.event.WindowAdapter createWindowAdapter()
           
 void deleteFromGameList(java.lang.String gameName)
          delete a game from the list
 void deleteFromList(java.lang.String thing, java.awt.List lst)
          delete a group
 void destroy()
          network trouble; if possible, ask if they want to play locally (robots).
 void discard(SOCGame ga, SOCResourceSet rs)
          the user wants to discard
protected  void disconnect()
          disconnect from the net
 void discoveryPick(SOCGame ga, SOCResourceSet rscs)
          the user picked 2 resources to discover
 boolean doLocalCommand(SOCGame ga, java.lang.String cmd)
          handle local client commands for games
 boolean doLocalCommand(java.lang.String ch, java.lang.String cmd)
          handle local client commands for channels
 void endTurn(SOCGame ga)
          the user is done with the turn
protected  SOCPlayerInterface findAnyActiveGame(boolean fromPracticeServer)
          Look for active games that we're playing
 java.lang.String getAppletInfo()
          applet info
 int getHexParameter(java.lang.String name)
          Retrieve a parameter and translate to a hex value.
 java.lang.String getNickname()
           
 int getServerVersion()
          Server version, assuming we're connected to a remote server.
private  void guardedActionPerform(java.lang.Object target)
          Wrapped version of actionPerformed() for easier encapsulation.
protected  void handleBCASTTEXTMSG(SOCBCastTextMsg mes)
          handle a broadcast text message
protected  void handleBOARDLAYOUT(SOCBoardLayout mes)
          handle the "board layout" message
protected  void handleCANCELBUILDREQUEST(SOCCancelBuildRequest mes)
          handle the rare "cancel build request" message; usually not sent from server to client.
protected  void handleCHANGEFACE(SOCChangeFace mes)
          handle the "change face" message
protected  void handleCHANNELS(SOCChannels mes, boolean isLocal)
          handle the "list of channels" message; this message indicates that we're newly connected to the server.
protected  void handleCHOOSEPLAYERREQUEST(SOCChoosePlayerRequest mes)
          handle the "choose player request" message
protected  void handleCLEAROFFER(SOCClearOffer mes)
          handle the "clear offer" message
protected  void handleCLEARTRADEMSG(SOCClearTradeMsg mes)
          handle the "clear trade message" message
protected  void handleDELETECHANNEL(SOCDeleteChannel mes)
          handle the "delete channel" message
protected  void handleDELETEGAME(SOCDeleteGame mes)
          handle the "delete game" message
protected  void handleDEVCARD(SOCDevCard mes)
          handle the "development card action" message
protected  void handleDEVCARDCOUNT(SOCDevCardCount mes)
          handle the "number of development cards" message
protected  void handleDICERESULT(SOCDiceResult mes)
          handle the "dice result" message
protected  void handleDISCARDREQUEST(SOCDiscardRequest mes)
          handle the "discard request" message
protected  void handleFIRSTPLAYER(SOCFirstPlayer mes)
          handle the "first player" message
protected  void handleGAMEMEMBERS(SOCGameMembers mes)
          handle the "game members" message
protected  void handleGAMES(SOCGames mes)
          handle the "list of games" message
protected  void handleGAMESTATE(SOCGameState mes)
          handle the "game state" message
protected  void handleGAMESTATS(SOCGameStats mes)
          handle the "game stats" message
protected  void handleGAMETEXTMSG(SOCGameTextMsg mes)
          handle the "game text message" message.
protected  void handleJOIN(SOCJoin mes)
          handle the "join channel" message
protected  void handleJOINAUTH(SOCJoinAuth mes)
          handle the "join authorization" message
protected  void handleJOINGAME(SOCJoinGame mes)
          handle the "join game" message
protected  void handleJOINGAMEAUTH(SOCJoinGameAuth mes, boolean isLocal)
          handle the "join game authorization" message
protected  void handleLARGESTARMY(SOCLargestArmy mes)
          handle the "largest army" message
protected  void handleLEAVE(SOCLeave mes)
          handle the "leave channel" message
protected  void handleLEAVEGAME(SOCLeaveGame mes)
          handle the "leave game" message
protected  void handleLONGESTROAD(SOCLongestRoad mes)
          handle the "longest road" message
protected  void handleMAKEOFFER(SOCMakeOffer mes)
          handle the "make offer" message
protected  void handleMEMBERS(SOCMembers mes)
          handle the "members" message
protected  void handleMOVEROBBER(SOCMoveRobber mes)
          handle the "robber moved" message
protected  void handleNEWCHANNEL(SOCNewChannel mes)
          handle the "new channel" message
protected  void handleNEWGAME(SOCNewGame mes)
          handle the "new game" message
protected  void handlePLAYERELEMENT(SOCPlayerElement mes)
          handle the "player information" message
protected  void handlePOTENTIALSETTLEMENTS(SOCPotentialSettlements mes)
          handle the "list of potential settlements" message
protected  void handlePUTPIECE(SOCPutPiece mes)
          handle the "put piece" message
protected  void handleREJECTCONNECTION(SOCRejectConnection mes)
          handle the "reject connection" message
protected  void handleREJECTOFFER(SOCRejectOffer mes)
          handle the "reject offer" message
protected  void handleRESETBOARDAUTH(SOCResetBoardAuth mes)
          handle board reset (new game with same players, same game name, new layout).
protected  void handleRESETBOARDREJECT(SOCResetBoardReject mes)
          voting complete, board reset request rejected
protected  void handleRESETBOARDVOTE(SOCResetBoardVote mes)
          another player has voted on a board reset request: display the vote.
protected  void handleRESETBOARDVOTEREQUEST(SOCResetBoardVoteRequest mes)
          a player is requesting a board reset: we must update local game state, and vote unless we are the requester.
protected  void handleRESOURCECOUNT(SOCResourceCount mes)
          handle "resource count" message
protected  void handleROLLDICEPROMPT(SOCRollDicePrompt mes)
          handle the "roll dice prompt" message; if we're in a game and we're the dice roller, either set the auto-roll timer, or prompt to roll or choose card.
protected  void handleSETPLAYEDDEVCARD(SOCSetPlayedDevCard mes)
          handle the "set played dev card flag" message
protected  void handleSETSEATLOCK(SOCSetSeatLock mes)
          handle the "set seat lock" message
protected  void handleSETTURN(SOCSetTurn mes)
          handle the "set turn" message
protected  void handleSITDOWN(SOCSitDown mes)
          handle the "player sitting down" message
protected  void handleSTARTGAME(SOCStartGame mes)
          handle the "start game" message
protected  void handleSTATUSMESSAGE(SOCStatusMessage mes)
          handle the "status message" message.
protected  void handleTEXTMSG(SOCTextMsg mes)
          handle a text message
protected  void handleTURN(SOCTurn mes)
          handle the "turn" message
private  void handleVERSION(boolean isLocal, SOCVersion mes)
          Handle the "version" message, server's version report.
 void init()
          Initialize the applet
protected  void initVisualElements()
          init the visual elements
 void leaveChannel(java.lang.String ch)
          the user leaves the given channel
 void leaveGame(SOCGame ga)
          the user leaves the given game
 void lockSeat(SOCGame ga, int pn)
          the user is locking a seat
static void main(java.lang.String[] args)
          for stand-alones
 void monopolyPick(SOCGame ga, int res)
          the user picked a resource to monopolize
 void moveRobber(SOCGame ga, SOCPlayer pl, int coord)
          the player wants to move the robber
 void offerTrade(SOCGame ga, SOCTradeOffer offer)
          the user is making an offer to trade
protected  boolean onIgnoreList(java.lang.String name)
           
 void playDevCard(SOCGame ga, int dc)
          the user wants to play a development card
protected  void printIgnoreList(ChannelFrame fr)
          Print the current chat ignorelist in a channel.
protected  void printIgnoreList(SOCPlayerInterface pi)
          Print the current chat ignorelist in a playerinterface.
 boolean put(java.lang.String s, boolean isLocal)
          Write a message to the net or local server.
 boolean putLeaveAll()
          For shutdown - Tell the server we're leaving all games.
 boolean putLocal(java.lang.String s)
          write a message to the local server
 boolean putNet(java.lang.String s)
          write a message to the net
 void putPiece(SOCGame ga, SOCPlayingPiece pp)
          put a piece on the board
 void rejectOffer(SOCGame ga)
          the user is rejecting the current offers
protected  void removeFromIgnoreList(java.lang.String name)
          remove this name from the ignore list
 void resendLocal()
          resend the last message (to the local practice server)
 void resendNet()
          resend the last message (to the network)
 void resetBoardRequest(SOCGame ga)
          Player wants to request to reset the board (same players, new game, new layout).
 void resetBoardVote(SOCGame ga, int pn, boolean voteYes)
          Player is responding to a board-reset vote from another player.
 void rollDice(SOCGame ga)
          the user rolls the dice
 void run()
          continuously read from the net in a separate thread; not used for talking to the practice server.
 void sendText(SOCGame ga, java.lang.String me)
          send a text message to the people in the game
 void setupLocalRobots(int port)
          Set up some robot opponents for a locally running server (tcp or stringport).
 void sitDown(SOCGame ga, int pn)
          the user sits down to play
 void start()
          Called when the applet should start it's work.
 void startGame(SOCGame ga)
          the user is starting the game
 void startLocalTCPServer(int tport)
          Setup for locally hosting a TCP server.
 void startPracticeGame()
          Create a game name, and start a practice game.
 void startPracticeGame(java.lang.String practiceGameName, boolean mainPanelIsActive)
          Setup for local practice game (local server).
 void treat(SOCMessage mes, boolean isLocal)
          Treat the incoming messages.
 void unlockSeat(SOCGame ga, int pn)
          the user is unlocking a seat
 void updateGameEndStats(java.lang.String game, int[] scores)
          If we're playing in a game that's just finished, update the scores.
 void updateGameStats(java.lang.String gameName, int[] scores, boolean[] robots)
          Update this game's stats in the game list display.
static void usage()
          for stand-alones
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, 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, 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

MAIN_PANEL

protected static final java.lang.String MAIN_PANEL
main panel, in cardlayout

See Also:
Constant Field Values

MESSAGE_PANEL

protected static final java.lang.String MESSAGE_PANEL
message panel, in cardlayout

See Also:
Constant Field Values

CONNECT_OR_PRACTICE_PANEL

protected static final java.lang.String CONNECT_OR_PRACTICE_PANEL
connect-or-practice panel (if jar launch), in cardlayout

See Also:
Constant Field Values

SOC_PORT_DEFAULT

public static final int SOC_PORT_DEFAULT
Default tcp port number 8880 to listen, and to connect to remote server

See Also:
Constant Field Values

STATSPREFEX

protected static java.lang.String STATSPREFEX

nick

protected java.awt.TextField nick

pass

protected java.awt.TextField pass

status

protected java.awt.TextField status

channel

protected java.awt.TextField channel

game

protected java.awt.TextField game

chlist

protected java.awt.List chlist

gmlist

protected java.awt.List gmlist

jc

protected java.awt.Button jc

jg

protected java.awt.Button jg

pg

protected java.awt.Button pg

messageLabel

protected java.awt.Label messageLabel

messageLabel_top

protected java.awt.Label messageLabel_top

localTCPPortLabel

protected java.awt.Label localTCPPortLabel

pgm

protected java.awt.Button pgm

ac

protected java.applet.AppletContext ac

lastMessage_N

protected java.lang.String lastMessage_N
For debug, our last messages sent, over the net and locally (pipes)


lastMessage_L

protected java.lang.String lastMessage_L
For debug, our last messages sent, over the net and locally (pipes)


cardLayout

protected java.awt.CardLayout cardLayout
SOCPlayerClient displays one of several panels to the user: MAIN_PANEL, MESSAGE_PANEL or (if launched from jar, or with no command-line arguments) CONNECT_OR_PRACTICE_PANEL.

See Also:
hasConnectOrPractice

host

protected java.lang.String host

port

protected int port

s

protected java.net.Socket s

in

protected java.io.DataInputStream in

out

protected java.io.DataOutputStream out

reader

protected java.lang.Thread reader

ex

protected java.lang.Exception ex

ex_L

protected java.lang.Exception ex_L

connected

protected boolean connected

sVersion

protected int sVersion
Server version number, sent soon after connect, or -1 if unknown


sLocalVersion

protected int sLocalVersion
Server version number, sent soon after connect, or -1 if unknown


hasJoinedServer

protected boolean hasJoinedServer
Once true, disable "nick" textfield, etc. Remains true, even if connected becomes false.


hasConnectOrPractice

protected boolean hasConnectOrPractice
If true, we'll give the user a choice to connect to a server, start a local server, or a local practice game. Used for when we're started from a jar, or from the command line with no arguments. Uses SOCConnectOrPracticePanel.

See Also:
cardLayout

connectOrPracticePane

protected SOCConnectOrPracticePanel connectOrPracticePane
If applicable, is set up in initVisualElements().

See Also:
hasConnectOrPractice

DEFAULT_PLAYER_NAME

public static java.lang.String DEFAULT_PLAYER_NAME
For local practice games, default player name.


DEFAULT_PRACTICE_GAMENAME

public static java.lang.String DEFAULT_PRACTICE_GAMENAME
For local practice games, default game name.


NET_UNAVAIL_CAN_PRACTICE_MSG

public static java.lang.String NET_UNAVAIL_CAN_PRACTICE_MSG
For local practice games, reminder message for network problems.


NEED_NICKNAME_BEFORE_JOIN

public static java.lang.String NEED_NICKNAME_BEFORE_JOIN
Hint message if they try to join game without entering a nickname.

See Also:
NEED_NICKNAME_BEFORE_JOIN_2

NEED_NICKNAME_BEFORE_JOIN_2

public static java.lang.String NEED_NICKNAME_BEFORE_JOIN_2
Stronger hint message if they still try to join game without entering a nickname.

See Also:
NEED_NICKNAME_BEFORE_JOIN

nickname

protected java.lang.String nickname
the nickname


password

protected java.lang.String password
the password


gotPassword

protected boolean gotPassword
true if we've stored the password


lastFaceChange

protected int lastFaceChange
face ID chosen most recently (for use in new games)


channels

protected java.util.Hashtable channels
the channels


games

protected java.util.Hashtable games
the games


playerInterfaces

protected java.util.Hashtable playerInterfaces
the player interfaces for the games


ignoreList

protected java.util.Vector ignoreList
the ignore list


practiceServer

protected SOCServer practiceServer
for local-practice game via prCli


prCli

protected StringConnection prCli
for connection to local-practice server practiceServer


numPracticeGames

protected int numPracticeGames

localTCPServer

protected SOCServer localTCPServer
Client-hosted TCP server. If client is running this server, it's also connected as a client, instead of being client of a remote server. practiceServer may still be activated at the user's request.

Constructor Detail

SOCPlayerClient

public SOCPlayerClient()
Create a SOCPlayerClient connecting to localhost port SOC_PORT_DEFAULT


SOCPlayerClient

public SOCPlayerClient(boolean cp)
Create a SOCPlayerClient either connecting to localhost port SOC_PORT_DEFAULT, or initially showing 'Connect or Practice' panel.

Parameters:
cp - If true, start by showing 'Connect or Practice' panel, instead of connecting to localhost port.

SOCPlayerClient

public SOCPlayerClient(java.lang.String h,
                       int p)
Constructor for connecting to the specified host, on the specified port. Must call 'init' or 'initVisualElements' to start up and do layout.

Parameters:
h - host, or null for localhost
p - port

SOCPlayerClient

public SOCPlayerClient(java.lang.String h,
                       int p,
                       boolean cp)
Constructor for connecting to the specified host, on the specified port. Must call 'init' or 'initVisualElements' to start up and do layout.

Parameters:
h - host, or null for localhost
p - port
cp - If true, start by showing 'Connect or Practice' panel, instead of connecting to host and port.
Method Detail

initVisualElements

protected void initVisualElements()
init the visual elements


getHexParameter

public int getHexParameter(java.lang.String name)
Retrieve a parameter and translate to a hex value.

Parameters:
name - a parameter name. null is ignored
Returns:
the parameter parsed as a hex value or -1 on error

start

public void start()
Called when the applet should start it's work.


init

public void init()
Initialize the applet


connect

public void connect(java.lang.String chost,
                    int cport,
                    java.lang.String cuser,
                    java.lang.String cpass)
Connect and give feedback by showing MESSAGE_PANEL.

Parameters:
chost - Hostname to connect to, or null for localhost
cport - Port number to connect to
cuser - User nickname
cpass - User optional password

connect

public void connect()
Attempts to connect to the server. See connected for success or failure. Once connected, starts a reader thread. The first message over the connection is the server's response: Either SOCRejectConnection, or the lists of channels and games (SOCChannels, SOCGames).

Throws:
java.lang.IllegalStateException - if already connected
See Also:
SOCServer.newConnection1(StringConnection)

getNickname

public java.lang.String getNickname()
Returns:
the nickname of this user

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handle mouse clicks and keyboard

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

clickPracticeButton

public void clickPracticeButton()
Act as if the "practice game" button has been clicked. Assumes the dialog panels are all initialized.


guardedActionPerform

private void guardedActionPerform(java.lang.Object target)
Wrapped version of actionPerformed() for easier encapsulation.

Parameters:
target - Action source, from ActionEvent.getSource()

findAnyActiveGame

protected SOCPlayerInterface findAnyActiveGame(boolean fromPracticeServer)
Look for active games that we're playing

Parameters:
fromPracticeServer - Enumerate games from practiceServer, instead of playerInterfaces?
Returns:
Any found game of ours which is active (state not OVER), or null if none.
See Also:
anyHostedActiveGames()

anyHostedActiveGames

protected boolean anyHostedActiveGames()
Look for active games that we're hosting (state >= START1A, not yet OVER).

Returns:
If any hosted games of ours are active
See Also:
findAnyActiveGame(boolean)

run

public void run()
continuously read from the net in a separate thread; not used for talking to the practice server.

Specified by:
run in interface java.lang.Runnable

resendNet

public void resendNet()
resend the last message (to the network)


resendLocal

public void resendLocal()
resend the last message (to the local practice server)


putNet

public boolean putNet(java.lang.String s)
write a message to the net

Parameters:
s - the message
Returns:
true if the message was sent, false if not

putLocal

public boolean putLocal(java.lang.String s)
write a message to the local server

Parameters:
s - the message
Returns:
true if the message was sent, false if not

put

public boolean put(java.lang.String s,
                   boolean isLocal)
Write a message to the net or local server. Because the player can be in both network games and local games, we must route to the appropriate client-server connection.

Parameters:
s - the message
isLocal - Is the server local (practice game), or network?
Returns:
true if the message was sent, false if not

treat

public void treat(SOCMessage mes,
                  boolean isLocal)
Treat the incoming messages. Messages of unknown type are ignored (mes will be null from SOCMessage.toMsg(String)).

Parameters:
mes - the message
isLocal - Server is local (practice game, not network)

handleVERSION

private void handleVERSION(boolean isLocal,
                           SOCVersion mes)
Handle the "version" message, server's version report. Reply with client's version.

Parameters:
isLocal - Is the server local, or remote? Client can be connected only to local, or remote.
mes - the messsage

handleSTATUSMESSAGE

protected void handleSTATUSMESSAGE(SOCStatusMessage mes)
handle the "status message" message. Used for server events, also used if player tries to join a game but their nickname is not OK.

Parameters:
mes - the message

handleJOINAUTH

protected void handleJOINAUTH(SOCJoinAuth mes)
handle the "join authorization" message

Parameters:
mes - the message

handleJOIN

protected void handleJOIN(SOCJoin mes)
handle the "join channel" message

Parameters:
mes - the message

handleMEMBERS

protected void handleMEMBERS(SOCMembers mes)
handle the "members" message

Parameters:
mes - the message

handleNEWCHANNEL

protected void handleNEWCHANNEL(SOCNewChannel mes)
handle the "new channel" message

Parameters:
mes - the message

handleCHANNELS

protected void handleCHANNELS(SOCChannels mes,
                              boolean isLocal)
handle the "list of channels" message; this message indicates that we're newly connected to the server.

Parameters:
mes - the message
isLocal - is the server actually local (practice game)?

handleBCASTTEXTMSG

protected void handleBCASTTEXTMSG(SOCBCastTextMsg mes)
handle a broadcast text message

Parameters:
mes - the message

handleTEXTMSG

protected void handleTEXTMSG(SOCTextMsg mes)
handle a text message

Parameters:
mes - the message

handleLEAVE

protected void handleLEAVE(SOCLeave mes)
handle the "leave channel" message

Parameters:
mes - the message

handleDELETECHANNEL

protected void handleDELETECHANNEL(SOCDeleteChannel mes)
handle the "delete channel" message

Parameters:
mes - the message

handleGAMES

protected void handleGAMES(SOCGames mes)
handle the "list of games" message

Parameters:
mes - the message

handleJOINGAMEAUTH

protected void handleJOINGAMEAUTH(SOCJoinGameAuth mes,
                                  boolean isLocal)
handle the "join game authorization" message

Parameters:
mes - the message
isLocal - server is local for practice (vs. normal network)

handleJOINGAME

protected void handleJOINGAME(SOCJoinGame mes)
handle the "join game" message

Parameters:
mes - the message

handleLEAVEGAME

protected void handleLEAVEGAME(SOCLeaveGame mes)
handle the "leave game" message

Parameters:
mes - the message

handleNEWGAME

protected void handleNEWGAME(SOCNewGame mes)
handle the "new game" message

Parameters:
mes - the message

handleDELETEGAME

protected void handleDELETEGAME(SOCDeleteGame mes)
handle the "delete game" message

Parameters:
mes - the message

handleGAMEMEMBERS

protected void handleGAMEMEMBERS(SOCGameMembers mes)
handle the "game members" message

Parameters:
mes - the message

handleGAMESTATS

protected void handleGAMESTATS(SOCGameStats mes)
handle the "game stats" message


handleGAMETEXTMSG

protected void handleGAMETEXTMSG(SOCGameTextMsg mes)
handle the "game text message" message. Messages not from Server go to the chat area. Messages from Server go to the game text window. Urgent messages from Server (starting with ">>>") also go to the chat area, which has less activity, so they are harder to miss.

Parameters:
mes - the message

handleSITDOWN

protected void handleSITDOWN(SOCSitDown mes)
handle the "player sitting down" message

Parameters:
mes - the message

handleBOARDLAYOUT

protected void handleBOARDLAYOUT(SOCBoardLayout mes)
handle the "board layout" message

Parameters:
mes - the message

handleSTARTGAME

protected void handleSTARTGAME(SOCStartGame mes)
handle the "start game" message

Parameters:
mes - the message

handleGAMESTATE

protected void handleGAMESTATE(SOCGameState mes)
handle the "game state" message

Parameters:
mes - the message

handleSETTURN

protected void handleSETTURN(SOCSetTurn mes)
handle the "set turn" message

Parameters:
mes - the message

handleFIRSTPLAYER

protected void handleFIRSTPLAYER(SOCFirstPlayer mes)
handle the "first player" message

Parameters:
mes - the message

handleTURN

protected void handleTURN(SOCTurn mes)
handle the "turn" message

Parameters:
mes - the message

handlePLAYERELEMENT

protected void handlePLAYERELEMENT(SOCPlayerElement mes)
handle the "player information" message

Parameters:
mes - the message

handleRESOURCECOUNT

protected void handleRESOURCECOUNT(SOCResourceCount mes)
handle "resource count" message

Parameters:
mes - the message

handleDICERESULT

protected void handleDICERESULT(SOCDiceResult mes)
handle the "dice result" message

Parameters:
mes - the message

handlePUTPIECE

protected void handlePUTPIECE(SOCPutPiece mes)
handle the "put piece" message

Parameters:
mes - the message

handleCANCELBUILDREQUEST

protected void handleCANCELBUILDREQUEST(SOCCancelBuildRequest mes)
handle the rare "cancel build request" message; usually not sent from server to client.

- When sent from client to server, CANCELBUILDREQUEST means the player has changed their mind about spending resources to build a piece. Only allowed during normal game play (PLACING_ROAD, PLACING_SETTLEMENT, or PLACING_CITY).

When sent from server to client:

- During game startup (START1B or START2B):
Sent from server, CANCELBUILDREQUEST means the current player wants to undo the placement of their initial settlement.

- During piece placement (PLACING_ROAD, PLACING_CITY, PLACING_SETTLEMENT, PLACING_FREE_ROAD1 or PLACING_FREE_ROAD2):

Sent from server, CANCELBUILDREQUEST means the player has sent an illegal PUTPIECE (bad building location). Humans can probably decide a better place to put their road, but robots must cancel the build request and decide on a new plan.

Our client can ignore this case, because the server also sends a text message that the human player is capable of reading and acting on.

Parameters:
mes - the message

handleMOVEROBBER

protected void handleMOVEROBBER(SOCMoveRobber mes)
handle the "robber moved" message

Parameters:
mes - the message

handleDISCARDREQUEST

protected void handleDISCARDREQUEST(SOCDiscardRequest mes)
handle the "discard request" message

Parameters:
mes - the message

handleCHOOSEPLAYERREQUEST

protected void handleCHOOSEPLAYERREQUEST(SOCChoosePlayerRequest mes)
handle the "choose player request" message

Parameters:
mes - the message

handleMAKEOFFER

protected void handleMAKEOFFER(SOCMakeOffer mes)
handle the "make offer" message

Parameters:
mes - the message

handleCLEAROFFER

protected void handleCLEAROFFER(SOCClearOffer mes)
handle the "clear offer" message

Parameters:
mes - the message

handleREJECTOFFER

protected void handleREJECTOFFER(SOCRejectOffer mes)
handle the "reject offer" message

Parameters:
mes - the message

handleCLEARTRADEMSG

protected void handleCLEARTRADEMSG(SOCClearTradeMsg mes)
handle the "clear trade message" message

Parameters:
mes - the message

handleDEVCARDCOUNT

protected void handleDEVCARDCOUNT(SOCDevCardCount mes)
handle the "number of development cards" message

Parameters:
mes - the message

handleDEVCARD

protected void handleDEVCARD(SOCDevCard mes)
handle the "development card action" message

Parameters:
mes - the message

handleSETPLAYEDDEVCARD

protected void handleSETPLAYEDDEVCARD(SOCSetPlayedDevCard mes)
handle the "set played dev card flag" message

Parameters:
mes - the message

handlePOTENTIALSETTLEMENTS

protected void handlePOTENTIALSETTLEMENTS(SOCPotentialSettlements mes)
handle the "list of potential settlements" message

Parameters:
mes - the message

handleCHANGEFACE

protected void handleCHANGEFACE(SOCChangeFace mes)
handle the "change face" message

Parameters:
mes - the message

handleREJECTCONNECTION

protected void handleREJECTCONNECTION(SOCRejectConnection mes)
handle the "reject connection" message

Parameters:
mes - the message

handleLONGESTROAD

protected void handleLONGESTROAD(SOCLongestRoad mes)
handle the "longest road" message

Parameters:
mes - the message

handleLARGESTARMY

protected void handleLARGESTARMY(SOCLargestArmy mes)
handle the "largest army" message

Parameters:
mes - the message

handleSETSEATLOCK

protected void handleSETSEATLOCK(SOCSetSeatLock mes)
handle the "set seat lock" message

Parameters:
mes - the message

handleROLLDICEPROMPT

protected void handleROLLDICEPROMPT(SOCRollDicePrompt mes)
handle the "roll dice prompt" message; if we're in a game and we're the dice roller, either set the auto-roll timer, or prompt to roll or choose card.

Parameters:
mes - the message

handleRESETBOARDAUTH

protected void handleRESETBOARDAUTH(SOCResetBoardAuth mes)
handle board reset (new game with same players, same game name, new layout). Create new Game object, destroy old one. For human players, the reset message will be followed with others which will fill in the game state. For robots, they must discard game state and ask to re-join.

Parameters:
mes - the message
See Also:
SOCServer.resetBoardAndNotify(String, int), SOCGame.resetAsCopy()

handleRESETBOARDVOTEREQUEST

protected void handleRESETBOARDVOTEREQUEST(SOCResetBoardVoteRequest mes)
a player is requesting a board reset: we must update local game state, and vote unless we are the requester.

Parameters:
mes - the message

handleRESETBOARDVOTE

protected void handleRESETBOARDVOTE(SOCResetBoardVote mes)
another player has voted on a board reset request: display the vote.

Parameters:
mes - the message

handleRESETBOARDREJECT

protected void handleRESETBOARDREJECT(SOCResetBoardReject mes)
voting complete, board reset request rejected

Parameters:
mes - the message

addToGameList

public void addToGameList(java.lang.String gameName)
add a new game to the initial window's list of games

Parameters:
gameName - the game name to add to the list

addToList

public void addToList(java.lang.String thing,
                      java.awt.List lst)
add a new channel or game, put it in the list in alphabetical order

Parameters:
thing - the thing to add to the list
lst - the list

updateGameStats

public void updateGameStats(java.lang.String gameName,
                            int[] scores,
                            boolean[] robots)
Update this game's stats in the game list display.

Parameters:
gameName - Name of game to update
scores - Each player position's score
robots - Is this position a robot?
See Also:
SOCGameStats

updateGameEndStats

public void updateGameEndStats(java.lang.String game,
                               int[] scores)
If we're playing in a game that's just finished, update the scores. This is used to show the true scores, including hidden victory-point cards, at the game's end.


deleteFromGameList

public void deleteFromGameList(java.lang.String gameName)
delete a game from the list

Parameters:
gameName - the game to remove

deleteFromList

public void deleteFromList(java.lang.String thing,
                           java.awt.List lst)
delete a group

Parameters:
thing - the thing to remove
lst - the list

chSend

public void chSend(java.lang.String ch,
                   java.lang.String mes)
send a text message to a channel

Parameters:
ch - the name of the channel
mes - the message

leaveChannel

public void leaveChannel(java.lang.String ch)
the user leaves the given channel

Parameters:
ch - the name of the channel

disconnect

protected void disconnect()
disconnect from the net


buyDevCard

public void buyDevCard(SOCGame ga)
request to buy a development card

Parameters:
ga - the game

buildRequest

public void buildRequest(SOCGame ga,
                         int piece)
request to build something

Parameters:
ga - the game
piece - the type of piece from SOCPlayingPiece

cancelBuildRequest

public void cancelBuildRequest(SOCGame ga,
                               int piece)
request to cancel building something

Parameters:
ga - the game
piece - the type of piece from SOCPlayingPiece

putPiece

public void putPiece(SOCGame ga,
                     SOCPlayingPiece pp)
put a piece on the board

Parameters:
ga - the game where the action is taking place
pp - the piece being placed

moveRobber

public void moveRobber(SOCGame ga,
                       SOCPlayer pl,
                       int coord)
the player wants to move the robber

Parameters:
ga - the game
pl - the player
coord - where the player wants the robber

sendText

public void sendText(SOCGame ga,
                     java.lang.String me)
send a text message to the people in the game

Parameters:
ga - the game
me - the message

leaveGame

public void leaveGame(SOCGame ga)
the user leaves the given game

Parameters:
ga - the game

sitDown

public void sitDown(SOCGame ga,
                    int pn)
the user sits down to play

Parameters:
ga - the game
pn - the number of the seat where the user wants to sit

startGame

public void startGame(SOCGame ga)
the user is starting the game

Parameters:
ga - the game

rollDice

public void rollDice(SOCGame ga)
the user rolls the dice

Parameters:
ga - the game

endTurn

public void endTurn(SOCGame ga)
the user is done with the turn

Parameters:
ga - the game

discard

public void discard(SOCGame ga,
                    SOCResourceSet rs)
the user wants to discard

Parameters:
ga - the game

choosePlayer

public void choosePlayer(SOCGame ga,
                         int pn)
the user chose a player to steal from

Parameters:
ga - the game
pn - the player id

rejectOffer

public void rejectOffer(SOCGame ga)
the user is rejecting the current offers

Parameters:
ga - the game

acceptOffer

public void acceptOffer(SOCGame ga,
                        int from)
the user is accepting an offer

Parameters:
ga - the game
from - the number of the player that is making the offer

clearOffer

public void clearOffer(SOCGame ga)
the user is clearing an offer

Parameters:
ga - the game

bankTrade

public void bankTrade(SOCGame ga,
                      SOCResourceSet give,
                      SOCResourceSet get)
the user wants to trade with the bank

Parameters:
ga - the game
give - what is being offered
get - what the player wants

offerTrade

public void offerTrade(SOCGame ga,
                       SOCTradeOffer offer)
the user is making an offer to trade

Parameters:
ga - the game
offer - the trade offer

playDevCard

public void playDevCard(SOCGame ga,
                        int dc)
the user wants to play a development card

Parameters:
ga - the game
dc - the type of development card

discoveryPick

public void discoveryPick(SOCGame ga,
                          SOCResourceSet rscs)
the user picked 2 resources to discover

Parameters:
ga - the game
rscs - the resources

monopolyPick

public void monopolyPick(SOCGame ga,
                         int res)
the user picked a resource to monopolize

Parameters:
ga - the game
res - the resource

changeFace

public void changeFace(SOCGame ga,
                       int id)
the user is changing the face image

Parameters:
ga - the game
id - the image id

lockSeat

public void lockSeat(SOCGame ga,
                     int pn)
the user is locking a seat

Parameters:
ga - the game
pn - the seat number

unlockSeat

public void unlockSeat(SOCGame ga,
                       int pn)
the user is unlocking a seat

Parameters:
ga - the game
pn - the seat number

resetBoardRequest

public void resetBoardRequest(SOCGame ga)
Player wants to request to reset the board (same players, new game, new layout). Send SOCResetBoardRequest to server; it will either respond with a SOCResetBoardAuth message, or will tell other players to vote yes/no on the request. Before calling, check player.hasAskedBoardReset() and game.getResetVoteActive().


resetBoardVote

public void resetBoardVote(SOCGame ga,
                           int pn,
                           boolean voteYes)
Player is responding to a board-reset vote from another player. Send SOCResetBoardRequest to server; it will either respond with a SOCResetBoardAuth message, or will tell other players to vote yes/no on the request.

Parameters:
ga - Game to vote on
pn - Player number of our player who is voting
voteYes - If true, this player votes yes; if false, no

doLocalCommand

public boolean doLocalCommand(java.lang.String ch,
                              java.lang.String cmd)
handle local client commands for channels

Returns:
true if a command was handled

doLocalCommand

public boolean doLocalCommand(SOCGame ga,
                              java.lang.String cmd)
handle local client commands for games

Returns:
true if a command was handled

onIgnoreList

protected boolean onIgnoreList(java.lang.String name)
Returns:
true if name is on the ignore list

addToIgnoreList

protected void addToIgnoreList(java.lang.String name)
add this name to the ignore list

Parameters:
name - the name to add

removeFromIgnoreList

protected void removeFromIgnoreList(java.lang.String name)
remove this name from the ignore list

Parameters:
name - the name to remove

printIgnoreList

protected void printIgnoreList(ChannelFrame fr)
Print the current chat ignorelist in a channel.


printIgnoreList

protected void printIgnoreList(SOCPlayerInterface pi)
Print the current chat ignorelist in a playerinterface.


considerMove

public void considerMove(SOCGame ga,
                         java.lang.String pname,
                         SOCPlayingPiece piece)
send a command to the server with a message asking a robot to show the debug info for a possible move after a move has been made

Parameters:
ga - the game
pname - the robot name
piece - the piece to consider

considerTarget

public void considerTarget(SOCGame ga,
                           java.lang.String pname,
                           SOCPlayingPiece piece)
send a command to the server with a message asking a robot to show the debug info for a possible move before a move has been made

Parameters:
ga - the game
pname - the robot name
piece - the piece to consider

startPracticeGame

public void startPracticeGame()
Create a game name, and start a practice game. Assumes MAIN_PANEL is initialized.


startPracticeGame

public void startPracticeGame(java.lang.String practiceGameName,
                              boolean mainPanelIsActive)
Setup for local practice game (local server). If needed, a local server, client, and robots are started.

Parameters:
practiceGameName - Unique name to give practice game; if name unknown, call startPracticeGame() instead
mainPanelIsActive - Is the SOCPlayerClient main panel active? False if we're being called from elsewhere, such as SOCConnectOrPracticePanel.

startLocalTCPServer

public void startLocalTCPServer(int tport)
                         throws java.lang.IllegalArgumentException
Setup for locally hosting a TCP server. If needed, a local server and robots are started, and client connects to it. If parent is a Frame, set titlebar to show "server" and port#. Show port number in localTCPPortLabel. If the localTCPServer is already created, does nothing. If connected already, does nothing.

Parameters:
tport - Port number to host on; must be greater than zero.
Throws:
java.lang.IllegalArgumentException - If port is 0 or negative

setupLocalRobots

public void setupLocalRobots(int port)
Set up some robot opponents for a locally running server (tcp or stringport). This lets the server randomize whether we play against smart or fast ones. (Some will be SOCRobotDM.FAST_STRATEGY, some SMART_STRATEGY). If the local server is stringport, it must be running as SOCServer.PRACTICE_STRINGPORT.

Parameters:
port - Port number for tcp, or 0 for stringport
See Also:
startPracticeGame(), startLocalTCPServer(int)

getServerVersion

public int getServerVersion()
Server version, assuming we're connected to a remote server. Returns -1 if unknown.

Returns:
Server version, format like Version.versionNumber(), or 0 or -1.

getAppletInfo

public java.lang.String getAppletInfo()
applet info


destroy

public void destroy()
network trouble; if possible, ask if they want to play locally (robots). Otherwise, go ahead and destroy the applet.


putLeaveAll

public boolean putLeaveAll()
For shutdown - Tell the server we're leaving all games. If we've started a local practice server, also tell that server. If we've started a TCP server, tell all players on that server, and shut it down.

Since no other state variables are set, call this only right before discarding this object or calling System.exit.

Returns:
Can we still start local games? (No local exception yet in ex_L)

usage

public static void usage()
for stand-alones


main

public static void main(java.lang.String[] args)
for stand-alones


createWindowAdapter

private java.awt.event.WindowAdapter createWindowAdapter()