Class AnimateAttackMessage


  • public class AnimateAttackMessage
    extends ObjectMessage
    The message sent to tell a client to show an attack animation.
    • Constructor Detail

      • AnimateAttackMessage

        public AnimateAttackMessage​(Unit attacker,
                                    Unit defender,
                                    boolean result,
                                    boolean addAttacker,
                                    boolean addDefender)
        Create a new AnimateAttackMessage for the supplied attacker, defender, result and visibility information.
        Parameters:
        attacker - The attacking Unit.
        defender - The defending Unit.
        result - Whether the attack succeeds.
        addAttacker - Whether to attach the attacker unit.
        addDefender - Whether to attach the defender unit.
      • AnimateAttackMessage

        public AnimateAttackMessage​(Game game,
                                    FreeColXMLReader xr)
                             throws javax.xml.stream.XMLStreamException
        Create a new AnimateAttackMessage 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

      • getUnit

        private Unit getUnit​(Game game,
                             java.lang.String key)
        Get a unit by key.
        Parameters:
        game - The Game to look up the unit in.
        key - An attribute key to extract the unit identifier with.
        Returns:
        The attacker Unit.
      • getAttacker

        private Unit getAttacker​(Game game)
        Get the attacker unit.
        Parameters:
        game - The Game to look up the unit in.
        Returns:
        The attacker Unit.
      • getDefender

        private Unit getDefender​(Game game)
        Get the defender unit.
        Parameters:
        game - The Game to look up the unit in.
        Returns:
        The defender Unit.
      • getAttackerTile

        private Tile getAttackerTile​(Game game)
        Get the attacker tile.
        Parameters:
        game - The Game to look up the tile in.
        Returns:
        The attacker Tile.
      • getDefenderTile

        private Tile getDefenderTile​(Game game)
        Get the defender tile.
        Parameters:
        game - The Game to look up the tile in.
        Returns:
        The defender Tile.
      • getResult

        private boolean getResult()
        Get the result of the attack.
        Returns:
        The result.
      • 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.