Class MonarchActionMessage


  • public class MonarchActionMessage
    extends ObjectMessage
    The message sent when doing a monarch action.
    • Constructor Detail

      • MonarchActionMessage

        public MonarchActionMessage​(Monarch.MonarchAction action,
                                    StringTemplate template,
                                    java.lang.String monarchKey)
        Create a new MonarchActionMessage with the given action to be sent to the client to solicit a response.
        Parameters:
        action - The MonarchAction to do.
        template - A StringTemplate 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 new MonarchActionMessage from a stream.
        Parameters:
        game - The Game this message belongs to.
        xr - The FreeColXMLReader 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 class TrivialMessage
        Returns:
        True if this is a current-player-only message.
      • 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 class TrivialMessage
        Parameters:
        freeColServer - The FreeColServer handling the request.
        aiPlayer - The AIPlayer 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 class TrivialMessage
        Parameters:
        freeColClient - The FreeColClient to handle this message.
      • serverHandler

        public ChangeSet serverHandler​(FreeColServer freeColServer,
                                       ServerPlayer serverPlayer)
        Server-side handler for this message.
        Overrides:
        serverHandler in class TrivialMessage
        Parameters:
        freeColServer - The FreeColServer handling the request.
        serverPlayer - The ServerPlayer 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.