|
||||||||||
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.SOCSimpleAction
public class SOCSimpleAction
This generic message from the server to clients handles a simple action or event for a client player in a game. This is a way to add game actions and events without adding new SOCMessage subclasses. It has a player number, an action type code, and two optional detail-value fields. This message comes after, not before, any messages that update the game and player data for the action.
To get the optional detail value fields from a SOCSimpleAction
, be sure to use getValue1()
and getValue2()
, not SOCMessageTemplate4i.getParam1()
and SOCMessageTemplate4i.getParam2()
which would instead return the
player number and action type code. getPlayerNumber()
and getActionType()
are
convenience methods with more intuitive names to retrieve the player number and typecode.
This message type is useful for functions that don't have a complicated set of details attached, such as telling all players that someone has bought a development card, or telling a bot that it's made a successful bank/port trade, or some event or condition just happened.
It can also be used to prompt the player that they may or must take some action at this time.
Action types that do this have MAY_
or MUST_
in their name.
Depending on the action type code, this message may be broadcast to the entire game or sent to only the affected player. Clients should ignore action types they don't know how to handle (maybe the type is newer than the client's version).
Action type codes below 1000 are for general types that different kinds of games might be able to use.
Gametype-specific action types start at 1000.
SOCSimpleRequest
,
Serialized FormField Summary | |
---|---|
static int |
DEVCARD_BOUGHT
The current player has bought a development card. |
static int |
SC_PIRI_FORT_ATTACK_RESULT
This message from server announces the results of the current player's pirate fortress attack attempt: Pirates' random defense strength, number of player's ships lost (win/tie/loss). |
private static long |
serialVersionUID
|
static int |
TRADE_PORT_REMOVED
The current player has removed a trade port from the board. |
static int |
TRADE_SUCCESSFUL
The requested resource trade with the bank/ports was successful. |
static int |
VERSION_FOR_SIMPLEACTION
First version number (1.1.19) that has this message type. |
Fields inherited from class soc.message.SOCMessageTemplate4i |
---|
game, p1, p2, p3, p4 |
Constructor Summary | |
---|---|
SOCSimpleAction(java.lang.String ga,
int pn,
int acttype)
Create a SOCSimpleAction message. |
|
SOCSimpleAction(java.lang.String ga,
int pn,
int acttype,
int value1)
Create a SOCSimpleAction message with a detail value. |
|
SOCSimpleAction(java.lang.String ga,
int pn,
int acttype,
int value1,
int value2)
Create a SOCSimpleAction message with 2 detail values. |
Method Summary | |
---|---|
int |
getActionType()
|
int |
getMinimumVersion()
Minimum version where this message type is used. |
int |
getPlayerNumber()
|
int |
getValue1()
|
int |
getValue2()
|
static SOCSimpleAction |
parseDataStr(java.lang.String s)
Parse the command String into a SOCSimpleAction message |
static java.lang.String |
toCmd(java.lang.String ga,
int pn,
int acttype,
int value1,
int value2)
SIMPLEACTION sep game sep2 playernumber sep2 acttype 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 VERSION_FOR_SIMPLEACTION
SOCGameTextMsg
or other appropriate messages instead.
public static final int DEVCARD_BOUGHT
value1
is the number of cards remaining to be bought, value2
is unused.
Follows a SOCDevCardAction
which has the card's info, bots must process that message.
public static final int TRADE_SUCCESSFUL
value1
and value2
are unused.
Sent to bots only; human players see a text message sent to the entire game.
public static final int SC_PIRI_FORT_ATTACK_RESULT
SOCSimpleRequest.SC_PIRI_FORT_ATTACK
in scenario _SC_PIRI
.
This message is sent out after related messages with game data (see below), so that those can be shown visually before any popup announcing the result.
Param 1: The pirates' defense strength (random 1 - 6)
Param 2: The number of ships lost by the player: 0 if player wins, 1 if tie, 2 if pirates win
These game data update messages are sent from server before SC_PIRI_FORT_ATTACK_RESULT
, in this order:
SOCRemovePiece
for each removed ship
SOCPlayerElement
(SCENARIO_WARSHIP_COUNT
)
if any of the player's warships were removed
Messages sent if player wins:
SOCMoveRobber
only if all players' fortresses are recaptured,
which removes the pirate fleet from the board (new pirate coordinate = 0)
SOCPieceValue
for the fortress' reduced strength;
if its new strength is 0, it is recaptured by the player
SOCPutPiece
(SETTLEMENT
) if the player wins for the last time
and recaptures the fortress
public static final int TRADE_PORT_REMOVED
value1
is the former port's edge coordinate, value2
is the port type.
Sent to entire game. If the player must place the port immediately, server will soon send
SOCGameState
(PLACING_INV_ITEM
) among other messages.
When the player wants to place the removed port, they will send SOCSimpleRequest.TRADE_PORT_PLACE
with their chosen location. If the placement is allowed, the server will broadcast a similar
SOCSimpleRequest.TRADE_PORT_PLACE
to the game; see that javadoc for details.
Used with scenario option _SC_FTRI
.
Constructor Detail |
---|
public SOCSimpleAction(java.lang.String ga, int pn, int acttype)
ga
- the name of the gamepn
- the player acting or acted onacttype
- the action type; below 1000 is general, 1000+ is specific to one kind of gamepublic SOCSimpleAction(java.lang.String ga, int pn, int acttype, int value1)
ga
- the name of the gamepn
- the player acting or acted onacttype
- the action 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 SOCSimpleAction
message.public SOCSimpleAction(java.lang.String ga, int pn, int acttype, int value1, int value2)
ga
- the name of the gamepn
- the player acting or acted onacttype
- the action 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 SOCSimpleAction
message.value2
- Second optional detail value, or 0. Use getValue2()
, not SOCMessageTemplate4i.getParam2()
, to get
this value from a SOCSimpleAction
message.Method Detail |
---|
public final int getPlayerNumber()
public final int getActionType()
public final int getValue1()
value1
detail fieldpublic final int getValue2()
value2
detail fieldpublic static java.lang.String toCmd(java.lang.String ga, int pn, int acttype, int value1, int value2)
SIMPLEACTION
sep game sep2 playernumber sep2 acttype sep2 value1 sep2 value2
ga
- the name of the gamepn
- the player acting or acted onacttype
- the action 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 SOCSimpleAction parseDataStr(java.lang.String s)
s
- the String to parse: SIMPLEACTION
sep game sep2 playernumber sep2 acttype sep2 value1 sep2 value2
null
if the data is garbledpublic final int getMinimumVersion()
getMinimumVersion
in class SOCMessage
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |