soc.message
Class SOCPlayerStats

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

public class SOCPlayerStats
extends SOCMessageTemplateMi

Statistics of one type for one player. Sent at end of game, or by player's request ("*STATS*" command). Design allows multiple types of stats. The first item in this message is the type number. Content of further items depends on the stats type.

Type 1: Resource roll stats: For item details see STYPE_RES_ROLL. Introduced in 1.1.09; check client version against VERSION_FOR_RES_ROLL before sending this type.

In 2.0.00 and newer, this type optionally includes an additional item for the number of gold hex resource picks/gains. Older clients would ignore the extra item, but wouldn't be compatible anyway with any game scenario that features gold hexes.

Robot clients don't need to know about or handle this message type, because they don't care about their player stats.

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

Field Summary
private static long serialVersionUID
           
static int STYPE_MAX
          Highest-numbered stat stype in this version (1)
static int STYPE_MIN
          Lowest-numbered stats type (1)
static int STYPE_RES_ROLL
          Stats type 1: Resource roll stats.
static int VERSION_FOR_RES_ROLL
          Minimum client version 1.1.09 for stats type 1 (STYPE_RES_ROLL: resource roll stats).
 
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
  SOCPlayerStats(SOCPlayer pl, int stype)
          Constructor for server to tell client about a player stat.
protected SOCPlayerStats(java.lang.String gameName, int[] pa)
          Constructor for client to parse message from server.
 
Method Summary
 int getMinimumVersion()
          Minimum version where this message type is used.
 int getStatType()
          Get the stat type.
private static int len(SOCPlayer pl, int stype)
          Given a stat type and specific player, find the array length needed to send that player's stats of that type.
static SOCPlayerStats parseDataStr(java.util.List<java.lang.String> pa)
          Parse the command String list into a SOCPlayerStats 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

STYPE_MIN

public static final int STYPE_MIN
Lowest-numbered stats type (1)

See Also:
Constant Field Values

STYPE_RES_ROLL

public static final int STYPE_RES_ROLL
Stats type 1: Resource roll stats. Each resource's count includes resources picked from a rolled GOLD_HEX. For the Fog Scenario, includes resources picked when building a road or ship revealed gold from a fog hex.
Items for this type:
 pa[1] = clay count
 pa[2] = ore
 pa[3] = sheep
 pa[4] = wheat
 pa[5] = wood count
 pa[6] = gold gains count (v2.0.00+); value is 0 if omitted

In 2.0.00 and newer, this type optionally includes an additional item for the number of gold hex resource picks/gains; this is omitted when value is 0 and there are no further items. Older clients would ignore the extra item, but wouldn't be compatible anyway with any game scenario that features gold hexes.

Check client version against VERSION_FOR_RES_ROLL before sending this type.

See Also:
Constant Field Values

STYPE_MAX

public static final int STYPE_MAX
Highest-numbered stat stype in this version (1)

See Also:
Constant Field Values

VERSION_FOR_RES_ROLL

public static final int VERSION_FOR_RES_ROLL
Minimum client version 1.1.09 for stats type 1 (STYPE_RES_ROLL: resource roll stats).

See Also:
Constant Field Values
Constructor Detail

SOCPlayerStats

public SOCPlayerStats(SOCPlayer pl,
                      int stype)
               throws java.lang.IllegalArgumentException,
                      java.lang.NullPointerException
Constructor for server to tell client about a player stat.

Parameters:
pl - Player for these stats
stype - Stats type. Newer servers and clients may support more types. For each type (such as STYPE_RES_ROLL), check the corresponding VERSION_FOR_ field before sending.
Throws:
java.lang.IllegalArgumentException - if stype < STYPE_MIN or > STYPE_MAX
java.lang.NullPointerException - if pl null

SOCPlayerStats

protected SOCPlayerStats(java.lang.String gameName,
                         int[] pa)
                  throws java.lang.IllegalArgumentException
Constructor for client to parse message from server. Note that neither type nor pa length are validated, so that future stats types can be passed along.

Parameters:
gameName - Game name
pa - Parameters of the option:
  • pa[0] = stats type (only type 1 is defined for now): Use STYPE_RES_ROLL for this parameter.
  • pa[1 - n] = items for that stats type: see stats-type constant javadocs.
Throws:
java.lang.IllegalArgumentException
Method Detail

len

private static final int len(SOCPlayer pl,
                             int stype)
                      throws java.lang.IllegalArgumentException,
                             java.lang.NullPointerException
Given a stat type and specific player, find the array length needed to send that player's stats of that type.

Parameters:
pl - Player for these stats
stype - Stats type, such as STYPE_RES_ROLL; see class javadoc or constructors
Returns:
Stat array length, including stype at index 0; always 6 before v2.0.00
Throws:
java.lang.IllegalArgumentException - if stype < STYPE_MIN or > STYPE_MAX
java.lang.NullPointerException - if pl null

getMinimumVersion

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

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

getStatType

public int getStatType()
Get the stat type.

For the actual statistic data. call SOCMessageTemplateMi.getParams() but remember that stats[i] will be in params[i+1], because params[0] is the stat type.

Returns:
the player stat type, such as STYPE_RES_ROLL

parseDataStr

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

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