Package net.sf.freecol.common.networking
Class MonarchActionMessage
- java.lang.Object
-
- net.sf.freecol.common.networking.Message
-
- net.sf.freecol.common.networking.TrivialMessage
-
- net.sf.freecol.common.networking.AttributeMessage
-
- net.sf.freecol.common.networking.ObjectMessage
-
- net.sf.freecol.common.networking.MonarchActionMessage
-
public class MonarchActionMessage extends ObjectMessage
The message sent when doing a monarch action.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.networking.Message
Message.MessagePriority
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ACTION_TAG
private static java.lang.String
MONARCH_TAG
private static java.lang.String
RESULT_TAG
static java.lang.String
TAG
private static java.lang.String
TAX_TAG
-
Fields inherited from class net.sf.freecol.common.networking.AttributeMessage
attributes
-
Fields inherited from class net.sf.freecol.common.networking.TrivialMessage
continueMessage, disconnectMessage, endTurnMessage, enterRevengeModeMessage, reconnectMessage, requestLaunchMessage, retireMessage, startGameMessage
-
Fields inherited from class net.sf.freecol.common.networking.Message
logger, messagePriorityComparator
-
-
Constructor Summary
Constructors Constructor Description MonarchActionMessage(Game game, FreeColXMLReader xr)
Create a newMonarchActionMessage
from a stream.MonarchActionMessage(Monarch.MonarchAction action, StringTemplate template, java.lang.String monarchKey)
Create a newMonarchActionMessage
with the given action to be sent to the client to solicit a response.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
aiHandler(FreeColServer freeColServer, AIPlayer aiPlayer)
AI-side handler for this message.void
clientHandler(FreeColClient freeColClient)
Client-side handler for this message.boolean
currentPlayerMessage()
Should this message only be sent to a server by the current player?private Monarch.MonarchAction
getAction()
Gets the monarch action type of this message.private java.lang.String
getMonarchKey()
Gets the monarch key.Message.MessagePriority
getPriority()
Get the priority of this type of message.private java.lang.Boolean
getResult()
Gets the result.private int
getTax()
Gets the tax amount attached to this message.private StringTemplate
getTemplate()
Gets the template of this message.ChangeSet
serverHandler(FreeColServer freeColServer, ServerPlayer serverPlayer)
Server-side handler for this message.MonarchActionMessage
setResult(boolean accept)
Sets the result.MonarchActionMessage
setTax(int tax)
Sets the tax amount attached to this message.-
Methods inherited from class net.sf.freecol.common.networking.ObjectMessage
appendChild, appendChildren, getChildCount, getChildren, setChildren
-
Methods inherited from class net.sf.freecol.common.networking.AttributeMessage
canMerge, getStringAttribute, getStringAttributeMap, hasAttribute, setMergeable, setStringAttribute
-
Methods inherited from class net.sf.freecol.common.networking.TrivialMessage
getType, setType
-
Methods inherited from class net.sf.freecol.common.networking.Message
clientGeneric, expected, getArrayAttributes, getBooleanAttribute, getChild, getChildren, getEnumAttribute, getIntegerAttribute, getPriorityLevel, igc, igc, invokeAndWait, invokeLater, isEmpty, isType, merge, pgc, pgc, pretty, read, setArrayAttributes, setArrayAttributes, setBooleanAttribute, setEnumAttribute, setIntegerAttribute, setStringAttributeMap, setStringAttributes, setStringAttributes, toString, toXML, writeAttributes, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
ACTION_TAG
private static final java.lang.String ACTION_TAG
- See Also:
- Constant Field Values
-
MONARCH_TAG
private static final java.lang.String MONARCH_TAG
- See Also:
- Constant Field Values
-
RESULT_TAG
private static final java.lang.String RESULT_TAG
- See Also:
- Constant Field Values
-
TAX_TAG
private static final java.lang.String TAX_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MonarchActionMessage
public MonarchActionMessage(Monarch.MonarchAction action, StringTemplate template, java.lang.String monarchKey)
Create a newMonarchActionMessage
with the given action to be sent to the client to solicit a response.- Parameters:
action
- TheMonarchAction
to do.template
- AStringTemplate
describing the action.monarchKey
- The resource key for the monarch image.
-
MonarchActionMessage
public MonarchActionMessage(Game game, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Create a newMonarchActionMessage
from a stream.- Parameters:
game
- TheGame
this message belongs to.xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
-
Method Detail
-
getAction
private Monarch.MonarchAction getAction()
Gets the monarch action type of this message.- Returns:
- The monarch action type.
-
getTemplate
private StringTemplate getTemplate()
Gets the template of this message.- Returns:
- The template.
-
getMonarchKey
private java.lang.String getMonarchKey()
Gets the monarch key.- Returns:
- The monarch key.
-
getTax
private int getTax()
Gets the tax amount attached to this message.- Returns:
- The tax amount, or negative if none present.
-
getResult
private java.lang.Boolean getResult()
Gets the result.- Returns:
- The result.
-
currentPlayerMessage
public boolean currentPlayerMessage()
Should this message only be sent to a server by the current player?- Overrides:
currentPlayerMessage
in classTrivialMessage
- Returns:
- True if this is a current-player-only message.
-
getPriority
public Message.MessagePriority getPriority()
Get the priority of this type of message.- Overrides:
getPriority
in classAttributeMessage
- Returns:
- The message priority.
-
aiHandler
public void aiHandler(FreeColServer freeColServer, AIPlayer aiPlayer)
AI-side handler for this message. AI handlers always return null. FIXME: One day the FreeColServer should devolve to AIMain.- Overrides:
aiHandler
in classTrivialMessage
- Parameters:
freeColServer
- TheFreeColServer
handling the request.aiPlayer
- TheAIPlayer
the message was sent to.
-
clientHandler
public void clientHandler(FreeColClient freeColClient)
Client-side handler for this message. Client handlers always return null.- Overrides:
clientHandler
in classTrivialMessage
- Parameters:
freeColClient
- TheFreeColClient
to handle this message.
-
serverHandler
public ChangeSet serverHandler(FreeColServer freeColServer, ServerPlayer serverPlayer)
Server-side handler for this message.- Overrides:
serverHandler
in classTrivialMessage
- Parameters:
freeColServer
- TheFreeColServer
handling the request.serverPlayer
- TheServerPlayer
that sent the request.- Returns:
- A
ChangeSet
defining the response.
-
setTax
public MonarchActionMessage setTax(int tax)
Sets the tax amount attached to this message.- Parameters:
tax
- The tax amount.- Returns:
- This message.
-
setResult
public MonarchActionMessage setResult(boolean accept)
Sets the result.- Parameters:
accept
- The new result.- Returns:
- This message.
-
-