soc.message
Class SOCGameTextMsg

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

public class SOCGameTextMsg
extends SOCMessage
implements SOCMessageForGame

This message contains a text message for a SoC game. Seen by server or by human players on-screen, occasionally parsed by robots if they're expecting a debug message.

Text announcements from the server are instead sent as SOCGameServerText to client versions 2.0.00 and newer. See that class javadoc for what game information is sent as text and what's sent as other message types.

Author:
Robert S Thomas
See Also:
Serialized Form

Field Summary
private  java.lang.String game
          Name of game
private  java.lang.String nickname
          Nickname of sender, or SERVERNAME
private static java.lang.String sep2
          our token separator; not the normal SOCMessage.sep2
private static long serialVersionUID
           
static java.lang.String SERVERNAME
          "Server", the reserved nickname used when sending game text messages from the server itself, not chat messages from players.
private  java.lang.String text
          Text message
static int VERSION_FOR_DICE_RESULT_INSTEAD
          Version number (2000) where the server no longer sends dice roll results as a game text message.
 
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_char, SERVERPING, SETPLAYEDDEVCARD, SETSEATLOCK, SETSPECIALITEM, SETTURN, SETUPDONE, SIMPLEACTION, SIMPLEREQUEST, SITDOWN, STARTGAME, STATUSMESSAGE, SVPTEXTMSG, TEXTMSG, TIMINGPING, TURN, UPDATEROBOTPARAMS, VERSION
 
Constructor Summary
SOCGameTextMsg(java.lang.String ga, java.lang.String nn, java.lang.String tm)
          Create a GameTextMsg message.
 
Method Summary
 java.lang.String getGame()
          Name of game this message is for.
 java.lang.String getNickname()
          Get the player's nickname for a chat message, or the server for game announcement text
 java.lang.String getText()
           
static SOCGameTextMsg parseDataStr(java.lang.String s)
          Parse the command String into a GameTextMsg message
 java.lang.String toCmd()
          GAMETEXTMSG sep game sep2 nickname sep2 text
static java.lang.String toCmd(java.lang.String ga, java.lang.String nn, java.lang.String tm)
          GAMETEXTMSG sep game sep2 nickname sep2 text
 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

SERVERNAME

public static final java.lang.String SERVERNAME
"Server", the reserved nickname used when sending game text messages from the server itself, not chat messages from players.

This is used only for pre-2.0.00 clients, because starting with that version, the server's announcement texts are sent as SOCGameServerText instead.

Moved here in v2.0.00; previously declared in SOCServer and a string literal at clients.

Since:
2.0.00
See Also:
Constant Field Values

VERSION_FOR_DICE_RESULT_INSTEAD

public static final int VERSION_FOR_DICE_RESULT_INSTEAD
Version number (2000) where the server no longer sends dice roll results as a game text message.

Clients older than v2.0.00 expect the server to announce dice roll results via text messages such as "j rolled a 2 and a 2." The client would then replace that on-screen with "Rolled a 4." to reduce visual clutter.

Starting with v2.0.00, the client prints roll results from the SOCDiceResult message instead. So, the server doesn't send the roll result game text message to v2.0.00 or newer clients.

Since:
2.0.00
See Also:
Constant Field Values

sep2

private static java.lang.String sep2
our token separator; not the normal SOCMessage.sep2


game

private java.lang.String game
Name of game


nickname

private java.lang.String nickname
Nickname of sender, or SERVERNAME


text

private java.lang.String text
Text message

Constructor Detail

SOCGameTextMsg

public SOCGameTextMsg(java.lang.String ga,
                      java.lang.String nn,
                      java.lang.String tm)
Create a GameTextMsg message.

Parameters:
ga - name of game
nn - nickname of sender; announcements from the server (not from a player) use SERVERNAME
tm - text message
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

getNickname

public java.lang.String getNickname()
Get the player's nickname for a chat message, or the server for game announcement text

Returns:
the player's nickname, or SERVERNAME

getText

public java.lang.String getText()
Returns:
the text message

toCmd

public java.lang.String toCmd()
GAMETEXTMSG sep game sep2 nickname sep2 text

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

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     java.lang.String nn,
                                     java.lang.String tm)
GAMETEXTMSG sep game sep2 nickname sep2 text

Parameters:
ga - the game name
nn - the nickname
tm - the text message
Returns:
the command string

parseDataStr

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

Parameters:
s - the String to parse
Returns:
a GameTextMsg 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