soc.message
Class SOCDiscard

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

public class SOCDiscard
extends SOCMessage
implements SOCMessageForGame

This message means that a player is discarding. Client's response to server's SOCDiscardRequest. The server will report the discard's resource total to the other players via SOCPlayerElement and text, but will not send a SOCDiscard message to other players.

Author:
Robert S. Thomas
See Also:
Serialized Form

Field Summary
private  java.lang.String game
          Name of game
private  SOCResourceSet resources
          The set of resources being discarded
private static long serialVersionUID
           
 
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
SOCDiscard(java.lang.String ga, int cl, int or, int sh, int wh, int wo, int uk)
          Create a Discard message.
SOCDiscard(java.lang.String ga, int pn, SOCResourceSet rs)
          Create a Discard message.
 
Method Summary
 java.lang.String getGame()
          Name of game this message is for.
 SOCResourceSet getResources()
           
static SOCDiscard parseDataStr(java.lang.String s)
          Parse the command String into a Discard message
 java.lang.String toCmd()
          DISCARD sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown
static java.lang.String toCmd(java.lang.String ga, int cl, int or, int sh, int wh, int wo, int uk)
          DISCARD sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown
static java.lang.String toCmd(java.lang.String ga, SOCResourceSet rs)
          DISCARD sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown
 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

private java.lang.String game
Name of game


resources

private SOCResourceSet resources
The set of resources being discarded

Constructor Detail

SOCDiscard

public SOCDiscard(java.lang.String ga,
                  int cl,
                  int or,
                  int sh,
                  int wh,
                  int wo,
                  int uk)
Create a Discard message.

Parameters:
ga - the name of the game
cl - the amount of clay being discarded
or - the amount of ore being discarded
sh - the amount of sheep being discarded
wh - the amount of wheat being discarded
wo - the amount of wood being discarded
uk - the amount of unknown resources being discarded

SOCDiscard

public SOCDiscard(java.lang.String ga,
                  int pn,
                  SOCResourceSet rs)
Create a Discard message.

Parameters:
ga - the name of the game
rs - the resources being discarded
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

getResources

public SOCResourceSet getResources()
Returns:
the set of resources being discarded

toCmd

public java.lang.String toCmd()
DISCARD sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown

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

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     SOCResourceSet rs)
DISCARD sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown

Parameters:
ga - the name of the game
rs - the resources being discarded
Returns:
the command string

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     int cl,
                                     int or,
                                     int sh,
                                     int wh,
                                     int wo,
                                     int uk)
DISCARD sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown

Parameters:
ga - the name of the game
cl - the amount of clay being discarded
or - the amount of ore being discarded
sh - the amount of sheep being discarded
wh - the amount of wheat being discarded
wo - the amount of wood being discarded
uk - the amount of unknown resources being discarded
Returns:
the command string

parseDataStr

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

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