soc.message
Class SOCPlayerElement

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

public class SOCPlayerElement
extends SOCMessage
implements SOCMessageForGame

This message conveys one part of the player's status, such as their number of settlements remaining.

Unless otherwise mentioned, any getElementType() can be sent with any action (SET, GAIN, LOSE).

Author:
Robert S Thomas
See Also:
Serialized Form

Field Summary
private  int actionType
          Action type: SET, GAIN, or LOSE
static int ASK_SPECIAL_BUILD
          For the 6-player board, player element type for asking to build during the Special Building Phase.
static int CITIES
           
static int CLAY
          player element types.
private  int elementType
          Player element type, such as SETTLEMENTS
static int GAIN
           
private  java.lang.String game
          Name of game
static int LOSE
           
static int NUM_PICK_GOLD_HEX_RESOURCES
          For the large sea board, player element type for asking to choose resources from the gold hex after a dice roll, during the WAITING_FOR_PICK_GOLD_RESOURCE game state.
static int NUMKNIGHTS
          Number of knights in player's army; sent after a Soldier card is played.
static int ORE
           
private  int playerNumber
          Player number
static int ROADS
           
static int SCENARIO_CLOTH_COUNT
          For scenario _SC_CLVI on the large sea board, the number of cloth held by this player.
static int SCENARIO_PLAYEREVENTS_BITMASK
          For scenarios on the large sea board, bitmask of flags related to scenario player events.
static int SCENARIO_SVP
          For scenarios on the large sea board, the player's number of Special Victory Points (SVP).
static int SCENARIO_SVP_LANDAREAS_BITMASK
          For scenarios on the large sea board, bitmask of land areas for tracking Special Victory Points (SVP).
static int SCENARIO_WARSHIP_COUNT
          For scenario game option _SC_PIRI, the player's total number of ships that have been converted to warships.
private static long serialVersionUID
           
static int SET
          player element actions
static int SETTLEMENTS
           
static int SHEEP
           
static int SHIPS
          Number of SHIP pieces; added in v2.0.00.
static int STARTING_LANDAREAS
          Player's starting land area numbers.
static int UNKNOWN
           
private  int value
          Element value
static int WHEAT
           
static int WOOD
           
 
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
SOCPlayerElement(java.lang.String ga, int pn, int ac, int et, int va)
          Create a PlayerElement message.
 
Method Summary
 int getAction()
          Get the type of action.
 int getElementType()
          Get the element type, the type of info that is changing.
 java.lang.String getGame()
          Name of game this message is for.
 int getPlayerNumber()
          Get this element's player number.
 int getValue()
          Get the new value to set, or the delta to gain/lose.
static SOCPlayerElement parseDataStr(java.lang.String s)
          Parse the command String into a PlayerElement message
 java.lang.String toCmd()
          PLAYERELEMENT sep game sep2 playerNumber sep2 actionType sep2 elementType sep2 value
static java.lang.String toCmd(java.lang.String ga, int pn, int ac, int et, int va)
          PLAYERELEMENT sep game sep2 playerNumber sep2 actionType sep2 elementType sep2 value
 java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, getMinimumVersion, 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

CLAY

public static final int CLAY
player element types. CLAY has same value as SOCResourceConstants.CLAY; ORE, SHEEP, WHEAT and WOOD also match SOCResourceConstants.

See Also:
Constant Field Values

ORE

public static final int ORE
See Also:
Constant Field Values

SHEEP

public static final int SHEEP
See Also:
Constant Field Values

WHEAT

public static final int WHEAT
See Also:
Constant Field Values

WOOD

public static final int WOOD
See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

ROADS

public static final int ROADS
See Also:
Constant Field Values

SETTLEMENTS

public static final int SETTLEMENTS
See Also:
Constant Field Values

CITIES

public static final int CITIES
See Also:
Constant Field Values

SHIPS

public static final int SHIPS
Number of SHIP pieces; added in v2.0.00.

Since:
2.0.00
See Also:
Constant Field Values

NUMKNIGHTS

public static final int NUMKNIGHTS
Number of knights in player's army; sent after a Soldier card is played.

See Also:
Constant Field Values

ASK_SPECIAL_BUILD

public static final int ASK_SPECIAL_BUILD
For the 6-player board, player element type for asking to build during the Special Building Phase. This element is SET to 1 or 0.

Since:
1.1.08
See Also:
Constant Field Values

NUM_PICK_GOLD_HEX_RESOURCES

public static final int NUM_PICK_GOLD_HEX_RESOURCES
For the large sea board, player element type for asking to choose resources from the gold hex after a dice roll, during the WAITING_FOR_PICK_GOLD_RESOURCE game state. This element is SET to 0, or to the number of resources to choose. Call SOCPlayer.setNeedToPickGoldHexResources(int).

Since:
2.0.00
See Also:
Constant Field Values

SCENARIO_SVP

public static final int SCENARIO_SVP
For scenarios on the large sea board, the player's number of Special Victory Points (SVP). This element is SET to 0, or to the player's SOCPlayer.getSpecialVP().

Since:
2.0.00
See Also:
Constant Field Values

SCENARIO_PLAYEREVENTS_BITMASK

public static final int SCENARIO_PLAYEREVENTS_BITMASK
For scenarios on the large sea board, bitmask of flags related to scenario player events. This element is SET to 0, or to the player's flags from SOCPlayer.getScenarioPlayerEvents().

Since:
2.0.00
See Also:
Constant Field Values

SCENARIO_SVP_LANDAREAS_BITMASK

public static final int SCENARIO_SVP_LANDAREAS_BITMASK
For scenarios on the large sea board, bitmask of land areas for tracking Special Victory Points (SVP). This element is SET to 0, or to the player's land areas from SOCPlayer.getScenarioSVPLandAreas().

Since:
2.0.00
See Also:
Constant Field Values

STARTING_LANDAREAS

public static final int STARTING_LANDAREAS
Player's starting land area numbers. Sent only at reconnect, because these are also tracked during play at the client. Sent as (landArea2 << 8) | landArea1.

Since:
2.0.00
See Also:
Constant Field Values

SCENARIO_CLOTH_COUNT

public static final int SCENARIO_CLOTH_COUNT
For scenario _SC_CLVI on the large sea board, the number of cloth held by this player. This element is SET to 0, or to the player's cloth count from SOCPlayer.getCloth(). After giving cloth to a player, check their total VP; 2 cloth = 1 Victory Point.

The board's "general supply" is updated with this element type with getPlayerNumber() == -1. Each village's cloth count is updated with a PIECEVALUE message.

Since:
2.0.00
See Also:
Constant Field Values

SCENARIO_WARSHIP_COUNT

public static final int SCENARIO_WARSHIP_COUNT
For scenario game option _SC_PIRI, the player's total number of ships that have been converted to warships. See SOCPlayer.getNumWarships() for details. This element can be SET or GAINed. For clarity, if the number of warships decreases, send SET, never send LOSE. GAIN is sent only in response to a player's successful SOCPlayDevCardRequest to convert a ship to a warship.

If a player is joining a game in progress, the PLAYERELEMENT(SCENARIO_WARSHIP_COUNT) message is sent to their client only after sending their SOCShip piece positions.

Since:
2.0.00
See Also:
Constant Field Values

SET

public static final int SET
player element actions

See Also:
Constant Field Values

GAIN

public static final int GAIN
See Also:
Constant Field Values

LOSE

public static final int LOSE
See Also:
Constant Field Values

game

private java.lang.String game
Name of game


playerNumber

private int playerNumber
Player number


elementType

private int elementType
Player element type, such as SETTLEMENTS


actionType

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


value

private int value
Element value

Constructor Detail

SOCPlayerElement

public SOCPlayerElement(java.lang.String ga,
                        int pn,
                        int ac,
                        int et,
                        int va)
Create a PlayerElement message.

Parameters:
ga - name of the game
pn - the player number; v1.1.19 and newer allow -1 for some elements (applies to board or to all players). Earlier client versions will throw an exception accessing player -1. If the element type allows -1, its constant's javadoc will mention that.
ac - the type of action: SET, GAIN, or LOSE
et - the type of element, such as SETTLEMENTS
va - the value of the element
Method Detail

getGame

public java.lang.String getGame()
Description copied from interface: SOCMessageForGame
Name of game this message is for. Must not be null if message is in per-game structures or code.

At the server, the message treater dispatches incoming SOCMessageForGames based on their getGame():

Specified by:
getGame in interface SOCMessageForGame
Returns:
the game name
See Also:
SOCMessage.GAME_NONE

getPlayerNumber

public int getPlayerNumber()
Get this element's player number. v1.1.19 and newer allow -1 for some elements (applies to board or to all players). Earlier client versions will throw an exception accessing player -1. If the element type allows -1, its constant's javadoc will mention that.

Returns:
the player number

getAction

public int getAction()
Get the type of action.

Returns:
the action type: SET, GAIN, or LOSE

getElementType

public int getElementType()
Get the element type, the type of info that is changing.

Returns:
the element type, such as SETTLEMENTS or NUMKNIGHTS

getValue

public int getValue()
Get the new value to set, or the delta to gain/lose.

Returns:
the amount to SET, GAIN, or LOSE

toCmd

public java.lang.String toCmd()
PLAYERELEMENT sep game sep2 playerNumber sep2 actionType sep2 elementType sep2 value

Specified by:
toCmd in class SOCMessage
Returns:
the command String

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     int pn,
                                     int ac,
                                     int et,
                                     int va)
PLAYERELEMENT sep game sep2 playerNumber sep2 actionType sep2 elementType sep2 value

Parameters:
ga - the game name
pn - the player number; v1.1.19 and newer allow -1 for some elements (applies to board or to all players). Earlier client versions will throw an exception accessing player -1. If the element type allows -1, its constant's javadoc will mention that.
ac - the type of action
et - the type of element
va - the value of the element
Returns:
the command string

parseDataStr

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

Parameters:
s - the String to parse
Returns:
a PlayerElement message, or null of the data is garbled

toString

public java.lang.String toString()
Description copied from class: SOCMessage
Simple human-readable representation, used for debug purposes.

Specified by:
toString in class SOCMessage
Returns:
a human readable form of the message