Package net.sf.freecol.common.networking
Class ChangeSet.AttackChange
- java.lang.Object
-
- net.sf.freecol.common.networking.ChangeSet.Change<AnimateAttackMessage>
-
- net.sf.freecol.common.networking.ChangeSet.AttackChange
-
- Enclosing class:
- ChangeSet
private static class ChangeSet.AttackChange extends ChangeSet.Change<AnimateAttackMessage>
Encapsulate an attack.
-
-
Field Summary
Fields Modifier and Type Field Description private Unitattackerprivate Unitdefenderprivate booleandefenderInSettlementprivate booleansuccess-
Fields inherited from class net.sf.freecol.common.networking.ChangeSet.Change
see
-
-
Constructor Summary
Constructors Constructor Description AttackChange(ChangeSet.See see, Unit attacker, Unit defender, boolean success)Build a new AttackChange.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanattackerVisible(Player player)Is the attacker visible to a player?private booleandefenderVisible(Player player)Is the defender visible to a player? A false positive can occur as the defender may *start* invisible because it is in a settlement, but the settlement falls, exposing the defender (the defender dies).booleanisNotifiable(Player player)Should a player be notified of this Change? Override in subclasses with special cases.AnimateAttackMessagetoMessage(Player player)Specialize a Change for a particular player.java.lang.StringtoString()-
Methods inherited from class net.sf.freecol.common.networking.ChangeSet.Change
check, consequence, matches
-
-
-
-
Constructor Detail
-
AttackChange
public AttackChange(ChangeSet.See see, Unit attacker, Unit defender, boolean success)
Build a new AttackChange. Note that we must copy attackers and defenders because a successful attacker can move, and an unsuccessful participant can die, and unsuccessful defenders can be captured. Furthermore for defenders, insufficient information is serialized when a unit is inside a settlement, but if unscoped too much is disclosed. So we make a copy and neuter it. We have to remember if the defender was in a settlement because by the time serialization occurs the settlement might have been destroyed. We just have to accept that combat animation is an exception to the normal visibility rules.- Parameters:
see- The visibility of this change.attacker- TheUnitthat is attacking.defender- TheUnitthat is defending.success- Did the attack succeed.
-
-
Method Detail
-
attackerVisible
private boolean attackerVisible(Player player)
Is the attacker visible to a player?- Parameters:
player- ThePlayerto test.- Returns:
- The attacker visibility.
-
defenderVisible
private boolean defenderVisible(Player player)
Is the defender visible to a player? A false positive can occur as the defender may *start* invisible because it is in a settlement, but the settlement falls, exposing the defender (the defender dies). Defenders in settlements must always be considered to be invisible to other players as the animation happens while the settlement stands.- Parameters:
player- ThePlayerto test.- Returns:
- The defender visibility.
-
isNotifiable
public boolean isNotifiable(Player player)
Should a player be notified of this Change? Override in subclasses with special cases.- Overrides:
isNotifiablein classChangeSet.Change<AnimateAttackMessage>- Parameters:
player- ThePlayerto consider.- Returns:
- True if this
Changeshould be sent.
-
toMessage
public AnimateAttackMessage toMessage(Player player)
Specialize a Change for a particular player.- Specified by:
toMessagein classChangeSet.Change<AnimateAttackMessage>- Parameters:
player- ThePlayerto update.- Returns:
- A specialized
Message.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-