Package net.sf.freecol.common.networking
Class AnimateAttackMessage
- 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.AnimateAttackMessage
-
public class AnimateAttackMessage extends ObjectMessage
The message sent to tell a client to show an attack animation.
-
-
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
ATTACKER_TAG
private static java.lang.String
ATTACKER_TILE_TAG
private static java.lang.String
DEFENDER_TAG
private static java.lang.String
DEFENDER_TILE_TAG
private static java.lang.String
SUCCESS_TAG
static java.lang.String
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 AnimateAttackMessage(Game game, FreeColXMLReader xr)
Create a newAnimateAttackMessage
from a stream.AnimateAttackMessage(Unit attacker, Unit defender, boolean result, boolean addAttacker, boolean addDefender)
Create a newAnimateAttackMessage
for the supplied attacker, defender, result and visibility information.
-
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.private Unit
getAttacker(Game game)
Get the attacker unit.private Tile
getAttackerTile(Game game)
Get the attacker tile.private Unit
getDefender(Game game)
Get the defender unit.private Tile
getDefenderTile(Game game)
Get the defender tile.Message.MessagePriority
getPriority()
Get the priority of this type of message.private boolean
getResult()
Get the result of the attack.private Unit
getUnit(Game game, java.lang.String key)
Get a unit by key.-
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
currentPlayerMessage, getType, serverHandler, 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
-
ATTACKER_TAG
private static final java.lang.String ATTACKER_TAG
- See Also:
- Constant Field Values
-
ATTACKER_TILE_TAG
private static final java.lang.String ATTACKER_TILE_TAG
- See Also:
- Constant Field Values
-
DEFENDER_TAG
private static final java.lang.String DEFENDER_TAG
- See Also:
- Constant Field Values
-
DEFENDER_TILE_TAG
private static final java.lang.String DEFENDER_TILE_TAG
- See Also:
- Constant Field Values
-
SUCCESS_TAG
private static final java.lang.String SUCCESS_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AnimateAttackMessage
public AnimateAttackMessage(Unit attacker, Unit defender, boolean result, boolean addAttacker, boolean addDefender)
Create a newAnimateAttackMessage
for the supplied attacker, defender, result and visibility information.- Parameters:
attacker
- The attackingUnit
.defender
- The defendingUnit
.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 newAnimateAttackMessage
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
-
getUnit
private Unit getUnit(Game game, java.lang.String key)
Get a unit by key.- Parameters:
game
- TheGame
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
- TheGame
to look up the unit in.- Returns:
- The attacker
Unit
.
-
getDefender
private Unit getDefender(Game game)
Get the defender unit.- Parameters:
game
- TheGame
to look up the unit in.- Returns:
- The defender
Unit
.
-
getAttackerTile
private Tile getAttackerTile(Game game)
Get the attacker tile.- Parameters:
game
- TheGame
to look up the tile in.- Returns:
- The attacker
Tile
.
-
getDefenderTile
private Tile getDefenderTile(Game game)
Get the defender tile.- Parameters:
game
- TheGame
to look up the tile in.- Returns:
- The defender
Tile
.
-
getResult
private boolean getResult()
Get the result of the attack.- Returns:
- The result.
-
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.
-
-