j4cevo
Class Tile

java.lang.Object
  extended byj4cevo.Tile

public class Tile
extends java.lang.Object

A Tile is a location on the map.


Nested Class Summary
static class Tile.BattleForecast
           
static class Tile.Info
           
static class Tile.RessourceInfo
           
 
Field Summary
static Protocol.TerrainType fArctic
           
static Protocol.TerrainType fDesert
           
static Protocol.TerrainType fForest
           
static Protocol.TerrainType fGrass
           
static Protocol.TerrainType fHills
           
static Protocol.TerrainType fMountains
           
static Protocol.TerrainType fOcean
           
static Protocol.TerrainType fPrairie
           
static Protocol.TerrainType fShore
           
static Protocol.TerrainType fSwamp
           
static Protocol.TerrainType fTundra
           
 
Method Summary
 int distance(Tile destination)
          distance measures long (transversal) moves with 3, other (short moves) with 2.
 int getBattleForecast(Tile.BattleForecast forecast, int modelIndex, int experience, int health, int flags, int movement, int playerIndex)
           
static int getBattleForecast(Tile.BattleForecast forecast, int modelIndex, int experience, int health, int flags, int movementPointsLeft, int playerIndex, int locationIndex)
           
 int getBattleForecast(Tile.BattleForecast forecast, ModelBase model, int experience, int health, int flags, int movement)
          This query allows to simulate an attack of a hypothetical attacker on an existing defender.
 int getBattleForecast(Tile.BattleForecast forecast, UnitBase u, int movementPointsLeft)
           
 Tile.Info getCityTileInfo()
          Gets exact resource production of a tile for the city which is currently exploiting it.
 int getDamage()
          Gets resource production of a tile for the city which is currently hypothetically exploiting it.
static int getDamage(int tileValue)
          evaluates the percentual damage for ground units when spending movementpoints there does not matter if player owns hanging gardens wonder
 Unit getDefender()
          Gets the own unit which will defend a certain tile.
 java.lang.String getFlagNames()
           
 int getIndex()
           
 Tile.Info getInfo()
          Request resource production of a tile.
 int getLastObserved()
          Gets the turn this tile has been observed last
static int getMovementCost(int startValue, boolean transversal, int endValue, Model model, boolean hasShinkansen)
           
 int getMovementCost(int dx, int dy, Model model)
           
 PlayerBase getOwner()
          Gets the owner of a tile, if any
 Tile.RessourceInfo getRessourceInfo()
          Gets the ressource production considering terrain type and specialFlags only.
 Protocol.TerrainType getTerrainType()
           
static Protocol.TerrainType getTerrainType(int tileValue)
           
 java.util.Iterator getUnits()
           
 boolean hasCity()
           
static boolean hasCity(int tileValue)
           
 boolean hasEnemyCity()
           
static boolean hasEnemyCity(int tileValue)
           
 boolean hasEnemyUnit()
           
static boolean hasEnemyUnit(int tileValue)
           
 int hashCode()
           
static boolean hasRailRoad(int tileValue)
           
 boolean hasRoad()
           
static boolean hasRoad(int tileValue)
           
 boolean hasUnit()
           
static boolean hasUnit(int tileValue)
           
 boolean hasWater()
           
 boolean hasWaterAccess()
           
 java.lang.String identification()
           
 boolean isIrrigatable()
          Queries, wheter this tile is irrigatable at all To actually irrigate it, you need waterAccess also
 boolean isSet(int flag)
          Queries whether a flag is set.
static boolean isSet(int tileValue, int flag)
           
 boolean mayEnter(Model model)
           
static boolean mayEnter(Model model, int tileValue)
           
 void movement(Tile destination, Map.RelativeMovement r)
          Fills in the required movement to get from this tile to destination tile
 boolean requiresBridge()
           
 Tile tileRelativeAt(int dx, int dy)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fArctic

public static final Protocol.TerrainType fArctic

fDesert

public static final Protocol.TerrainType fDesert

fForest

public static final Protocol.TerrainType fForest

fGrass

public static final Protocol.TerrainType fGrass

fHills

public static final Protocol.TerrainType fHills

fMountains

public static final Protocol.TerrainType fMountains

fOcean

public static final Protocol.TerrainType fOcean

fPrairie

public static final Protocol.TerrainType fPrairie

fShore

public static final Protocol.TerrainType fShore

fSwamp

public static final Protocol.TerrainType fSwamp

fTundra

public static final Protocol.TerrainType fTundra
Method Detail

getBattleForecast

public final int getBattleForecast(Tile.BattleForecast forecast,
                                   int modelIndex,
                                   int experience,
                                   int health,
                                   int flags,
                                   int movement,
                                   int playerIndex)

getBattleForecast

public final int getBattleForecast(Tile.BattleForecast forecast,
                                   UnitBase u,
                                   int movementPointsLeft)

getBattleForecast

public final int getBattleForecast(Tile.BattleForecast forecast,
                                   ModelBase model,
                                   int experience,
                                   int health,
                                   int flags,
                                   int movement)
This query allows to simulate an attack of a hypothetical attacker on an existing defender. Restrictions: the attacked tile must be observed. The server return code is equal to an sMoveUnit that would order this attack.

Parameters:
forecast - object to hold the forecast
experience - the experience of the attacking unit
health - the health of the attacking unit
flags - the flags of the attacking unit
model - the model of the attacking unit
movement -
Returns:
serverCode

getCityTileInfo

public final Tile.Info getCityTileInfo()
Gets exact resource production of a tile for the city which is currently exploiting it. All factors are taken into consideration. Works only for tiles which are exploited by own cities.

Returns:
The cityTileInfo

getDamage

public final int getDamage()
Gets resource production of a tile for the city which is currently hypothetically exploiting it. All factors are taken into consideration.

Returns:
The TileInfo

getDefender

public Unit getDefender()
Gets the own unit which will defend a certain tile. (For enemy locations, this is not necessary because you only know the defender.)

Returns:
the unit or null if the server responds other than eOK

getFlagNames

public java.lang.String getFlagNames()

hashCode

public int hashCode()

getIndex

public final int getIndex()

getInfo

public final Tile.Info getInfo()
Request resource production of a tile. Considers government form, wonders and national projects, but no city improvements. Works for all known tiles.

Returns:
The info

getLastObserved

public int getLastObserved()
Gets the turn this tile has been observed last

Returns:
the turn this tile has been observed last

getMovementCost

public int getMovementCost(int dx,
                           int dy,
                           Model model)

getOwner

public PlayerBase getOwner()
Gets the owner of a tile, if any

Returns:
the owner or null, if getOwner() == player cast to Player, else to Enemy

getRessourceInfo

public Tile.RessourceInfo getRessourceInfo()
Gets the ressource production considering terrain type and specialFlags only.

Returns:
The ressourceInfo value

getTerrainType

public final Protocol.TerrainType getTerrainType()

getUnits

public java.util.Iterator getUnits()

isIrrigatable

public boolean isIrrigatable()
Queries, wheter this tile is irrigatable at all To actually irrigate it, you need waterAccess also

Returns:
The irrigatable value
See Also:
hasWaterAccess()

isSet

public final boolean isSet(int flag)
Queries whether a flag is set.

Parameters:
flag - the flag to be queried
Returns:
whether the flag is set
See Also:
Protocol.TileFlags

distance

public int distance(Tile destination)
distance measures long (transversal) moves with 3, other (short moves) with 2. This is the same relation as movement costs for Domain.Air and Domain.Naval if you can use the shortest path to destination

Parameters:
destination -

hasCity

public final boolean hasCity()

hasEnemyCity

public final boolean hasEnemyCity()

hasEnemyUnit

public final boolean hasEnemyUnit()

hasUnit

public final boolean hasUnit()

hasWater

public boolean hasWater()

hasWaterAccess

public boolean hasWaterAccess()

identification

public java.lang.String identification()

mayEnter

public final boolean mayEnter(Model model)

movement

public void movement(Tile destination,
                     Map.RelativeMovement r)
Fills in the required movement to get from this tile to destination tile

Parameters:
r - to incorporate the relative x and y distances
destination - movement

requiresBridge

public final boolean requiresBridge()

tileRelativeAt

public final Tile tileRelativeAt(int dx,
                                 int dy)

toString

public java.lang.String toString()

getBattleForecast

public static final int getBattleForecast(Tile.BattleForecast forecast,
                                          int modelIndex,
                                          int experience,
                                          int health,
                                          int flags,
                                          int movementPointsLeft,
                                          int playerIndex,
                                          int locationIndex)

getDamage

public static int getDamage(int tileValue)
evaluates the percentual damage for ground units when spending movementpoints there does not matter if player owns hanging gardens wonder

Parameters:
tileValue -
Returns:
The damage value

getMovementCost

public static int getMovementCost(int startValue,
                                  boolean transversal,
                                  int endValue,
                                  Model model,
                                  boolean hasShinkansen)

getTerrainType

public static final Protocol.TerrainType getTerrainType(int tileValue)

isSet

public static final boolean isSet(int tileValue,
                                  int flag)

hasCity

public static final boolean hasCity(int tileValue)

hasEnemyCity

public static final boolean hasEnemyCity(int tileValue)

hasEnemyUnit

public static final boolean hasEnemyUnit(int tileValue)

hasRailRoad

public static boolean hasRailRoad(int tileValue)

hasRoad

public boolean hasRoad()

hasRoad

public static boolean hasRoad(int tileValue)

hasUnit

public static final boolean hasUnit(int tileValue)

mayEnter

public static final boolean mayEnter(Model model,
                                     int tileValue)


generated: 20050107