|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.message.SOCMessage soc.message.SOCMessageTemplate4i soc.message.SOCSimpleRequest
public class SOCSimpleRequest
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.
pn
must be their own player number so that the server could announce the request using the same message
type and parameters instead of defining another type.
value1b
and value2b
are typecode-specific and
might not be the same as value1
or value2
.
If the server is too old to understand this request type, it will respond with (pn = -1, typecode, 0, 0).
SOCSimpleAction
,
Serialized FormField 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 |
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 |
---|
private static final long serialVersionUID
public static final int SC_PIRI_FORT_ATTACK
_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.
public static final int TRADE_PORT_PLACE
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).
Constructor Detail |
---|
public SOCSimpleRequest(java.lang.String ga, int pn, int reqtype)
ga
- the name of the gamepn
- the requester's player numberreqtype
- the request type; below 1000 is general, 1000+ is specific to one kind of gamepublic SOCSimpleRequest(java.lang.String ga, int pn, int reqtype, int value1)
ga
- the name of the gamepn
- the requester's player numberreqtype
- the request type; below 1000 is general, 1000+ is specific to one kind of gamevalue1
- Optional detail value, or 0. Use getValue1()
, not SOCMessageTemplate4i.getParam1()
, to get
this value from a SOCSimpleRequest
message.public SOCSimpleRequest(java.lang.String ga, int pn, int reqtype, int value1, int value2)
ga
- the name of the gamepn
- the requester's player numberreqtype
- the request type; below 1000 is general, 1000+ is specific to one kind of gamevalue1
- 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 |
---|
public int getPlayerNumber()
public int getRequestType()
public int getValue1()
value1
detail fieldpublic int getValue2()
value2
detail fieldpublic 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
ga
- the name of the gamepn
- the requester's player numberreqtype
- the request type; below 1000 is general, 1000+ is specific to one kind of gamevalue1
- First optional detail value, or 0value2
- Second optional detail value, or 0
public static SOCSimpleRequest parseDataStr(java.lang.String s)
s
- the String to parse: SIMPLEREQUEST
sep game sep2 playernumber sep2 reqtype sep2 value1 sep2 value2
null
if the data is garbledpublic int getMinimumVersion()
getMinimumVersion
in class SOCMessage
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |