Class BattleServerSide


  • public final class BattleServerSide
    extends Battle
    Class Battle holds data about a Titan battle. It has utility functions related to incrementing the phase, managing moves, and managing strikes.
    Author:
    David Ripton, Romain Dolbeau
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • server

        private Server server
      • carryDamage

        private int carryDamage
      • attackerElim

        private boolean attackerElim
      • defenderElim

        private boolean defenderElim
      • battleOver

        private boolean battleOver
      • attackerEntered

        private boolean attackerEntered
      • conceded

        private boolean conceded
      • preStrikeEffectsApplied

        private boolean preStrikeEffectsApplied
      • carryTargets

        private final java.util.Set<BattleHex> carryTargets
        Set of hexes for valid carry targets
      • pointsScored

        private int pointsScored
    • Method Detail

      • setServer

        public void setServer​(Server server)
      • cleanRefs

        public void cleanRefs()
      • placeLegion

        private void placeLegion​(Legion legion)
      • init

        void init()
        We need to do two-stage construction so that game.battle is non-null earlier.
      • getGame

        public GameServerSide getGame()
        Override with covariant return type to ease transition into new model.
        Overrides:
        getGame in class Battle
      • isDefenderActive

        public boolean isDefenderActive()
      • getBattleActivePlayer

        Player getBattleActivePlayer()
      • isOver

        private boolean isOver()
      • advancePhase

        private void advancePhase()
      • setupSummon

        private boolean setupSummon()
      • setupRecruit

        private boolean setupRecruit()
      • setupMove

        private boolean setupMove()
      • setupFight

        private boolean setupFight()
      • finishSummoningAngel

        void finishSummoningAngel​(boolean placeNewChit)
        Called from Game after the SummonAngel finishes.
      • recruitReinforcement

        private boolean recruitReinforcement()
      • doneReinforcing

        void doneReinforcing()
        Needs to be called when reinforcement is done.
      • getCarryDamage

        int getCarryDamage()
      • setCarryDamage

        void setCarryDamage​(int carryDamage)
      • concede

        void concede​(Player player)
        Mark all of the conceding player's critters as dead.
      • removeOffboardCreatures

        private void removeOffboardCreatures()
        If any creatures were left off-board, kill them. If they were newly summoned or recruited, unsummon or unrecruit them instead.
      • commitMoves

        private void commitMoves()
      • doneWithMoves

        void doneWithMoves()
      • applyPreStrikeEffects

        private void applyPreStrikeEffects()
      • arePreStrikeEffectsApplied

        boolean arePreStrikeEffectsApplied()
      • setPreStrikeEffectsApplied

        void setPreStrikeEffectsApplied​(boolean preStrikeEffectsApplied)
      • leaveCarryMode

        void leaveCarryMode()
      • removeDeadCreatures

        private void removeDeadCreatures()
      • removeDeadCreaturesFromLegion

        private void removeDeadCreaturesFromLegion​(LegionServerSide legion)
      • cleanupOneDeadCritter

        private void cleanupOneDeadCritter​(Creature critter)
      • checkForElimination

        private void checkForElimination()
      • commitStrikes

        private void commitStrikes()
      • isForcedStrikeRemaining

        public boolean isForcedStrikeRemaining()
      • doneWithStrikes

        void doneWithStrikes()
        Checks now all at same place in Server
      • findTargetHexes

        java.util.Set<BattleHex> findTargetHexes​(CreatureServerSide critter,
                                                 boolean rangestrike)
        Return a set of hexes containing targets that the critter may strike
        Parameters:
        battleUnit - the striking creature
        rangestrike - Whether to include rangestrike targets
        Returns:
        a set of hexes containing targets
      • getCarryTargets

        java.util.Set<BattleHex> getCarryTargets()
        Return the set of hexes with valid carry targets.
      • getCarryTargetDescriptions

        java.util.Set<java.lang.String> getCarryTargetDescriptions()
      • clearCarryTargets

        void clearCarryTargets()
      • setCarryTargets

        void setCarryTargets​(java.util.Set<BattleHex> carryTargets)
      • addCarryTarget

        void addCarryTarget​(BattleHex hex)
      • doMove

        java.lang.String doMove​(int tag,
                                BattleHex hex)
        If legal, move critter to hex and return true. Else return false.
      • cleanup

        private void cleanup()
      • getAllCritters

        public java.util.List<BattleCritter> getAllCritters()
        Description copied from class: Battle
        Get all BattleCritters / BattleUnits Abstract because currently implementation is different, but needed on both side, e.g. for BattleMovement
        Specified by:
        getAllCritters in class Battle
      • isInContact

        public boolean isInContact​(BattleCritter critter,
                                   boolean countDead)
        Return true if there are any enemies adjacent to this critter.
        Specified by:
        isInContact in class Battle
        Parameters:
        critter - The critter to check whether it is in contact with any enemy critter
        countDead - Dead critters count as being in contact only if countDead is true.
      • numInContact

        public int numInContact​(BattleCritter striker,
                                boolean countDead)
        Return the number of enemy creatures in contact with this critter. Dead critters count as being in contact only if countDead is true.