soc.message
Class SOCPlayerElements

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

public class SOCPlayerElements
extends SOCMessageTemplateMi

This message from the server holds information on some parts of the player's status, such as resource type counts. Same structure as SOCPlayerElement but with less redundancy when sending multiple messages. For a given player number and action type, contains multiple pairs of (element type, value).

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

Field Summary
private  int actionType
          Action type: SOCPlayerElement.SET, SOCPlayerElement.GAIN, or SOCPlayerElement.LOSE
private  int[] elementTypes
          Element types, such as SOCPlayerElement.CLAY, matching up with each item of values
static int[] NAMED_RESOURCES
          The original 5 named resources, for convenience: SOCPlayerElement.CLAY, ORE, SHEEP, WHEAT, SOCPlayerElement.WOOD.
private  int playerNumber
          Player number
private static long serialVersionUID
           
private  int[] values
          Element values, matching up with each item of elementTypes
static int VERSION
          Introduced in version 1.1.09
 
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
 
Constructor Summary
SOCPlayerElements(java.lang.String ga, int pn, int ac, int[] et, int[] va)
          Constructor for server to tell client about player elements.
 
Method Summary
 int getAction()
           
 int[] getElementTypes()
           
 int getMinimumVersion()
          Minimum version where this message type is used.
 int getPlayerNumber()
           
 int[] getValues()
           
static SOCPlayerElements parseDataStr(java.util.List<java.lang.String> pa)
          Parse the command String list into a SOCPlayerElements 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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

VERSION

public static final int VERSION
Introduced in version 1.1.09

See Also:
Constant Field Values

NAMED_RESOURCES

public static final int[] NAMED_RESOURCES
The original 5 named resources, for convenience: SOCPlayerElement.CLAY, ORE, SHEEP, WHEAT, SOCPlayerElement.WOOD.


playerNumber

private int playerNumber
Player number


actionType

private int actionType
Action type: SOCPlayerElement.SET, SOCPlayerElement.GAIN, or SOCPlayerElement.LOSE


elementTypes

private int[] elementTypes
Element types, such as SOCPlayerElement.CLAY, matching up with each item of values


values

private int[] values
Element values, matching up with each item of elementTypes

Constructor Detail

SOCPlayerElements

public SOCPlayerElements(java.lang.String ga,
                         int pn,
                         int ac,
                         int[] et,
                         int[] va)
                  throws java.lang.NullPointerException
Constructor for server to tell client about player elements.

Parameters:
ga - name of the game
pn - the player number
ac - the type of action: SOCPlayerElement.SET, SOCPlayerElement.GAIN, or SOCPlayerElement.LOSE
et - array of the types of element, such as SOCPlayerElement.SETTLEMENTS
va - array of the values of each element, corresponding to et[]
Throws:
java.lang.NullPointerException - if et null or va null
Method Detail

getMinimumVersion

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

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 1109 for JSettlers 1.1.09.

getPlayerNumber

public int getPlayerNumber()
Returns:
the player number

getAction

public int getAction()
Returns:
the action type

getElementTypes

public int[] getElementTypes()
Returns:
the element type array, such as SOCPlayerElement.CLAY, matching up with each item of getValues()

getValues

public int[] getValues()
Returns:
the element value array, matching up with each item of getElementTypes()

parseDataStr

public static SOCPlayerElements parseDataStr(java.util.List<java.lang.String> pa)
Parse the command String list into a SOCPlayerElements message.

Parameters:
pa - the parameters; length 5 or more required. Built by constructor at server. Length must be odd.
 pa[0] = gameName
 pa[1] = playerNum
 pa[2] = actionType
 pa[3] = elementType[0]
 pa[4] = value[0]
 pa[5] = elementType[1]
 pa[6] = value[1]
(etc.)
Returns:
a SOCPlayerElements message, or null if parsing errors