soc.message
Class SOCNewGameWithOptionsRequest

java.lang.Object
  extended by soc.message.SOCMessage
      extended by soc.message.SOCMessageTemplateJoinGame
          extended by soc.message.SOCNewGameWithOptionsRequest
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SOCNewGameWithOptionsRequest
extends SOCMessageTemplateJoinGame

This message means that client wants to create a new game, with options; needs same username/password options as JOINGAME. Server's reply, if it can create the game, is a broadcast SOCNewGameWithOptions.

Once the client has successfully joined or created a game or channel, the password field can be left blank in later join/create requests. All server versions ignore the password field after a successful request.

Introduced in 1.1.07; check server version against SOCNewGameWithOptions.VERSION_FOR_NEWGAMEWITHOPTIONS before sending this message. Older servers should be given JOINGAME instead.

Some game options have the SOCGameOption.FLAG_INTERNAL_GAME_PROPERTY flag. The client should not send these as part of a new-game request message, and the server should ignore them if it does. The server may send out such options, as part of a game it has created, in a SOCNewGameWithOptions message.

Robot clients don't need to know about or handle this message type, because they don't create games.

Since:
1.1.07
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
Serialized Form

Field Summary
private  java.util.Map<java.lang.String,SOCGameOption> opts
          may be null
private  java.lang.String optsStr
          won't be null, even if opts is null, due to SOCGameOption.packOptionsToString(Map, boolean) format.
private static long serialVersionUID
           
 
Fields inherited from class soc.message.SOCMessageTemplateJoinGame
game, host, nickname, NULLPASS, password
 
Fields inherited from class soc.message.SOCMessage
ACCEPTOFFER, ADMINPING, ADMINRESET, AUTHREQUEST, BANKTRADE, BCASTTEXTMSG, BOARDLAYOUT, BOARDLAYOUT2, BOARDSPECIALEDGE, BUILDREQUEST, BUYCARDREQUEST, CANCELBUILDREQUEST, CHANGEFACE, CHANNELS, CHOOSEPLAYER, CHOOSEPLAYERREQUEST, CLEAROFFER, CLEARTRADEMSG, CREATEACCOUNT, DEBUGFREEPLACE, DELETECHANNEL, DELETEGAME, DEVCARDACTION, DEVCARDCOUNT, DICERESULT, DICERESULTRESOURCES, DISCARD, DISCARDREQUEST, DISCOVERYPICK, ENDTURN, FIRSTPLAYER, GAME_NONE, GAMEMEMBERS, GAMEOPTIONGETDEFAULTS, GAMEOPTIONGETINFOS, GAMEOPTIONINFO, GAMES, GAMESERVERTEXT, GAMESTATE, GAMESTATS, GAMESWITHOPTIONS, GAMETEXTMSG, IMAROBOT, INVENTORYITEMACTION, JOIN, JOINAUTH, JOINGAME, JOINGAMEAUTH, LARGESTARMY, LASTSETTLEMENT, LEAVE, LEAVEALL, LEAVEGAME, LEGALEDGES, LOCALIZEDSTRINGS, LONGESTROAD, MAKEOFFER, MEMBERS, messageType, MONOPOLYPICK, MOVEPIECE, MOVEPIECEREQUEST, MOVEROBBER, NEWCHANNEL, NEWGAME, NEWGAMEWITHOPTIONS, NEWGAMEWITHOPTIONSREQUEST, NULLMESSAGE, PICKRESOURCES, PICKRESOURCESREQUEST, PIECEVALUE, PLAYDEVCARDREQUEST, PLAYERELEMENT, PLAYERELEMENTS, PLAYERSTATS, POTENTIALSETTLEMENTS, PUTPIECE, REJECTCONNECTION, REJECTOFFER, REMOVEPIECE, RESETBOARDAUTH, RESETBOARDREJECT, RESETBOARDREQUEST, RESETBOARDVOTE, RESETBOARDVOTEREQUEST, RESOURCECOUNT, REVEALFOGHEX, ROBOTDISMISS, ROBOTJOINGAMEREQUEST, ROLLDICE, ROLLDICEPROMPT, ROLLDICEREQUEST, SCENARIOINFO, sep, sep_char, sep2, sep2_char, SERVERPING, SETPLAYEDDEVCARD, SETSEATLOCK, SETSPECIALITEM, SETTURN, SETUPDONE, SIMPLEACTION, SIMPLEREQUEST, SITDOWN, STARTGAME, STATUSMESSAGE, SVPTEXTMSG, TEXTMSG, TIMINGPING, TURN, UPDATEROBOTPARAMS, VERSION
 
Constructor Summary
SOCNewGameWithOptionsRequest(java.lang.String nn, java.lang.String pw, java.lang.String hn, java.lang.String ga, java.util.Map<java.lang.String,SOCGameOption> opts)
          Create a NewGameWithOptionsRequest message.
SOCNewGameWithOptionsRequest(java.lang.String nn, java.lang.String pw, java.lang.String hn, java.lang.String ga, java.lang.String optstr)
          Create a NewGameWithOptionsRequest message.
 
Method Summary
 int getMinimumVersion()
          Minimum version where this message type is used.
 java.util.Map<java.lang.String,SOCGameOption> getOptions()
           
static SOCNewGameWithOptionsRequest parseDataStr(java.lang.String s)
          Parse the command String into a NewGameWithOptionsRequest message
 java.lang.String toCmd()
          NEWGAMEWITHOPTIONSREQUEST sep nickname sep2 password sep2 host sep2 game
static java.lang.String toCmd(java.lang.String nn, java.lang.String pw, java.lang.String hn, java.lang.String ga, java.util.Map<java.lang.String,SOCGameOption> opts)
          NEWGAMEWITHOPTIONSREQUEST sep nickname sep2 password sep2 host sep2 game sep2 options
static java.lang.String toCmd(java.lang.String nn, java.lang.String pw, java.lang.String hn, java.lang.String ga, java.lang.String optstr)
          NEWGAMEWITHOPTIONSREQUEST sep nickname sep2 password sep2 host sep2 game sep2 options
 java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class soc.message.SOCMessageTemplateJoinGame
getGame, getHost, getNickname, getPassword, toString
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, getType, isSingleLineAndSafe, isSingleLineAndSafe, toMsg
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

optsStr

private java.lang.String optsStr
won't be null, even if opts is null, due to SOCGameOption.packOptionsToString(Map, boolean) format.


opts

private java.util.Map<java.lang.String,SOCGameOption> opts
may be null

Constructor Detail

SOCNewGameWithOptionsRequest

public SOCNewGameWithOptionsRequest(java.lang.String nn,
                                    java.lang.String pw,
                                    java.lang.String hn,
                                    java.lang.String ga,
                                    java.util.Map<java.lang.String,SOCGameOption> opts)
Create a NewGameWithOptionsRequest message.

Parameters:
nn - nickname
pw - optional password, or "" if none
hn - server host name
ga - name of the game
opts - the game options, or null; if null, it probably makes sense to create a SOCJoinGame message instead.

SOCNewGameWithOptionsRequest

public SOCNewGameWithOptionsRequest(java.lang.String nn,
                                    java.lang.String pw,
                                    java.lang.String hn,
                                    java.lang.String ga,
                                    java.lang.String optstr)
Create a NewGameWithOptionsRequest message.

Parameters:
nn - nickname
pw - optional password, or "" if none
hn - server host name
ga - name of the game
optstr - the game options as a string name-value pairs, as created by SOCGameOption.packOptionsToString(Map, boolean).
Method Detail

getOptions

public java.util.Map<java.lang.String,SOCGameOption> getOptions()
Returns:
the game options (map of SOCGameOption), or null; does not parse optsStr.

toCmd

public java.lang.String toCmd()
NEWGAMEWITHOPTIONSREQUEST sep nickname sep2 password sep2 host sep2 game

Specified by:
toCmd in class SOCMessage
Returns:
the command String

toCmd

public static java.lang.String toCmd(java.lang.String nn,
                                     java.lang.String pw,
                                     java.lang.String hn,
                                     java.lang.String ga,
                                     java.lang.String optstr)
NEWGAMEWITHOPTIONSREQUEST sep nickname sep2 password sep2 host sep2 game sep2 options

Parameters:
nn - the nickname
pw - the optional password, or "" if none
hn - the server host name
ga - the game name
optstr - the game options as a string name-value pairs, as created by SOCGameOption.packOptionsToString(Map, boolean).
Returns:
the command string

toCmd

public static java.lang.String toCmd(java.lang.String nn,
                                     java.lang.String pw,
                                     java.lang.String hn,
                                     java.lang.String ga,
                                     java.util.Map<java.lang.String,SOCGameOption> opts)
NEWGAMEWITHOPTIONSREQUEST sep nickname sep2 password sep2 host sep2 game sep2 options

Parameters:
nn - the nickname
pw - the optional password, or "" if none
hn - the server host name
ga - the game name
opts - the game options (SOCGameOption)
Returns:
the command string

parseDataStr

public static SOCNewGameWithOptionsRequest parseDataStr(java.lang.String s)
Parse the command String into a NewGameWithOptionsRequest message

Parameters:
s - the String to parse
Returns:
a NewGameWithOptionsRequest message, or null if the data is garbled; this would include string-valued options which fail SOCMessage.isSingleLineAndSafe(String).

getMinimumVersion

public int getMinimumVersion()
Minimum version where this message type is used. NEWGAMEWITHOPTIONS introduced in 1.1.07 for game-options feature.

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 1107 for JSettlers 1.1.07.

toString

public java.lang.String toString()
Description copied from class: SOCMessage
Simple human-readable representation, used for debug purposes.

Specified by:
toString in class SOCMessage
Returns:
a human readable form of the message