soc.message
Class SOCPickResources

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

public class SOCPickResources
extends SOCMessage
implements SOCMessageForGame

This message from client means that the client player has picked these resources to receive from the gold hex. Client response to server's SOCPickResourcesRequest. (Similar send/response pattern as SOCDiscardRequest / SOCDiscard.)

If the resource count is wrong, the server will resend SOCPickResourcesRequest. Otherwise: The server will report the picked resources to the other players via SOCPlayerElement and text, but will not send a SOCPickResources message to other players. The server will also send all players a SOCPlayerElement(NUM_PICK_GOLD_HEX_RESOURCES, 0) message.

Also used in scenario SC_PIRI when player wins a free resource for defeating the pirate fleet attack at a dice roll.

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

Field Summary
private  java.lang.String game
          Name of game
private  SOCResourceSet resources
          The set of resources picked to be gained
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
SOCPickResources(java.lang.String ga, int cl, int or, int sh, int wh, int wo, int uk)
          Create a Pick Resources message.
SOCPickResources(java.lang.String ga, SOCResourceSet rs)
          Create a Pick Resources message.
 
Method Summary
 java.lang.String getGame()
          Name of game this message is for.
 SOCResourceSet getResources()
           
static SOCPickResources parseDataStr(java.lang.String s)
          Parse the command String into a Pick Resources message.
 java.lang.String toCmd()
          PICKRESOURCES 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)
          PICKRESOURCES 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)
          PICKRESOURCES 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 picked to be gained

Constructor Detail

SOCPickResources

public SOCPickResources(java.lang.String ga,
                        int cl,
                        int or,
                        int sh,
                        int wh,
                        int wo,
                        int uk)
Create a Pick Resources message.

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

SOCPickResources

public SOCPickResources(java.lang.String ga,
                        SOCResourceSet rs)
Create a Pick Resources message.

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

toCmd

public java.lang.String toCmd()
PICKRESOURCES 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)
PICKRESOURCES 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 picked
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)
PICKRESOURCES sep game sep2 clay sep2 ore sep2 sheep sep2 wheat sep2 wood sep2 unknown

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

parseDataStr

public static SOCPickResources parseDataStr(java.lang.String s)
Parse the command String into a Pick Resources message.

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