soc.message
Class SOCNewGameWithOptions

java.lang.Object
  extended by soc.message.SOCMessage
      extended by soc.message.SOCMessageTemplate2s
          extended by soc.message.SOCNewGameWithOptions
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, SOCMessageForGame

public class SOCNewGameWithOptions
extends SOCMessageTemplate2s

This broadcast message from server announces a new game, with a certain version and possibly game options, to all clients.

Introduced in 1.1.07; check server version against VERSION_FOR_NEWGAMEWITHOPTIONS before sending this message.

Game name may include a prefix marker if the client can't join; see SOCGames.MARKER_THIS_GAME_UNJOINABLE. This marker will be retained within the game name returned by SOCMessageTemplate2s.getGame().

Just like NEWGAME, robot clients don't need to know about or handle this message type.

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

Field Summary
private  int gameMinVers
           
private static long serialVersionUID
           
static int VERSION_FOR_NEWGAMEWITHOPTIONS
          Minimum version (1.1.07) of client/server which recognize and send NEWGAMEWITHOPTIONS and other messages related to SOCGameOption.
 
Fields inherited from class soc.message.SOCMessageTemplate2s
game, p1, p2
 
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
SOCNewGameWithOptions(java.lang.String ga, java.util.Map<java.lang.String,SOCGameOption> opts, int minVers)
          Create a SOCNewGameWithOptions message.
SOCNewGameWithOptions(java.lang.String ga, java.lang.String optstr, int minVers)
          Create a SOCNewGameWithOptions message.
 
Method Summary
 int getMinimumVersion()
          Minimum version where this message type is used.
 int getMinVersion()
           
 java.lang.String getOptionsString()
           
static SOCNewGameWithOptions parseDataStr(java.lang.String s)
          Parse the command String into a SOCNewGameWithOptions message.
static java.lang.String toCmd(SOCGame ga, int cliVers)
          NEWGAMEWITHOPTIONS sep game sep2 minVers sep2 optionstring
static java.lang.String toCmd(java.lang.String ga, java.util.Map<java.lang.String,SOCGameOption> opts, int gameMinVers, int cliVers)
          NEWGAMEWITHOPTIONS sep game sep2 minVers sep2 optionstring
static java.lang.String toCmd(java.lang.String ga, java.lang.String optstr, int minVers)
          NEWGAMEWITHOPTIONS sep game sep2 minVers sep2 optionstring
 
Methods inherited from class soc.message.SOCMessageTemplate2s
getGame, getParam1, getParam2, toCmd, toCmd, 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
 
Methods inherited from interface soc.message.SOCMessageForGame
getType
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

VERSION_FOR_NEWGAMEWITHOPTIONS

public static final int VERSION_FOR_NEWGAMEWITHOPTIONS
Minimum version (1.1.07) of client/server which recognize and send NEWGAMEWITHOPTIONS and other messages related to SOCGameOption.

See Also:
Constant Field Values

gameMinVers

private int gameMinVers
Constructor Detail

SOCNewGameWithOptions

public SOCNewGameWithOptions(java.lang.String ga,
                             java.lang.String optstr,
                             int minVers)
Create a SOCNewGameWithOptions message.

Parameters:
ga - the name of the game; may have the SOCGames.MARKER_THIS_GAME_UNJOINABLE prefix. minVers also designates if the game is joinable.
optstr - Requested game options, in the format returned by SOCGameOption.packOptionsToString(opts, false), or null
minVers - Minimum client version required for this game, or -1.

SOCNewGameWithOptions

public SOCNewGameWithOptions(java.lang.String ga,
                             java.util.Map<java.lang.String,SOCGameOption> opts,
                             int minVers)
Create a SOCNewGameWithOptions message.

Parameters:
ga - the name of the game; may have the SOCGames.MARKER_THIS_GAME_UNJOINABLE prefix. minVers also designates if the game is joinable.
opts - The game's SOCGameOptions, or null
minVers - Minimum client version for this game, or -1. Ignored if sent from client to server. Calculated at server and sent out to all clients.
Method Detail

getOptionsString

public java.lang.String getOptionsString()
Returns:
the options for the new game, in the format returned by SOCGameOption.packOptionsToString(opts, false), or null if no options

getMinVersion

public int getMinVersion()
Returns:
the game's minimum required client version, or -1. This is when sending from server to all clients.

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     java.lang.String optstr,
                                     int minVers)
NEWGAMEWITHOPTIONS sep game sep2 minVers sep2 optionstring

Parameters:
ga - the name of the game; the game name may have the SOCGames.MARKER_THIS_GAME_UNJOINABLE prefix.
optstr - Requested game options, in the format returned by SOCGameOption.packOptionsToString(Map, boolean), or null
minVers - Minimum client version required, or -1
Returns:
the command string

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     java.util.Map<java.lang.String,SOCGameOption> opts,
                                     int gameMinVers,
                                     int cliVers)
NEWGAMEWITHOPTIONS sep game sep2 minVers sep2 optionstring

Parameters:
ga - the name of the game; the game name may have the SOCGames.MARKER_THIS_GAME_UNJOINABLE prefix.
opts - Requested game options, as a map of SOCGameOption
gameMinVers - Minimum client version required, or -1
cliVers - Client version, if any game's options need adjustment for an older client. Use -2 if the client version doesn't matter, or if adjustment should not be done.
Returns:
the command string

toCmd

public static java.lang.String toCmd(SOCGame ga,
                                     int cliVers)
NEWGAMEWITHOPTIONS sep game sep2 minVers sep2 optionstring

Game's options and minimum required version will be extracted from game.

Parameters:
ga - the game
cliVers - Client version; assumed >= VERSION_FOR_NEWGAMEWITHOPTIONS. If any game's options need adjustment for an older client, cliVers triggers that. Use -2 if the client version doesn't matter.
Returns:
the command string

parseDataStr

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

Parameters:
s - the String to parse: NEWGAMEWITHOPTIONS sep game sep2 opts
Returns:
a SOCNewGameWithOptions message, or null if the data is garbled

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.