net.sf.colossus.variant
Class BattleHex

java.lang.Object
  extended by net.sf.colossus.variant.Hex
      extended by net.sf.colossus.variant.BattleHex
Direct Known Subclasses:
ShowCreatureDetails.SimulatedBattleHex

public class BattleHex
extends Hex

Class BattleHex holds game state for battle hex.

Author:
David Ripton, Romain Dolbeau

Field Summary
private static char[] allHexsides
          The array of all the valid terrain type for a BattleHex Side.
private  int elevation
          Valid elevations are 0, 1, and 2.
private  HazardHexside[] hexsideHazards
          Hold the HazardHexside type of the six side of the BattleHex (e.g.
static int IMPASSIBLE_COST
          Movement costs
private static java.util.logging.Logger LOGGER
           
private  BattleHex[] neighbors
          Links to the neighbors of the BattleHex.
private static int NORMAL_COST
           
private static int SLOW_COST
           
private static int SLOW_INCREMENT_COST
           
private  HazardTerrain terrain
           
 
Constructor Summary
BattleHex(int xCoord, int yCoord)
           
 
Method Summary
private static char _intXCoordToXLabel(int x)
          a char for an int: 0:'A'=0, 1:'B', ...
 boolean blocksLineOfSight()
          Whether this hex blocks rangestrike.
 boolean canBeFlownOverBy(CreatureType creature)
          Check if the Creature given in parameter can fly over the BattleHex, or not.
private static java.lang.String createLabel(int xCoord, int yCoord)
           
 int damageToCreature(CreatureType creature)
          Return how much damage the Creature should take from this Hex.
 int getElevation()
           
 int getEntryCost(CreatureType creature, int cameFrom, boolean cumul)
          Return the number of movement points it costs to enter this hex.
 HazardHexside getHexsideHazard(int i)
          TODO use side enumeration types instead of integers Return the HazardHexside (enumType) at the hex' side number i
 java.lang.String getHexsideImageName(int i)
           
static char[] getHexsides()
           
 BattleHex getNeighbor(int i)
           
 HazardHexside getOppositeHazard(int i)
          Return the hazard type of opposite side of side i.
 char getOppositeHexside(int i)
          TODO get rid of this char based one Return the character code of the hazard type of opposite side of side i.
 HazardTerrain getTerrain()
           
 java.awt.Color getTerrainColor()
           
 java.lang.String getTerrainName()
           
 boolean hasWall()
           
 boolean isCliff(int hexside)
           
 boolean isEntrance()
           
 boolean isNativeBonusTerrain()
           
 boolean isNonNativePenaltyTerrain()
           
 void setElevation(int elevation)
           
 void setHexsideHazard(int i, HazardHexside hazard)
           
 void setNeighbor(int i, BattleHex hex)
           
 void setTerrain(HazardTerrain terrain)
           
 int slowsCreature(CreatureType creature)
          Return how much the hex slows the creature for the rest of the battle
 
Methods inherited from class net.sf.colossus.variant.Hex
equals, getDescription, getLabel, getXCoord, getYCoord, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

elevation

private int elevation
Valid elevations are 0, 1, and 2. Also 3 for JDG Badlands.


allHexsides

private static final char[] allHexsides
The array of all the valid terrain type for a BattleHex Side.


hexsideHazards

private final HazardHexside[] hexsideHazards
Hold the HazardHexside type of the six side of the BattleHex (e.g. Slope, Dune, River...). The hexside is marked only in the higher hex.


neighbors

private final BattleHex[] neighbors
Links to the neighbors of the BattleHex. Neighbors have one hex side in common. Non-existent neighbor are marked with null.


terrain

private HazardTerrain terrain

IMPASSIBLE_COST

public static final int IMPASSIBLE_COST
Movement costs

See Also:
Constant Field Values

SLOW_COST

private static final int SLOW_COST
See Also:
Constant Field Values

NORMAL_COST

private static final int NORMAL_COST
See Also:
Constant Field Values

SLOW_INCREMENT_COST

private static final int SLOW_INCREMENT_COST
See Also:
Constant Field Values
Constructor Detail

BattleHex

public BattleHex(int xCoord,
                 int yCoord)
Method Detail

createLabel

private static java.lang.String createLabel(int xCoord,
                                            int yCoord)

_intXCoordToXLabel

private static final char _intXCoordToXLabel(int x)
a char for an int: 0:'A'=0, 1:'B', ... int(w):'W', else:'?', <0:undef.


getTerrain

public HazardTerrain getTerrain()

setTerrain

public void setTerrain(HazardTerrain terrain)

getTerrainName

public java.lang.String getTerrainName()
Specified by:
getTerrainName in class Hex

getTerrainColor

public java.awt.Color getTerrainColor()

isNativeBonusTerrain

public boolean isNativeBonusTerrain()

isNonNativePenaltyTerrain

public boolean isNonNativePenaltyTerrain()

setHexsideHazard

public void setHexsideHazard(int i,
                             HazardHexside hazard)

getHexsideHazard

public HazardHexside getHexsideHazard(int i)
TODO use side enumeration types instead of integers Return the HazardHexside (enumType) at the hex' side number i

Parameters:
i - The side number, from 0 to 5
Returns:
The HazardHexside type at that side

getHexsideImageName

public java.lang.String getHexsideImageName(int i)

getOppositeHazard

public HazardHexside getOppositeHazard(int i)
Return the hazard type of opposite side of side i.


getOppositeHexside

public char getOppositeHexside(int i)
TODO get rid of this char based one Return the character code of the hazard type of opposite side of side i.


getElevation

public int getElevation()

setElevation

public void setElevation(int elevation)

getNeighbor

public BattleHex getNeighbor(int i)

setNeighbor

public void setNeighbor(int i,
                        BattleHex hex)

isEntrance

public boolean isEntrance()

hasWall

public boolean hasWall()

blocksLineOfSight

public boolean blocksLineOfSight()
Whether this hex blocks rangestrike.

Returns:
Whether this hex blocks rangestrike.

getEntryCost

public int getEntryCost(CreatureType creature,
                        int cameFrom,
                        boolean cumul)
Return the number of movement points it costs to enter this hex. For fliers, this is the cost to land in this hex, not fly over it. If entry is illegal, just return a cost greater than the maximum possible number of movement points. This caller is responsible for checking to see if this hex is already occupied.

Parameters:
creature - The Creature that is trying to move into the BattleHex.
cameFrom - The HexSide through which the Creature try to enter.
Returns:
Cost to enter the BattleHex.

canBeFlownOverBy

public boolean canBeFlownOverBy(CreatureType creature)
Check if the Creature given in parameter can fly over the BattleHex, or not.

Parameters:
creature - The Creature that want to fly over this BattleHex
Returns:
If the Creature can fly over here or not.

slowsCreature

public int slowsCreature(CreatureType creature)
Return how much the hex slows the creature for the rest of the battle

Parameters:
creature - The Creature that may be slowed.
Returns:
How much the Creature is slowed for the rest of the battle.

damageToCreature

public int damageToCreature(CreatureType creature)
Return how much damage the Creature should take from this Hex.

Parameters:
creature - The Creature that may suffer damage.
Returns:
How much damage the Creature should take from being there.

isCliff

public boolean isCliff(int hexside)

getHexsides

public static char[] getHexsides()