soc.message
Class SOCSVPTextMessage

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

public class SOCSVPTextMessage
extends SOCMessage
implements SOCKeyedMessage, SOCMessageForGame

Message from server to game's clients, with the number of Special Victory Points (SVP) and reason the player was awarded them. The server will also send a SOCPlayerElement with the SVP total. So, robot players can ignore this textual message. Also sent for each player's SVPs when client is joining a game in progress, before client sits down at a seat.

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

Field Summary
 java.lang.String desc
          Description of the player's action that led to the SVP.
 java.lang.String game
          Name of the game.
 int pn
          Player number.
private static long serialVersionUID
           
 int svp
          Number of Special Victory Points (SVP) awarded.
 
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
SOCSVPTextMessage(java.lang.String ga, int pn, int svp, java.lang.String desc)
          Create a new SVPTEXTMSG message.
 
Method Summary
 java.lang.String getGame()
          Name of game this message is for.
 java.lang.String getKey()
          Get the message localization key, from StringManager.get(String), to look up and send the text of as part of this message.
static SOCSVPTextMessage parseDataStr(java.lang.String s)
          Parse the command string into a SOCSVPTextMessage message.
 java.lang.String toCmd()
          SVPTEXTMSG sep game sep2 pn sep2 svp sep2 desc
protected static java.lang.String toCmd(int messageType, java.lang.String ga, int pn, int svp, java.lang.String desc)
          SVPTEXTMSG sep game sep2 pn sep2 svp sep2 desc
 java.lang.String toCmd(java.lang.String localizedText)
          Construct a message ready to be sent, like SOCMessage.toCmd(), with text localized by the server.
 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

game

public final java.lang.String game
Name of the game.


pn

public final int pn
Player number.


svp

public final int svp
Number of Special Victory Points (SVP) awarded.


desc

public final java.lang.String desc
Description of the player's action that led to the SVP. At the server this is an I18N string key, at the client it's localized text sent from the server. This allows new SVP actions and descriptions without client changes. Constructor checks this against SOCMessage.isSingleLineAndSafe(String, boolean).

Constructor Detail

SOCSVPTextMessage

public SOCSVPTextMessage(java.lang.String ga,
                         int pn,
                         int svp,
                         java.lang.String desc)
                  throws java.lang.IllegalArgumentException
Create a new SVPTEXTMSG message.

Parameters:
ga - the game name
pn - Player number
svp - Number of Special Victory Points (SVP) awarded
desc - Description of the player's action that led to the SVP. At the server this is an I18N string key which the server must localize before sending, at the client it's localized text sent from the server. This allows new SVP actions and descriptions without client changes.
Throws:
java.lang.IllegalArgumentException - if desc is null or fails SOCMessage.isSingleLineAndSafe(desc, true)
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 name of the game
See Also:
SOCMessage.GAME_NONE

toCmd

public java.lang.String toCmd()
SVPTEXTMSG sep game sep2 pn sep2 svp sep2 desc

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

toCmd

protected static java.lang.String toCmd(int messageType,
                                        java.lang.String ga,
                                        int pn,
                                        int svp,
                                        java.lang.String desc)
SVPTEXTMSG sep game sep2 pn sep2 svp sep2 desc

Parameters:
ga - the game name
pn - Player number
svp - Number of Special Victory Points (SVP) awarded
desc - Description of the player's action that led to the SVP
Returns:
the command string

getKey

public java.lang.String getKey()
Get the message localization key, from StringManager.get(String), to look up and send the text of as part of this message.

This message type's key field is desc.

Specified by:
getKey in interface SOCKeyedMessage
Returns:
The text key to be localized from the message's key field, or (rarely) null

toCmd

public java.lang.String toCmd(java.lang.String localizedText)
Description copied from interface: SOCKeyedMessage
Construct a message ready to be sent, like SOCMessage.toCmd(), with text localized by the server.

Specified by:
toCmd in interface SOCKeyedMessage
Parameters:
localizedText - Text field contents localized by the server, from SOCKeyedMessage.getKey() and the client's locale, or null if getKey() == null
Returns:
A message formatted like SOCMessage.toCmd()

parseDataStr

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

Parameters:
s - the String to parse; format: game sep2 pn sep2 svp sep2 desc
Returns:
a SOCSVPTextMessage message, or null if parsing errors

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