soc.message
Class SOCDiceResultResources

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

public class SOCDiceResultResources
extends SOCMessageTemplateMi

All resources gained by players from a dice roll.

Before v2.0.00, these were sent as SOCPlayerElement(GAIN) and SOCGameTextMsg. This single message is more efficient and also easier for i18n/localization.

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

Field Summary
 java.util.List<java.lang.Integer> playerNum
          playerNum(i) is the player number gaining the resources in playerRsrc(i).
 java.util.List<SOCResourceSet> playerRsrc
          playerRsrc(i) is the resource set gained by player playerNum(i).
private static long serialVersionUID
           
static int VERSION_FOR_DICERESULTRESOURCES
          Version number (2.0.00) where the server no longer sends dice roll result resources as a game text message + several SOCPlayerElement(GAIN) messages, and instead sends a single SOCDiceResultResources message.
 
Fields inherited from class soc.message.SOCMessageTemplateMi
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 SOCDiceResultResources(java.lang.String gameName, int[] pa)
          Constructor for client to parse message from server via parseDataStr(List<String>).
  SOCDiceResultResources(java.lang.String gaName, java.util.List<java.lang.Integer> pn, java.util.List<SOCResourceSet> rsrc)
          Constructor for server to tell clients about players' gained resources.
 
Method Summary
private static int[] buildIntList(java.util.List<java.lang.Integer> pnum, java.util.List<SOCResourceSet> rsrc)
          Used by server constructor to build an outbound array of ints from these players and these resources.
 int getMinimumVersion()
          Minimum version where this message type is used (VERSION_FOR_DICERESULTRESOURCES).
static SOCDiceResultResources parseDataStr(java.util.List<java.lang.String> pa)
          Parse the command String list into a SOCDiceResultResources message.
 
Methods inherited from class soc.message.SOCMessageTemplateMi
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

VERSION_FOR_DICERESULTRESOURCES

public static final int VERSION_FOR_DICERESULTRESOURCES
Version number (2.0.00) where the server no longer sends dice roll result resources as a game text message + several SOCPlayerElement(GAIN) messages, and instead sends a single SOCDiceResultResources message.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

playerNum

public java.util.List<java.lang.Integer> playerNum
playerNum(i) is the player number gaining the resources in playerRsrc(i). Used at client only, null at server.


playerRsrc

public java.util.List<SOCResourceSet> playerRsrc
playerRsrc(i) is the resource set gained by player playerNum(i). Used at client only, null at server.

Constructor Detail

SOCDiceResultResources

public SOCDiceResultResources(java.lang.String gaName,
                              java.util.List<java.lang.Integer> pn,
                              java.util.List<SOCResourceSet> rsrc)
                       throws java.lang.IllegalArgumentException,
                              java.lang.NullPointerException
Constructor for server to tell clients about players' gained resources. The int array will be built from pn and rsrc; the playerNum and playerRsrc fields will be left blank, we don't need them to send the ints to clients.

Parameters:
gaName - Game name
pn - Player numbers, same format as playerNum
rsrc - Resources gained by each pn, same format as playerRsrc
Throws:
java.lang.IllegalArgumentException - if pn.size() != rsrc.size(), or if either is empty
java.lang.NullPointerException - if any parameter is null

SOCDiceResultResources

protected SOCDiceResultResources(java.lang.String gameName,
                                 int[] pa)
                          throws java.lang.IllegalArgumentException
Constructor for client to parse message from server via parseDataStr(List<String>). Decodes the integers in pa[] into playerNum and playerRsrc.

Parameters:
gameName - Game name
pa - Parameters, each of which is a sequence of integers with this format:
 pa[i] = player number gaining resource(s)
    Pair of:
 pa[i+1] = resource amount gained
 pa[i+2] = resource type
    More pairs, if any, for each other resource type gained by the player
 If there are more players after this one:
 pa[i+n] = 0, marking the end of the pairs
Throws:
java.lang.IllegalArgumentException - if pa[] doesn't fit that format, or ends in the middle of parsing
Method Detail

buildIntList

private static final int[] buildIntList(java.util.List<java.lang.Integer> pnum,
                                        java.util.List<SOCResourceSet> rsrc)
Used by server constructor to build an outbound array of ints from these players and these resources.

Parameters:
pnum - Player numbers, same format as playerNum
rsrc - Resources gained by each pn, same format as playerRsrc
Throws:
java.lang.IllegalArgumentException - if pn.size() != rsrc.size(), or if either is empty
java.lang.NullPointerException - if any parameter is null

getMinimumVersion

public int getMinimumVersion()
Minimum version where this message type is used (VERSION_FOR_DICERESULTRESOURCES). DICERESULTRESOURCES introduced in 2.0.00 for dice roll result resources.

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 2000 for JSettlers 2.0.00.

parseDataStr

public static SOCDiceResultResources parseDataStr(java.util.List<java.lang.String> pa)
Parse the command String list into a SOCDiceResultResources message. Calls SOCDiceResultResources(String, int[]) constructor, see its javadoc for parameter details.

Parameters:
pa - the parameters; length 2 or more required.
Returns:
a parsed message, or null if parsing errors