civquest
Class Field

java.lang.Object
  extended bycivquest.Field
All Implemented Interfaces:
java.io.Serializable

public class Field
extends java.lang.Object
implements java.io.Serializable

This class represents one field on the map. It saves all information about the field (things like production, humidity, temperature, units on that field, and so on). A field does especially save its position on map (usually in array-coordinates; see MapData for details). This makes dealing with fields and their coordinates much easier. Of course the coordinates saved in Field have to match the ones determined by data (usually array-indizes)in MapData. Furthermore, in this class, the CivQuest-wide used height-level-constants are defined. Some related functions are supplied, too. The Field does also maintain a container with all units currently placed on this field. Note that because of that everytime a unit enters or leaves a Field, one of the functions insertUnit/removeUnit has to be called.

See Also:
Serialized Form

Field Summary
static int HEIGHT_DEEP_SEA
           
static int HEIGHT_HIGH_MOUNTAIN
           
static int HEIGHT_HILLS
           
static int HEIGHT_LAND_VOLCANO
           
static int HEIGHT_MOUNTAIN
           
static int HEIGHT_PLAIN
           
static int HEIGHT_SEA
           
static int HEIGHT_SEA_MOUNTAIN
           
static int HEIGHT_SEA_VOLCANO
           
static int HEIGHT_SHALLOW_SEA
           
static int HEIGHT_UNDEFINED
           
static int LAYER_CITY
           
static int LAYER_COUNT
           
static int LAYER_GROUND
           
static int LAYER_RESOURCE
           
static int LAYER_ROAD
           
static int LAYER_TERRAIN
           
static int LAYER_UNITS
           
 
Constructor Summary
Field(int x, int y)
          Constructs a new Field with coordinates (x,y)
Field(int x, int y, int heightLevel)
          Constructs a new Field with coordinates (x,y) and given height-level.
 
Method Summary
 void addUnit(Unit unit)
           
 void addWaterFlow(int nwaterflow)
           
 void addWaterFlowFrom(Field from)
          Saves that water from Field from flows into this field.
 java.util.List getAllUnits()
           
 City getCity()
           
 java.lang.String getDescription()
           
 int getDistanceToCoast()
           
 int getDistanceToSea()
           
 int getFood()
           
static int getHeightConstant(java.lang.String name)
          Returns the heightlevel-constant assigned to the height-level that is given by name.
 int getHeightLevel()
           
static java.lang.String getHeightString(int height)
          Returns a String with the name of the height-level that is given by height.
 int getHumidity()
           
 java.lang.String getLayer(int layer)
           
 java.lang.String getName()
           
 java.lang.String getName(int layer)
           
 Nation getOwnerShip()
           
 int getPopulation()
           
 Coordinate getPosition()
           
 int getPressure()
           
 int getProduction()
           
 int getSpeedFactor()
           
 int getTemperature()
           
 int getTrade()
           
 Unit getUnit(int n)
           
 int getUnitCount()
           
 java.util.Iterator getUnitIterator()
           
 int getWaterFlow()
           
 Field[] getWaterFlowFrom()
          Returns an array with all Field where water flows into this Field.
 Field getWaterFlowTo()
          Returns which Field the water from this Field flows to.
 boolean hasCity()
           
 void increasePopulation(int population)
           
 void insertUnit(Unit unit)
           
 boolean isDeepSea()
           
 boolean isHighMountain()
           
 boolean isHills()
           
static boolean isLand(int hlevel)
          Returns if the given height-level-constant represents land.
 boolean isLandVolcano()
           
 boolean isMountain()
           
 boolean isNormalSea()
           
 boolean isPlain()
           
static boolean isSea(int hlevel)
          Returns if the given height-level-constant represents sea.
 boolean isSeaMountain()
           
 boolean isSeaVolcano()
           
 boolean isShallowSea()
           
 boolean isThisLand()
          Returns if this field is land.
 boolean isThisSea()
          Returns if this field is sea.
 void removeUnit(Unit unit)
           
 void setCity(City city)
           
 void setDescription(java.lang.String des)
           
 void setDistanceToCoast(int ndistancetocoast)
           
 void setDistanceToSea(int ndistancetosea)
           
 void setFood(int i)
           
 void setHeightLevel(int heightLevel)
           
 void setHumidity(int humidity)
           
 void setLayer(int layer, java.lang.String layerData)
           
 void setName(java.lang.String name)
           
 void setName(java.lang.String name, int layer)
           
 void setOwner(Nation owner)
           
 void setPopulation(int population)
           
 void setPressure(int npressure)
           
 void setProduction(int i)
           
 void setTemperature(int temperature)
           
 void setTrade(int i)
           
 void setValues(VegetationData data, int whichlayer, int maptype)
           
 void setWaterFlow(int nwaterflow)
           
 void setWaterFlowTo(Field to)
          Saves that water from this field flows to Field to.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LAYER_GROUND

public static final int LAYER_GROUND
See Also:
Constant Field Values

LAYER_TERRAIN

public static final int LAYER_TERRAIN
See Also:
Constant Field Values

LAYER_RESOURCE

public static final int LAYER_RESOURCE
See Also:
Constant Field Values

LAYER_ROAD

public static final int LAYER_ROAD
See Also:
Constant Field Values

LAYER_CITY

public static final int LAYER_CITY
See Also:
Constant Field Values

LAYER_UNITS

public static final int LAYER_UNITS
See Also:
Constant Field Values

LAYER_COUNT

public static final int LAYER_COUNT
See Also:
Constant Field Values

HEIGHT_SEA_VOLCANO

public static final int HEIGHT_SEA_VOLCANO
See Also:
Constant Field Values

HEIGHT_SEA_MOUNTAIN

public static final int HEIGHT_SEA_MOUNTAIN
See Also:
Constant Field Values

HEIGHT_DEEP_SEA

public static final int HEIGHT_DEEP_SEA
See Also:
Constant Field Values

HEIGHT_SEA

public static final int HEIGHT_SEA
See Also:
Constant Field Values

HEIGHT_SHALLOW_SEA

public static final int HEIGHT_SHALLOW_SEA
See Also:
Constant Field Values

HEIGHT_UNDEFINED

public static final int HEIGHT_UNDEFINED
See Also:
Constant Field Values

HEIGHT_PLAIN

public static final int HEIGHT_PLAIN
See Also:
Constant Field Values

HEIGHT_HILLS

public static final int HEIGHT_HILLS
See Also:
Constant Field Values

HEIGHT_MOUNTAIN

public static final int HEIGHT_MOUNTAIN
See Also:
Constant Field Values

HEIGHT_HIGH_MOUNTAIN

public static final int HEIGHT_HIGH_MOUNTAIN
See Also:
Constant Field Values

HEIGHT_LAND_VOLCANO

public static final int HEIGHT_LAND_VOLCANO
See Also:
Constant Field Values
Constructor Detail

Field

public Field(int x,
             int y)
Constructs a new Field with coordinates (x,y)


Field

public Field(int x,
             int y,
             int heightLevel)
Constructs a new Field with coordinates (x,y) and given height-level.

Method Detail

getPosition

public Coordinate getPosition()

isLand

public static boolean isLand(int hlevel)
Returns if the given height-level-constant represents land.


isSea

public static boolean isSea(int hlevel)
Returns if the given height-level-constant represents sea.


isThisLand

public boolean isThisLand()
Returns if this field is land.


isThisSea

public boolean isThisSea()
Returns if this field is sea.


isSeaVolcano

public boolean isSeaVolcano()

isSeaMountain

public boolean isSeaMountain()

isDeepSea

public boolean isDeepSea()

isNormalSea

public boolean isNormalSea()

isShallowSea

public boolean isShallowSea()

isPlain

public boolean isPlain()

isHills

public boolean isHills()

isMountain

public boolean isMountain()

isHighMountain

public boolean isHighMountain()

isLandVolcano

public boolean isLandVolcano()

getPopulation

public int getPopulation()

setPopulation

public void setPopulation(int population)

increasePopulation

public void increasePopulation(int population)

getOwnerShip

public Nation getOwnerShip()

setOwner

public void setOwner(Nation owner)

setFood

public void setFood(int i)

getFood

public int getFood()

setProduction

public void setProduction(int i)

getProduction

public int getProduction()

setTrade

public void setTrade(int i)

getTrade

public int getTrade()

getSpeedFactor

public int getSpeedFactor()

setDescription

public void setDescription(java.lang.String des)

getDescription

public java.lang.String getDescription()

setName

public void setName(java.lang.String name,
                    int layer)

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

getName

public java.lang.String getName(int layer)

setValues

public void setValues(VegetationData data,
                      int whichlayer,
                      int maptype)

setPressure

public void setPressure(int npressure)

getPressure

public int getPressure()

getTemperature

public int getTemperature()

getHumidity

public int getHumidity()

setTemperature

public void setTemperature(int temperature)

setHumidity

public void setHumidity(int humidity)

setWaterFlow

public void setWaterFlow(int nwaterflow)

addWaterFlow

public void addWaterFlow(int nwaterflow)

getWaterFlow

public int getWaterFlow()

setWaterFlowTo

public void setWaterFlowTo(Field to)
Saves that water from this field flows to Field to. Overrides previously saved to-fields.


getWaterFlowTo

public Field getWaterFlowTo()
Returns which Field the water from this Field flows to.


addWaterFlowFrom

public void addWaterFlowFrom(Field from)
Saves that water from Field from flows into this field.


getWaterFlowFrom

public Field[] getWaterFlowFrom()
Returns an array with all Field where water flows into this Field.


setDistanceToSea

public void setDistanceToSea(int ndistancetosea)

getDistanceToSea

public int getDistanceToSea()

setDistanceToCoast

public void setDistanceToCoast(int ndistancetocoast)

getDistanceToCoast

public int getDistanceToCoast()

getLayer

public java.lang.String getLayer(int layer)

setLayer

public void setLayer(int layer,
                     java.lang.String layerData)

getUnit

public Unit getUnit(int n)

getUnitCount

public int getUnitCount()

getAllUnits

public java.util.List getAllUnits()

addUnit

public void addUnit(Unit unit)

insertUnit

public void insertUnit(Unit unit)

removeUnit

public void removeUnit(Unit unit)

getUnitIterator

public java.util.Iterator getUnitIterator()

setCity

public void setCity(City city)

getCity

public City getCity()

hasCity

public boolean hasCity()

getHeightLevel

public int getHeightLevel()

setHeightLevel

public void setHeightLevel(int heightLevel)

getHeightConstant

public static int getHeightConstant(java.lang.String name)
Returns the heightlevel-constant assigned to the height-level that is given by name. Returns HEIGHT_UNDEFINED if name doesn't match any height-level.


getHeightString

public static java.lang.String getHeightString(int height)
Returns a String with the name of the height-level that is given by height. Returns HEIGHTLEVEL x NOT DEFINED if height doesn't match any height-level.


toString

public java.lang.String toString()