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 Unit
attacker
private Unit
defender
private boolean
defenderInSettlement
private boolean
success
-
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 boolean
attackerVisible(Player player)
Is the attacker visible to a player?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).boolean
isNotifiable(Player player)
Should a player be notified of this Change? Override in subclasses with special cases.AnimateAttackMessage
toMessage(Player player)
Specialize a Change for a particular player.java.lang.String
toString()
-
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
- TheUnit
that is attacking.defender
- TheUnit
that is defending.success
- Did the attack succeed.
-
-
Method Detail
-
attackerVisible
private boolean attackerVisible(Player player)
Is the attacker visible to a player?- Parameters:
player
- ThePlayer
to 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
- ThePlayer
to 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:
isNotifiable
in classChangeSet.Change<AnimateAttackMessage>
- Parameters:
player
- ThePlayer
to consider.- Returns:
- True if this
Change
should be sent.
-
toMessage
public AnimateAttackMessage toMessage(Player player)
Specialize a Change for a particular player.- Specified by:
toMessage
in classChangeSet.Change<AnimateAttackMessage>
- Parameters:
player
- ThePlayer
to update.- Returns:
- A specialized
Message
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-