|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
soc.client.SOCPlayerClient
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.
| 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 |
protected static final java.lang.String MAIN_PANEL
protected static final java.lang.String MESSAGE_PANEL
protected static final java.lang.String CONNECT_OR_PRACTICE_PANEL
public static final int SOC_PORT_DEFAULT
protected static java.lang.String STATSPREFEX
protected java.awt.TextField nick
protected java.awt.TextField pass
protected java.awt.TextField status
protected java.awt.TextField channel
protected java.awt.TextField game
protected java.awt.List chlist
protected java.awt.List gmlist
protected java.awt.Button jc
protected java.awt.Button jg
protected java.awt.Button pg
protected java.awt.Label messageLabel
protected java.awt.Label messageLabel_top
protected java.awt.Label localTCPPortLabel
protected java.awt.Button pgm
protected java.applet.AppletContext ac
protected java.lang.String lastMessage_N
protected java.lang.String lastMessage_L
protected java.awt.CardLayout cardLayout
MAIN_PANEL, MESSAGE_PANEL or
(if launched from jar, or with no command-line arguments)
CONNECT_OR_PRACTICE_PANEL.
hasConnectOrPracticeprotected java.lang.String host
protected int port
protected java.net.Socket s
protected java.io.DataInputStream in
protected java.io.DataOutputStream out
protected java.lang.Thread reader
protected java.lang.Exception ex
protected java.lang.Exception ex_L
protected boolean connected
protected int sVersion
protected int sLocalVersion
protected boolean hasJoinedServer
protected boolean hasConnectOrPractice
SOCConnectOrPracticePanel.
cardLayoutprotected SOCConnectOrPracticePanel connectOrPracticePane
initVisualElements().
hasConnectOrPracticepublic static java.lang.String DEFAULT_PLAYER_NAME
public static java.lang.String DEFAULT_PRACTICE_GAMENAME
public static java.lang.String NET_UNAVAIL_CAN_PRACTICE_MSG
public static java.lang.String NEED_NICKNAME_BEFORE_JOIN
NEED_NICKNAME_BEFORE_JOIN_2public static java.lang.String NEED_NICKNAME_BEFORE_JOIN_2
NEED_NICKNAME_BEFORE_JOINprotected java.lang.String nickname
protected java.lang.String password
protected boolean gotPassword
protected int lastFaceChange
protected java.util.Hashtable channels
protected java.util.Hashtable games
protected java.util.Hashtable playerInterfaces
protected java.util.Vector ignoreList
protected SOCServer practiceServer
prCli
protected StringConnection prCli
practiceServer
protected int numPracticeGames
protected SOCServer localTCPServer
practiceServer may still be activated at the user's request.
| Constructor Detail |
public SOCPlayerClient()
SOC_PORT_DEFAULT
public SOCPlayerClient(boolean cp)
SOC_PORT_DEFAULT,
or initially showing 'Connect or Practice' panel.
cp - If true, start by showing 'Connect or Practice' panel,
instead of connecting to localhost port.
public SOCPlayerClient(java.lang.String h,
int p)
h - host, or null for localhostp - port
public SOCPlayerClient(java.lang.String h,
int p,
boolean cp)
h - host, or null for localhostp - portcp - If true, start by showing 'Connect or Practice' panel,
instead of connecting to host and port.| Method Detail |
protected void initVisualElements()
public int getHexParameter(java.lang.String name)
name - a parameter name. null is ignored
public void start()
public void init()
public void connect(java.lang.String chost,
int cport,
java.lang.String cuser,
java.lang.String cpass)
chost - Hostname to connect to, or null for localhostcport - Port number to connect tocuser - User nicknamecpass - User optional passwordpublic void connect()
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).
java.lang.IllegalStateException - if already connectedSOCServer.newConnection1(StringConnection)public java.lang.String getNickname()
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenerpublic void clickPracticeButton()
private void guardedActionPerform(java.lang.Object target)
target - Action source, from ActionEvent.getSource()protected SOCPlayerInterface findAnyActiveGame(boolean fromPracticeServer)
fromPracticeServer - Enumerate games from practiceServer,
instead of playerInterfaces?
anyHostedActiveGames()protected boolean anyHostedActiveGames()
findAnyActiveGame(boolean)public void run()
run in interface java.lang.Runnablepublic void resendNet()
public void resendLocal()
public boolean putNet(java.lang.String s)
s - the message
public boolean putLocal(java.lang.String s)
s - the message
public boolean put(java.lang.String s,
boolean isLocal)
s - the messageisLocal - Is the server local (practice game), or network?
public void treat(SOCMessage mes,
boolean isLocal)
SOCMessage.toMsg(String)).
mes - the messageisLocal - Server is local (practice game, not network)
private void handleVERSION(boolean isLocal,
SOCVersion mes)
isLocal - Is the server local, or remote? Client can be connected
only to local, or remote.mes - the messsageprotected void handleSTATUSMESSAGE(SOCStatusMessage mes)
mes - the messageprotected void handleJOINAUTH(SOCJoinAuth mes)
mes - the messageprotected void handleJOIN(SOCJoin mes)
mes - the messageprotected void handleMEMBERS(SOCMembers mes)
mes - the messageprotected void handleNEWCHANNEL(SOCNewChannel mes)
mes - the message
protected void handleCHANNELS(SOCChannels mes,
boolean isLocal)
mes - the messageisLocal - is the server actually local (practice game)?protected void handleBCASTTEXTMSG(SOCBCastTextMsg mes)
mes - the messageprotected void handleTEXTMSG(SOCTextMsg mes)
mes - the messageprotected void handleLEAVE(SOCLeave mes)
mes - the messageprotected void handleDELETECHANNEL(SOCDeleteChannel mes)
mes - the messageprotected void handleGAMES(SOCGames mes)
mes - the message
protected void handleJOINGAMEAUTH(SOCJoinGameAuth mes,
boolean isLocal)
mes - the messageisLocal - server is local for practice (vs. normal network)protected void handleJOINGAME(SOCJoinGame mes)
mes - the messageprotected void handleLEAVEGAME(SOCLeaveGame mes)
mes - the messageprotected void handleNEWGAME(SOCNewGame mes)
mes - the messageprotected void handleDELETEGAME(SOCDeleteGame mes)
mes - the messageprotected void handleGAMEMEMBERS(SOCGameMembers mes)
mes - the messageprotected void handleGAMESTATS(SOCGameStats mes)
protected void handleGAMETEXTMSG(SOCGameTextMsg mes)
mes - the messageprotected void handleSITDOWN(SOCSitDown mes)
mes - the messageprotected void handleBOARDLAYOUT(SOCBoardLayout mes)
mes - the messageprotected void handleSTARTGAME(SOCStartGame mes)
mes - the messageprotected void handleGAMESTATE(SOCGameState mes)
mes - the messageprotected void handleSETTURN(SOCSetTurn mes)
mes - the messageprotected void handleFIRSTPLAYER(SOCFirstPlayer mes)
mes - the messageprotected void handleTURN(SOCTurn mes)
mes - the messageprotected void handlePLAYERELEMENT(SOCPlayerElement mes)
mes - the messageprotected void handleRESOURCECOUNT(SOCResourceCount mes)
mes - the messageprotected void handleDICERESULT(SOCDiceResult mes)
mes - the messageprotected void handlePUTPIECE(SOCPutPiece mes)
mes - the messageprotected void handleCANCELBUILDREQUEST(SOCCancelBuildRequest mes)
- 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.
mes - the messageprotected void handleMOVEROBBER(SOCMoveRobber mes)
mes - the messageprotected void handleDISCARDREQUEST(SOCDiscardRequest mes)
mes - the messageprotected void handleCHOOSEPLAYERREQUEST(SOCChoosePlayerRequest mes)
mes - the messageprotected void handleMAKEOFFER(SOCMakeOffer mes)
mes - the messageprotected void handleCLEAROFFER(SOCClearOffer mes)
mes - the messageprotected void handleREJECTOFFER(SOCRejectOffer mes)
mes - the messageprotected void handleCLEARTRADEMSG(SOCClearTradeMsg mes)
mes - the messageprotected void handleDEVCARDCOUNT(SOCDevCardCount mes)
mes - the messageprotected void handleDEVCARD(SOCDevCard mes)
mes - the messageprotected void handleSETPLAYEDDEVCARD(SOCSetPlayedDevCard mes)
mes - the messageprotected void handlePOTENTIALSETTLEMENTS(SOCPotentialSettlements mes)
mes - the messageprotected void handleCHANGEFACE(SOCChangeFace mes)
mes - the messageprotected void handleREJECTCONNECTION(SOCRejectConnection mes)
mes - the messageprotected void handleLONGESTROAD(SOCLongestRoad mes)
mes - the messageprotected void handleLARGESTARMY(SOCLargestArmy mes)
mes - the messageprotected void handleSETSEATLOCK(SOCSetSeatLock mes)
mes - the messageprotected void handleROLLDICEPROMPT(SOCRollDicePrompt mes)
mes - the messageprotected void handleRESETBOARDAUTH(SOCResetBoardAuth mes)
mes - the messageSOCServer.resetBoardAndNotify(String, int),
SOCGame.resetAsCopy()protected void handleRESETBOARDVOTEREQUEST(SOCResetBoardVoteRequest mes)
mes - the messageprotected void handleRESETBOARDVOTE(SOCResetBoardVote mes)
mes - the messageprotected void handleRESETBOARDREJECT(SOCResetBoardReject mes)
mes - the messagepublic void addToGameList(java.lang.String gameName)
gameName - the game name to add to the list
public void addToList(java.lang.String thing,
java.awt.List lst)
thing - the thing to add to the listlst - the list
public void updateGameStats(java.lang.String gameName,
int[] scores,
boolean[] robots)
gameName - Name of game to updatescores - Each player position's scorerobots - Is this position a robot?SOCGameStats
public void updateGameEndStats(java.lang.String game,
int[] scores)
public void deleteFromGameList(java.lang.String gameName)
gameName - the game to remove
public void deleteFromList(java.lang.String thing,
java.awt.List lst)
thing - the thing to removelst - the list
public void chSend(java.lang.String ch,
java.lang.String mes)
ch - the name of the channelmes - the messagepublic void leaveChannel(java.lang.String ch)
ch - the name of the channelprotected void disconnect()
public void buyDevCard(SOCGame ga)
ga - the game
public void buildRequest(SOCGame ga,
int piece)
ga - the gamepiece - the type of piece from SOCPlayingPiece
public void cancelBuildRequest(SOCGame ga,
int piece)
ga - the gamepiece - the type of piece from SOCPlayingPiece
public void putPiece(SOCGame ga,
SOCPlayingPiece pp)
ga - the game where the action is taking placepp - the piece being placed
public void moveRobber(SOCGame ga,
SOCPlayer pl,
int coord)
ga - the gamepl - the playercoord - where the player wants the robber
public void sendText(SOCGame ga,
java.lang.String me)
ga - the gameme - the messagepublic void leaveGame(SOCGame ga)
ga - the game
public void sitDown(SOCGame ga,
int pn)
ga - the gamepn - the number of the seat where the user wants to sitpublic void startGame(SOCGame ga)
ga - the gamepublic void rollDice(SOCGame ga)
ga - the gamepublic void endTurn(SOCGame ga)
ga - the game
public void discard(SOCGame ga,
SOCResourceSet rs)
ga - the game
public void choosePlayer(SOCGame ga,
int pn)
ga - the gamepn - the player idpublic void rejectOffer(SOCGame ga)
ga - the game
public void acceptOffer(SOCGame ga,
int from)
ga - the gamefrom - the number of the player that is making the offerpublic void clearOffer(SOCGame ga)
ga - the game
public void bankTrade(SOCGame ga,
SOCResourceSet give,
SOCResourceSet get)
ga - the gamegive - what is being offeredget - what the player wants
public void offerTrade(SOCGame ga,
SOCTradeOffer offer)
ga - the gameoffer - the trade offer
public void playDevCard(SOCGame ga,
int dc)
ga - the gamedc - the type of development card
public void discoveryPick(SOCGame ga,
SOCResourceSet rscs)
ga - the gamerscs - the resources
public void monopolyPick(SOCGame ga,
int res)
ga - the gameres - the resource
public void changeFace(SOCGame ga,
int id)
ga - the gameid - the image id
public void lockSeat(SOCGame ga,
int pn)
ga - the gamepn - the seat number
public void unlockSeat(SOCGame ga,
int pn)
ga - the gamepn - the seat numberpublic void resetBoardRequest(SOCGame ga)
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().
public void resetBoardVote(SOCGame ga,
int pn,
boolean voteYes)
SOCResetBoardRequest to server;
it will either respond with a
SOCResetBoardAuth message,
or will tell other players to vote yes/no on the request.
ga - Game to vote onpn - Player number of our player who is votingvoteYes - If true, this player votes yes; if false, no
public boolean doLocalCommand(java.lang.String ch,
java.lang.String cmd)
public boolean doLocalCommand(SOCGame ga,
java.lang.String cmd)
protected boolean onIgnoreList(java.lang.String name)
protected void addToIgnoreList(java.lang.String name)
name - the name to addprotected void removeFromIgnoreList(java.lang.String name)
name - the name to removeprotected void printIgnoreList(ChannelFrame fr)
protected void printIgnoreList(SOCPlayerInterface pi)
public void considerMove(SOCGame ga,
java.lang.String pname,
SOCPlayingPiece piece)
ga - the gamepname - the robot namepiece - the piece to consider
public void considerTarget(SOCGame ga,
java.lang.String pname,
SOCPlayingPiece piece)
ga - the gamepname - the robot namepiece - the piece to considerpublic void startPracticeGame()
MAIN_PANEL is initialized.
public void startPracticeGame(java.lang.String practiceGameName,
boolean mainPanelIsActive)
practiceGameName - Unique name to give practice game; if name unknown, call
startPracticeGame() insteadmainPanelIsActive - Is the SOCPlayerClient main panel active?
False if we're being called from elsewhere, such as
SOCConnectOrPracticePanel.
public void startLocalTCPServer(int tport)
throws java.lang.IllegalArgumentException
localTCPPortLabel.
If the localTCPServer is already created, does nothing.
If connected already, does nothing.
tport - Port number to host on; must be greater than zero.
java.lang.IllegalArgumentException - If port is 0 or negativepublic void setupLocalRobots(int port)
SOCServer.PRACTICE_STRINGPORT.
port - Port number for tcp, or 0 for stringportstartPracticeGame(),
startLocalTCPServer(int)public int getServerVersion()
Version.versionNumber(),
or 0 or -1.public java.lang.String getAppletInfo()
public void destroy()
public boolean putLeaveAll()
Since no other state variables are set, call this only right before discarding this object or calling System.exit.
ex_L)public static void usage()
public static void main(java.lang.String[] args)
private java.awt.event.WindowAdapter createWindowAdapter()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||