Class ChangeSet.AttackChange

    • Field Detail

      • attacker

        private final Unit attacker
      • defender

        private final Unit defender
      • success

        private final boolean success
      • defenderInSettlement

        private final boolean defenderInSettlement
    • 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 - The Unit that is attacking.
        defender - The Unit 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 - The Player 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 - The Player 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 class ChangeSet.Change<AnimateAttackMessage>
        Parameters:
        player - The Player to consider.
        Returns:
        True if this Change should be sent.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object