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.StringACTION_TAGprivate static java.lang.StringMONARCH_TAGprivate static java.lang.StringRESULT_TAGstatic java.lang.StringTAGprivate static java.lang.StringTAX_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 newMonarchActionMessagefrom a stream.MonarchActionMessage(Monarch.MonarchAction action, StringTemplate template, java.lang.String monarchKey)Create a newMonarchActionMessagewith 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 voidaiHandler(FreeColServer freeColServer, AIPlayer aiPlayer)AI-side handler for this message.voidclientHandler(FreeColClient freeColClient)Client-side handler for this message.booleancurrentPlayerMessage()Should this message only be sent to a server by the current player?private Monarch.MonarchActiongetAction()Gets the monarch action type of this message.private java.lang.StringgetMonarchKey()Gets the monarch key.Message.MessagePrioritygetPriority()Get the priority of this type of message.private java.lang.BooleangetResult()Gets the result.private intgetTax()Gets the tax amount attached to this message.private StringTemplategetTemplate()Gets the template of this message.ChangeSetserverHandler(FreeColServer freeColServer, ServerPlayer serverPlayer)Server-side handler for this message.MonarchActionMessagesetResult(boolean accept)Sets the result.MonarchActionMessagesetTax(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 newMonarchActionMessagewith the given action to be sent to the client to solicit a response.- Parameters:
action- TheMonarchActionto do.template- AStringTemplatedescribing the action.monarchKey- The resource key for the monarch image.
-
MonarchActionMessage
public MonarchActionMessage(Game game, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Create a newMonarchActionMessagefrom a stream.- Parameters:
game- TheGamethis message belongs to.xr- TheFreeColXMLReaderto 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:
currentPlayerMessagein 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:
getPriorityin 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:
aiHandlerin classTrivialMessage- Parameters:
freeColServer- TheFreeColServerhandling the request.aiPlayer- TheAIPlayerthe message was sent to.
-
clientHandler
public void clientHandler(FreeColClient freeColClient)
Client-side handler for this message. Client handlers always return null.- Overrides:
clientHandlerin classTrivialMessage- Parameters:
freeColClient- TheFreeColClientto handle this message.
-
serverHandler
public ChangeSet serverHandler(FreeColServer freeColServer, ServerPlayer serverPlayer)
Server-side handler for this message.- Overrides:
serverHandlerin classTrivialMessage- Parameters:
freeColServer- TheFreeColServerhandling the request.serverPlayer- TheServerPlayerthat sent the request.- Returns:
- A
ChangeSetdefining 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.
-
-