soc.message
Class SOCSimpleAction

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

public class SOCSimpleAction
extends SOCMessageTemplate4i

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.

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

Field 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
 
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
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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

VERSION_FOR_SIMPLEACTION

public static final int VERSION_FOR_SIMPLEACTION
First version number (1.1.19) that has this message type. Send older clients SOCGameTextMsg or other appropriate messages instead.

See Also:
Constant Field Values

DEVCARD_BOUGHT

public static final int DEVCARD_BOUGHT
The current player has bought a development card. For i18n in v2.x, this message is sent instead of a text message announcing the buy; bots can ignore it. 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.

Since:
1.1.19
See Also:
Constant Field Values

TRADE_SUCCESSFUL

public static final int TRADE_SUCCESSFUL
The requested resource trade with the bank/ports was successful. value1 and value2 are unused. Sent to bots only; human players see a text message sent to the entire game.

Since:
1.1.19
See Also:
Constant Field Values

SC_PIRI_FORT_ATTACK_RESULT

public static final 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). Sent in response to client's 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:

Since:
2.0.00
See Also:
Constant Field Values

TRADE_PORT_REMOVED

public static final int TRADE_PORT_REMOVED
The current player has removed a trade port from the board. 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.

Since:
2.0.00
See Also:
Constant Field Values
Constructor Detail

SOCSimpleAction

public SOCSimpleAction(java.lang.String ga,
                       int pn,
                       int acttype)
Create a SOCSimpleAction message.

Parameters:
ga - the name of the game
pn - the player acting or acted on
acttype - the action type; below 1000 is general, 1000+ is specific to one kind of game

SOCSimpleAction

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

Parameters:
ga - the name of the game
pn - the player acting or acted on
acttype - the action 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 SOCSimpleAction message.

SOCSimpleAction

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

Parameters:
ga - the name of the game
pn - the player acting or acted on
acttype - the action 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 SOCSimpleAction message.
value2 - Second optional detail value, or 0. Use getValue2(), not SOCMessageTemplate4i.getParam2(), to get this value from a SOCSimpleAction message.
Method Detail

getPlayerNumber

public final int getPlayerNumber()
Returns:
the player number acting or acted on

getActionType

public final int getActionType()
Returns:
the action type

getValue1

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

getValue2

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

toCmd

public 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

Parameters:
ga - the name of the game
pn - the player acting or acted on
acttype - the action 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 SOCSimpleAction parseDataStr(java.lang.String s)
Parse the command String into a SOCSimpleAction message

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

getMinimumVersion

public final int getMinimumVersion()
Minimum version where this message type is used. SIMPLEACTION introduced in 1.1.19.

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 1119 for JSettlers 1.1.19.