soc.message
Class SOCGamesWithOptions

java.lang.Object
  extended by soc.message.SOCMessage
      extended by soc.message.SOCMessageMulti
          extended by soc.message.SOCMessageTemplateMs
              extended by soc.message.SOCGamesWithOptions
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, SOCMessageForGame

public class SOCGamesWithOptions
extends SOCMessageTemplateMs

List of all games currently on the server, including their game options. It's constructed and sent for each connecting client which can understand game options (1.1.07 and newer), by calling toCmd(Vector, int).

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

Introduced in 1.1.07; check client version against SOCNewGameWithOptions.VERSION_FOR_NEWGAMEWITHOPTIONS.

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

Field Summary
private static long serialVersionUID
           
 
Fields inherited from class soc.message.SOCMessageTemplateMs
game, pa
 
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
protected SOCGamesWithOptions(java.util.List<java.lang.String> gl)
          Constructor for client to parse server's list of games.
 
Method Summary
 SOCGameList getGameList()
          Get the list of games (and option strings).
 int getMinimumVersion()
          Minimum version where this message type is used.
static SOCGamesWithOptions parseDataStr(java.util.List<java.lang.String> gl)
          Parse the command String array into a SOCGamesWithOptions message.
static java.lang.String toCmd(java.util.Vector<?> ga, int cliVers)
          Build the command string from a set of games; used at server side.
 
Methods inherited from class soc.message.SOCMessageTemplateMs
getGame, getParams, 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
Constructor Detail

SOCGamesWithOptions

protected SOCGamesWithOptions(java.util.List<java.lang.String> gl)
Constructor for client to parse server's list of games. This collects the paired games and options into a string list, but doesn't parse the game option strings into SOCGameOption objects; call SOCGameOption.parseOptionsToMap(String) for that.

There is no server-side constructor, because the server instead calls toCmd(Vector, int).

Parameters:
gl - Game list; can be empty, but not null
Method Detail

getGameList

public SOCGameList getGameList()
Get the list of games (and option strings). List contains each game's name and option strings sent from server, as packed by SOCGameOption.packOptionsToString(opts, boolean).

Game names may be marked with the prefix SOCGames.MARKER_THIS_GAME_UNJOINABLE; this will be removed from their names before adding to the returned game list. To see if a game cannot be joined, call SOCGameList.isUnjoinableGame(String).

Returns:
list of games contained in this message, or an empty SOCGameList
See Also:
SOCGameList.parseGameOptions(String)

getMinimumVersion

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

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

parseDataStr

public static SOCGamesWithOptions parseDataStr(java.util.List<java.lang.String> gl)
Parse the command String array into a SOCGamesWithOptions message.

Parameters:
gl - the game list; must contain an even number of strings (pairs of game names+options); can be null or empty
Returns:
a SOCGamesWithOptions message, or null if parsing errors

toCmd

public static java.lang.String toCmd(java.util.Vector<?> ga,
                                     int cliVers)
Build the command string from a set of games; used at server side.

Parameters:
ga - the list of games, as a mixed-content vector of Strings and/or SOCGames; if a client can't join a game, it should be a String prefixed with SOCGames.MARKER_THIS_GAME_UNJOINABLE.
cliVers - Client version; assumed >= SOCNewGameWithOptions.VERSION_FOR_NEWGAMEWITHOPTIONS. If any game's options need adjustment for an older client, cliVers triggers that.
Returns:
the command string