net.sf.colossus.game
Class Battle

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

public abstract class Battle
extends java.lang.Object

An ongoing battle.


Field Summary
protected  Legion attacker
           
protected  Legion defender
           
protected  Game game
           
private  MasterHex location
           
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
Battle(Game game, Legion attacker, Legion defender, MasterHex location)
           
 
Method Summary
 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.
private  int computeSkillPenaltyRangestrikeThroughDir(BattleHex hex1, BattleHex hex2, Creature c, boolean left, int previousCount)
           
 Legion getAttackingLegion()
           
 Legion getDefendingLegion()
           
static int getDirection(BattleHex hex1, BattleHex hex2, boolean left)
          Return the hexside direction of the path from hex1 to hex2.
 Game getGame()
           
protected  Legion getLegionByPlayer(Player player)
           
 MasterHex getLocation()
           
static int getRange(BattleHex hex1, BattleHex hex2, boolean allowEntrance)
          Return the range in hexes from hex1 to hex2.
 boolean isLOSBlocked(BattleHex hex1, BattleHex hex2)
          Check to see if the LOS from hex1 to hex2 is blocked.
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.
private static boolean isObstacle(char hexside)
          Deprecated. This is the realm of HazardEdge, not direct use of hexside
protected abstract  boolean isOccupied(BattleHex hex)
          Whether the hex is occupied by a critter/creature/chit/...
protected  boolean isRangestrikePossible(Creature critter, Creature target, BattleHex currentHex, BattleHex targetHex)
          Return true if the rangestrike is possible.
private static int minRangeToNeighbor(BattleHex hex1, BattleHex hex2)
          Return the minimum range from any neighbor of hex1 to hex2.
static boolean toLeft(double xDist, double yDist)
          Caller must ensure that yDist != 0 TODO Temporarily public because n.s.c.client.Strike needs it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

game

protected final Game game

attacker

protected final Legion attacker

defender

protected final Legion defender

location

private final MasterHex location
Constructor Detail

Battle

public Battle(Game game,
              Legion attacker,
              Legion defender,
              MasterHex location)
Method Detail

getGame

public Game getGame()

getAttackingLegion

public Legion getAttackingLegion()

getDefendingLegion

public Legion getDefendingLegion()

isOccupied

protected abstract boolean isOccupied(BattleHex hex)
Whether the hex is occupied by a critter/creature/chit/... This is abstract because the specific information about critter/... is currently kept in the subclass, but this information is required by several helper function located in the Battle class.

Parameters:
hex - The hex whose occupancy is being checked
Returns:
Whether the hex is occupied by a critter/creature/chit/...

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.


isObstacle

@Deprecated
private 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()