soc.message
Class SOCPutPiece

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

public class SOCPutPiece
extends SOCMessage
implements SOCMessageForGame

This message means that a player is asking to place, or has placed, a piece on the board. Also used when joining a new game or a game in progress, to send the game state so far. Some game scenarios use villages which aren't owned by any player; their getPlayerNumber() is -1 in this message.

The messages similar but opposite to this one are SOCCancelBuildRequest and the very-limited SOCRemovePiece.

Author:
Robert S Thomas
See Also:
Serialized Form

Field Summary
private  int coordinates
          the coordinates of the piece
private  java.lang.String game
          the name of the game
private  int pieceType
          the type of piece being placed, such as SOCPlayingPiece.CITY
private  int playerNumber
          the player number of who played the piece, or -1 for non-player-owned SOCPlayingPiece.VILLAGE
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
SOCPutPiece(java.lang.String na, int pn, int pt, int co)
          create a PutPiece message
 
Method Summary
 int getCoordinates()
           
 java.lang.String getGame()
          Name of game this message is for.
 int getPieceType()
           
 int getPlayerNumber()
           
static SOCPutPiece parseDataStr(java.lang.String s)
          parse the command string into a PutPiece message
 java.lang.String toCmd()
          Command string: PUTPIECE sep game sep2 playerNumber sep2 pieceType sep2 coordinates
static java.lang.String toCmd(java.lang.String ga, int pn, int pt, int co)
          Command string: PUTPIECE sep game sep2 playerNumber sep2 pieceType sep2 coordinates
 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
the name of the game


pieceType

private int pieceType
the type of piece being placed, such as SOCPlayingPiece.CITY


playerNumber

private int playerNumber
the player number of who played the piece, or -1 for non-player-owned SOCPlayingPiece.VILLAGE


coordinates

private int coordinates
the coordinates of the piece

Constructor Detail

SOCPutPiece

public SOCPutPiece(java.lang.String na,
                   int pn,
                   int pt,
                   int co)
create a PutPiece message

Parameters:
na - name of the game
pt - type of playing piece, such as SOCPlayingPiece.CITY
pn - player number, or -1 for non-player-owned SOCPlayingPiece.VILLAGE
co - coordinates
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

getPieceType

public int getPieceType()
Returns:
the type of playing piece, such as SOCPlayingPiece.CITY

getPlayerNumber

public int getPlayerNumber()
Returns:
the player number

getCoordinates

public int getCoordinates()
Returns:
the coordinates

toCmd

public java.lang.String toCmd()
Command string: PUTPIECE sep game sep2 playerNumber sep2 pieceType sep2 coordinates

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

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     int pn,
                                     int pt,
                                     int co)
Command string: PUTPIECE sep game sep2 playerNumber sep2 pieceType sep2 coordinates

Parameters:
ga - the name of the game
pn - player number, or -1 for non-player-owned SOCPlayingPiece.VILLAGE
pt - type of playing piece
co - coordinates
Returns:
the command string

parseDataStr

public static SOCPutPiece parseDataStr(java.lang.String s)
parse the command string into a PutPiece message

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