|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object civquest.MapData
Contains all display-agnostic information about a map. Is designed for use with 2D-maps that can be saved in a (two-dimensional) array. MapView-ers work on objects of this class. Some definitions: An array-coordinate is a coordinate within the (subclass-internal) array that saves the data. A map-coordinate is an array-coordinate that marks a Field.
Nested Class Summary | |
protected class |
MapData.Configuration
|
Field Summary | |
static short |
EQUAL_TO
|
protected Field[][] |
fields
Each object of this array stores that data for one field on the map. |
static short |
GREATER_THAN
|
protected int |
mapHeight
Height of the map. |
protected Registry |
mapRegistry
|
protected int |
mapWidth
Width of the map. |
protected Registry |
moveCalcRegistry
|
static short |
SMALLER_THAN
|
Constructor Summary | |
MapData(int width,
int height,
boolean nflatearth,
int nminbigriverwf,
Registry registry)
Constructs the object. |
Method Summary | |
void |
addCity(City city,
Field field,
Nation nation)
Adds a city. |
void |
addMapChangeListener(MapChangeListener mcl)
|
void |
addUnit(Unit unit,
Field field,
Nation nation)
Adds a unit. |
boolean |
adjustsToLand(Coordinate coord)
|
boolean |
adjustsToSea(Coordinate coord)
Returns if the field specified by coord adjusts to sea (in directions N, NE, E, ..., NW) |
abstract Coordinate |
adjustToMapSize(Coordinate coord)
Adjusts the given coordinate to mapsize. |
Coordinate |
adjustToMapSize(int x,
int y)
|
boolean |
areIncompleteMovesAllowed()
|
abstract boolean |
areNeighborCoords(Coordinate coord1,
Coordinate coord2)
Returns if the two given Coordinates are neighbor-Coordinates. |
boolean |
calculateDistanceFromCoast()
|
boolean |
calculateDistanceFromSea()
Calculates for all Fields on the map how far they are away from sea. |
int |
distanceFromHeightLevel(int heightLevel,
Coordinate b,
int timeout,
int operator)
Gets distance from the current tile to (and included) the tile the meets the requested heightlevel. |
abstract Coordinate |
getAreaCoord(Rectangle rect,
Coordinate coord)
Translates the given Coordinate (by map-sizes) to be in the specified rectangle. |
abstract int |
getArrayHeight()
Returns the height of the internal array that stores the Fields. |
abstract int |
getArrayWidth()
Returns the width of the internal array that stores the Fields. |
City |
getCity(long id)
|
java.util.Iterator |
getCityIterator()
|
Field[] |
getCoasts(Coordinate coord)
|
abstract MapData.Configuration |
getConfiguration()
|
Field |
getField(Coordinate c)
|
Field |
getField(int x,
int y)
Returns the field at the given (array)-coordinate. |
int |
getMapHeight()
|
int |
getMapWidth()
|
int |
getMinBigRiverWaterFlow()
|
MoveCalculator |
getMoveCalculator()
|
abstract int |
getNeighborFieldDist(Field f1,
Field f2)
Returns the distance between the two given _neighbor_-fields. |
abstract FieldDistanceInfo[] |
getNeighborFieldDists(Field field)
Returns an array with FieldDistanceInfo-objects for each neighbor-field of the given Field. |
abstract Field[] |
getNeighborFields(Field field)
|
abstract Coordinate |
getRandomCoordinate()
Returns a random map-coordinate. |
Unit |
getUnit(long id)
|
java.util.Iterator |
getUnitIterator()
|
boolean |
hasNeighborFieldDistanceToCoast(Field field,
int distance)
Returns if any of the 8 neighborfields of the given field has the given distanceToCoast. |
boolean |
hasNeighborFieldDistanceToSea(Field field,
int distance)
Returns if any of the 8 neighborfields of the given field has the given distanceToSea. |
abstract boolean |
isArrayCoordOnMap(Coordinate coord)
|
abstract boolean |
isArrayCoordOnMap(int x,
int y)
|
boolean |
isFlatEarth()
|
abstract boolean |
isOnEastEdge(Coordinate coord)
See isOnNorthEdge |
abstract boolean |
isOnMap(Coordinate coord)
|
abstract boolean |
isOnMap(int x,
int y)
|
boolean |
isOnMapEdge(Coordinate coord)
Returns false if field |
abstract boolean |
isOnNorthEdge(Coordinate coord)
A coordinate is on the northern edge if there is no map-coordinate that is north, northeast or northwest of it. |
abstract boolean |
isOnSouthEdge(Coordinate coord)
See isOnNorthEdge |
abstract boolean |
isOnWestEdge(Coordinate coord)
See isOnNorthEdge |
boolean |
isPressureUsed()
|
abstract Coordinate |
mapCoordinate(Coordinate coord)
|
void |
setCityOwner(City city,
Nation nation)
Sets the owner of |
void |
setHeightLevel(int x,
int y,
int hlevel)
|
void |
setMinBigRiverWaterFlow(int nminbigriverwf)
|
void |
setPressureUsed(boolean npressureused)
|
void |
setUnitOwner(Unit unit,
Nation nation)
Sets the owner of a unit. |
void |
setUnitPosition(Unit unit,
Field field)
Sets the position of the given Unit to the given Field. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Registry mapRegistry
protected Registry moveCalcRegistry
protected int mapHeight
protected int mapWidth
protected Field[][] fields
public static final short SMALLER_THAN
public static final short EQUAL_TO
public static final short GREATER_THAN
Constructor Detail |
public MapData(int width, int height, boolean nflatearth, int nminbigriverwf, Registry registry)
Method Detail |
public abstract Coordinate mapCoordinate(Coordinate coord)
public int getMapHeight()
public int getMapWidth()
public boolean isFlatEarth()
public void setPressureUsed(boolean npressureused)
public boolean isPressureUsed()
public void setMinBigRiverWaterFlow(int nminbigriverwf)
public int getMinBigRiverWaterFlow()
public void addMapChangeListener(MapChangeListener mcl)
public MoveCalculator getMoveCalculator()
public Field getField(int x, int y)
public Field getField(Coordinate c)
public void setHeightLevel(int x, int y, int hlevel)
public Field[] getCoasts(Coordinate coord)
public boolean calculateDistanceFromCoast()
public boolean calculateDistanceFromSea()
public boolean hasNeighborFieldDistanceToCoast(Field field, int distance)
public boolean hasNeighborFieldDistanceToSea(Field field, int distance)
public int distanceFromHeightLevel(int heightLevel, Coordinate b, int timeout, int operator)
public boolean adjustsToSea(Coordinate coord)
public boolean adjustsToLand(Coordinate coord)
public Unit getUnit(long id)
public java.util.Iterator getUnitIterator()
public void addUnit(Unit unit, Field field, Nation nation)
unit
- field
- nation
- public void setUnitPosition(Unit unit, Field field)
unit
- field
- public void setUnitOwner(Unit unit, Nation nation)
unit
- nation
- public City getCity(long id)
public java.util.Iterator getCityIterator()
public void addCity(City city, Field field, Nation nation)
city
- a city, may not be nullnation
- nation that should own the city, may be null, then, no one
will own the cityfield
- field to place the city on, may not be null, may not contain
a city beforepublic void setCityOwner(City city, Nation nation)
city
- a city, may not be nullnation
- a nation, may not be nullpublic abstract int getArrayWidth()
public abstract int getArrayHeight()
public abstract Coordinate adjustToMapSize(Coordinate coord)
public Coordinate adjustToMapSize(int x, int y)
public boolean isOnMapEdge(Coordinate coord)
public abstract boolean isArrayCoordOnMap(Coordinate coord)
public abstract boolean isArrayCoordOnMap(int x, int y)
public abstract boolean isOnMap(Coordinate coord)
public abstract boolean isOnMap(int x, int y)
public abstract boolean isOnNorthEdge(Coordinate coord)
public abstract boolean isOnEastEdge(Coordinate coord)
public abstract boolean isOnSouthEdge(Coordinate coord)
public abstract boolean isOnWestEdge(Coordinate coord)
public abstract Coordinate getAreaCoord(Rectangle rect, Coordinate coord)
public abstract Coordinate getRandomCoordinate()
public abstract boolean areNeighborCoords(Coordinate coord1, Coordinate coord2)
public abstract int getNeighborFieldDist(Field f1, Field f2)
f1
- any Fieldf2
- any Field
public abstract Field[] getNeighborFields(Field field)
public abstract FieldDistanceInfo[] getNeighborFieldDists(Field field)
field
- any Field
public abstract MapData.Configuration getConfiguration()
public boolean areIncompleteMovesAllowed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |