soc.message
Class SOCSimpleRequest

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

public class SOCSimpleRequest
extends SOCMessageTemplate4i

This generic message handles a simple request from a client player in a game. This is a way to add game actions without adding new SOCMessage subclasses. It has a player number, a request type code, and two optional detail-value fields.

To get the optional detail value fields from a SOCSimpleRequest, be sure to use getValue1() and getValue2(), not SOCMessageTemplate4i.getParam1() and SOCMessageTemplate4i.getParam2() which would instead return the player number and request type code. getPlayerNumber() and getRequestType() are convenience methods with more intuitive names to retrieve the player number and typecode.

This message type would be useful for new functions that don't have a complicated set of details attached. If SOCRollDiceRequest or the Ask-Special-Build message types were implemented today, they would add request types to this message type.

Request type codes below 1000 are for general types that different kinds of games might be able to use.
Gametype-specific request types start at 1000.

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

Field Summary
static int SC_PIRI_FORT_ATTACK
          The current player wants to attack their pirate fortress (scenario _SC_PIRI).
private static long serialVersionUID
           
static int TRADE_PORT_PLACE
          The current player wants to place a trade port they've been given.
 
Fields inherited from class soc.message.SOCMessageTemplate4i
game, p1, p2, p3, p4
 
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
SOCSimpleRequest(java.lang.String ga, int pn, int reqtype)
          Create a SOCSimpleRequest message.
SOCSimpleRequest(java.lang.String ga, int pn, int reqtype, int value1)
          Create a SOCSimpleRequest message with a detail value.
SOCSimpleRequest(java.lang.String ga, int pn, int reqtype, int value1, int value2)
          Create a SOCSimpleRequest message with 2 detail values.
 
Method Summary
 int getMinimumVersion()
          Minimum version where this message type is used.
 int getPlayerNumber()
           
 int getRequestType()
           
 int getValue1()
           
 int getValue2()
           
static SOCSimpleRequest parseDataStr(java.lang.String s)
          Parse the command String into a SOCSimpleRequest message
static java.lang.String toCmd(java.lang.String ga, int pn, int reqtype, int value1, int value2)
          SIMPLEREQUEST sep game sep2 playernumber sep2 reqtype sep2 value1 sep2 value2
 
Methods inherited from class soc.message.SOCMessageTemplate4i
getGame, getParam1, getParam2, getParam3, getParam4, toCmd, toCmd, toString
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, 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

SC_PIRI_FORT_ATTACK

public static final int SC_PIRI_FORT_ATTACK
The current player wants to attack their pirate fortress (scenario _SC_PIRI). Value1 and value2 are unused. If client can attack, server responds with SOCSimpleAction.SC_PIRI_FORT_ATTACK_RESULT and related messages (see that type's javadoc). Otherwise, server responds with the standard SOCSimpleRequest denial: (pn = -1, typecode SC_PIRI_FORT_ATTACK, 0, 0).

This request type is used in v2.0.00. It's unused and unrecognized in 1.1.18, but this field is declared there as an example and to reserve its number.

Since:
1.1.18
See Also:
Constant Field Values

TRADE_PORT_PLACE

public static final int TRADE_PORT_PLACE
The current player wants to place a trade port they've been given. This typically happens at some point after SOCSimpleAction.TRADE_PORT_REMOVED in scenario _SC_FTRI.

In state SOCGame.PLACING_INV_ITEM, player sends this with an edge coordinate where they want to place the port. value1 = the edge coordinate, value2 is unused.

If they can place there now, server will do so and broadcast the resulting game state (SOCGame.PLAY1 or SOCGame.SPECIAL_BUILDING), then broadcast a SOCSimpleRequest to the game with value1 = the placed port type, value2 = edge. All clients should call SOCGame.placePort(soc.game.SOCPlayer, int, int).

Otherwise, server responds with a SOCSimpleRequest declining the placement (pn = -1).

Since:
2.0.00
See Also:
Constant Field Values
Constructor Detail

SOCSimpleRequest

public SOCSimpleRequest(java.lang.String ga,
                        int pn,
                        int reqtype)
Create a SOCSimpleRequest message.

Parameters:
ga - the name of the game
pn - the requester's player number
reqtype - the request type; below 1000 is general, 1000+ is specific to one kind of game

SOCSimpleRequest

public SOCSimpleRequest(java.lang.String ga,
                        int pn,
                        int reqtype,
                        int value1)
Create a SOCSimpleRequest message with a detail value.

Parameters:
ga - the name of the game
pn - the requester's player number
reqtype - the request type; below 1000 is general, 1000+ is specific to one kind of game
value1 - Optional detail value, or 0. Use getValue1(), not SOCMessageTemplate4i.getParam1(), to get this value from a SOCSimpleRequest message.

SOCSimpleRequest

public SOCSimpleRequest(java.lang.String ga,
                        int pn,
                        int reqtype,
                        int value1,
                        int value2)
Create a SOCSimpleRequest message with 2 detail values.

Parameters:
ga - the name of the game
pn - the requester's player number
reqtype - the request type; below 1000 is general, 1000+ is specific to one kind of game
value1 - First optional detail value, or 0. Use getValue1(), not SOCMessageTemplate4i.getParam1(), to get this value from a SOCSimpleRequest message.
value2 - Second optional detail value, or 0. Use getValue2(), not SOCMessageTemplate4i.getParam2(), to get this value from a SOCSimpleRequest message.
Method Detail

getPlayerNumber

public int getPlayerNumber()
Returns:
the player number

getRequestType

public int getRequestType()
Returns:
the request type

getValue1

public int getValue1()
Returns:
the request's optional value1 detail field

getValue2

public int getValue2()
Returns:
the request's optional value2 detail field

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     int pn,
                                     int reqtype,
                                     int value1,
                                     int value2)
SIMPLEREQUEST sep game sep2 playernumber sep2 reqtype sep2 value1 sep2 value2

Parameters:
ga - the name of the game
pn - the requester's player number
reqtype - the request type; below 1000 is general, 1000+ is specific to one kind of game
value1 - First optional detail value, or 0
value2 - Second optional detail value, or 0
Returns:
the command string

parseDataStr

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

Parameters:
s - the String to parse: SIMPLEREQUEST sep game sep2 playernumber sep2 reqtype sep2 value1 sep2 value2
Returns:
a SOCSimpleRequest message, or null if the data is garbled

getMinimumVersion

public int getMinimumVersion()
Minimum version where this message type is used. SIMPLEREQUEST introduced in 1.1.18.

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 1118 for JSettlers 1.1.18.