Class Battle

java.lang.Object
net.sf.colossus.game.Battle
Direct Known Subclasses:
BattleClientSide, BattleServerSide

public abstract class Battle extends Object
An ongoing battle.
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • game

      protected final Game game
    • attacker

      protected final Legion attacker
    • defender

      protected final Legion defender
    • location

      private final MasterHex location
    • battleTurnNumber

      protected int battleTurnNumber
  • Constructor Details

  • Method Details

    • getGame

      public Game getGame()
    • getAttackingLegion

      public Legion getAttackingLegion()
    • getDefendingLegion

      public Legion getDefendingLegion()
    • toLeft

      public static boolean toLeft(double xDist, double yDist)
      Caller must ensure that yDist != 0 TODO Temporarily public because n.s.c.client.Strike needs it
    • getDirection

      public static int getDirection(BattleHex hex1, BattleHex hex2, boolean left)
      Return the hexside direction of the path from hex1 to hex2. Sometimes two directions are possible. If the left parameter is set, the direction further left will be given. Otherwise, the direction further right will be given.
    • countBrambleHexesDir

      @Deprecated private int countBrambleHexesDir(BattleHex hex1, BattleHex hex2, boolean left, int previousCount)
      Deprecated.
      another function with explicit reference to Bramble that should be fixed.
      Return the number of intervening bramble hexes. If LOS is along a hexspine, go left if argument left is true, right otherwise. If LOS is blocked, return a large number.
    • countBrambleHexes

      @Deprecated public int countBrambleHexes(BattleHex hex1, BattleHex hex2)
      Deprecated.
      another function with explicit reference to Bramble that should be fixed.
      Return the number of intervening bramble hexes. If LOS is along a hexspine and there are two choices, pick the lower one.
    • isObstacle

      @Deprecated protected static boolean isObstacle(char hexside)
      Deprecated.
      This is the realm of HazardEdge, not direct use of hexside
    • getRange

      public static int getRange(BattleHex hex1, BattleHex hex2, boolean allowEntrance)
      Return the range in hexes from hex1 to hex2. Titan ranges are inclusive at both ends.
    • minRangeToNeighbor

      private static int minRangeToNeighbor(BattleHex hex1, BattleHex hex2)
      Return the minimum range from any neighbor of hex1 to hex2.
    • isLOSBlocked

      public boolean isLOSBlocked(BattleHex hex1, BattleHex hex2)
      Check to see if the LOS from hex1 to hex2 is blocked. If the LOS lies along a hexspine, check both and return true only if both are blocked.
    • isLOSBlockedDir

      protected boolean isLOSBlockedDir(BattleHex initialHex, BattleHex currentHex, BattleHex finalHex, boolean left, int strikeElevation, boolean strikerAtop, boolean strikerAtopCliff, boolean strikerAtopWall, boolean midObstacle, boolean midCliff, boolean midChit, int totalObstacles, int totalWalls)
      Check LOS, going to the left of hexspines if argument left is true, or to the right if it is false.
    • isRangestrikePossible

      protected boolean isRangestrikePossible(Creature critter, Creature target, BattleHex currentHex, BattleHex targetHex)
      Return true if the rangestrike is possible.
    • computeSkillPenaltyRangestrikeThroughDir

      private int computeSkillPenaltyRangestrikeThroughDir(BattleHex hex1, BattleHex hex2, Creature c, boolean left, int previousCount)
    • computeSkillPenaltyRangestrikeThrough

      public int computeSkillPenaltyRangestrikeThrough(BattleHex hex1, BattleHex hex2, Creature c)
      Compute the minimum Skill penalty that the creature will endure to rangestrike from hex1 to a creature in hex2 from the intervening hex.
      Parameters:
      hex1 - The hex in which the rangestriker sit
      hex2 - The hex in which the rangestruck sit
      c - The rangestriker
      Returns:
      The penalty to the Skill Factor of the rangestriker from intervening hex.
    • getLegionByPlayer

      protected Legion getLegionByPlayer(Player player)
    • getLocation

      public MasterHex getLocation()
    • setBattleTurnNumber

      public void setBattleTurnNumber(int battleTurnNumber)
    • getBattleTurnNumber

      public int getBattleTurnNumber()
    • getCritter

      public BattleCritter getCritter(BattleHex hex)
    • isOccupied

      public boolean isOccupied(BattleHex hex)
    • getBattleActiveLegion

      public abstract Legion getBattleActiveLegion()
    • getAllCritters

      protected abstract List<BattleCritter> getAllCritters()
      Get all BattleCritters / BattleUnits Abstract because currently implementation is different, but needed on both side, e.g. for BattleMovement
    • isInContact

      public abstract boolean isInContact(BattleCritter striker, boolean countDead)