net.sf.freecol.common.model
Class Tile

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObject
          extended by net.sf.freecol.common.model.Tile
All Implemented Interfaces:
Location, Ownable, Typed<TileType>

public final class Tile
extends FreeColGameObject
implements Location, Ownable, Typed<TileType>

Represents a single tile on the Map.

See Also:
Map

Field Summary
static java.lang.String UNIT_CHANGE
           
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
Tile(Game game, org.w3c.dom.Element e)
          Initialize this object from an XML-representation of this object.
Tile(Game game, java.lang.String id)
          Initiates a new Tile with the given ID.
Tile(Game game, TileType type, int locX, int locY)
          A constructor to use.
Tile(Game game, javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 
Method Summary
 void add(Locatable locatable)
          Adds a Locatable to this Location.
 void addUnitNoUpdate(Unit unit)
          Adds the unit to the tile.
 boolean canAdd(Locatable locatable)
          Checks whether or not the specified locatable may be added to this Location.
 boolean canGetRoad()
          Checks whether this Tile can have a road or not.
 boolean canMoveToEurope()
          Get the MoveToEurope value.
 boolean claimable(Player player)
          Can the ownership of this tile be claimed? Quick test that does not handle the curly case of tile transfer between colonies, or guarantee success (natives may want to be paid), but just that success is possible.
 boolean contains(Locatable locatable)
          Checks if this Tile contains the specified Locatable.
 void dispose()
          Removes all references to this object.
 void disposeAllUnits()
          Disposes all units on this Tile.
 void expendResource(GoodsType goodsType, UnitType unitType, Settlement settlement)
          This method is called only when a new turn is beginning.
 TileImprovement findTileImprovementType(TileImprovementType type)
          Finds the TileImprovement of a given Type, or null if there is no match.
 Colony getColony()
          Gets the Colony located on this Tile.
 java.util.List<TileImprovement> getCompletedTileImprovements()
          Returns a List of completed TileImprovements.
 Unit getDefendingUnit(Unit attacker)
          Gets the Unit that is currently defending this Tile.
 Region getDiscoverableRegion()
          Return the discoverable Region of this Tile, or null if there is none.
 int getDistanceTo(Tile tile)
          Gets the distance in tiles between this Tile and the specified one.
 Unit getFirstUnit()
          Gets the first Unit on this tile.
 GoodsContainer getGoodsContainer()
          Returns null.
 Unit getLastUnit()
          Gets the last Unit on this tile.
 LostCityRumour getLostCityRumour()
          Returns the lost city rumour on this Tile if any
 Map getMap()
          Gets the Map in which this Tile belongs.
 int getMaximumPotential(GoodsType goodsType, UnitType unitType)
          Gets the maximum potential for producing the given type of goods.
 Unit getMovableUnit()
          Gets a Unit that can become active.
 int getMoveCost(Tile fromTile)
          Returns the cost of moving onto this tile from a given Tile.
 Tile getNeighbourOrNull(Map.Direction d)
          Describe getNeighbourOrNull method here.
 Unit getOccupyingUnit()
          Returns the unit who is occupying the tile
 Player getOwner()
          The nation that consider this tile to be their property.
 Settlement getOwningSettlement()
          Gets the owner of this tile.
 PlayerExploredTile getPlayerExploredTile(Player player)
          Gets the PlayerExploredTile for the given Player.
 Map.Position getPosition()
          Gets the Position of this Tile.
 java.util.Set<Modifier> getProductionBonus(GoodsType goodsType, UnitType unitType)
          Describe getProductionBonus method here.
 Region getRegion()
          Get the Region value.
 TileImprovement getRiver()
          Returns the river on this Tile if any
 int getRiverStyle()
          Returns the style of a river TileImprovement on this Tile.
 TileImprovement getRoad()
          Returns the road on this tile, if there is one, and null otherwise.
 Settlement getSettlement()
          Gets the Settlement located on this Tile.
 java.util.List<AbstractGoods> getSortedPotential()
          Sorts GoodsTypes according to potential based on TileType, TileItemContainer if any.
 java.util.List<AbstractGoods> getSortedPotential(Unit unit)
          Sorts GoodsTypes according to potential based on TileType, TileItemContainer if any.
 java.util.List<AbstractGoods> getSortedPotential(UnitType unitType, Player owner)
          Sorts GoodsTypes according to potential based on TileType, TileItemContainer if any.
 int getStyle()
          Get the Style value.
 Tile getTile()
          Gets the Tile where this Location is located or null if no Tile applies.
 java.util.List<TileImprovement> getTileImprovements()
          Returns a List of TileImprovements.
 TileItemContainer getTileItemContainer()
          Returns the TileItemContainer.
static int getTileTypePotential(TileType tileType, GoodsType goodsType, TileItemContainer tiContainer, UnitType unitType)
          Calculates the potential of a certain GoodsType.
 int getTotalUnitCount()
          Returns the total amount of Units at this Location.
 TileType getType()
          Returns the type of this Tile.
 int getUnitCount()
          Returns the amount of units at this Location.
 java.util.Iterator<Unit> getUnitIterator()
          Gets an Iterator of every Unit directly located on this Tile.
 java.util.List<Unit> getUnitList()
          Gets a List/code> of every Unit directly located on this Tile.
 int getWorkAmount(TileImprovementType workType)
          Returns the number of turns it takes for a non-expert pioneer to perform the given TileImprovementType.
 int getX()
          Returns the x-coordinate of this Tile.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 int getY()
          Returns the y-coordinate of this Tile.
 boolean hasImprovement(TileImprovementType type)
          Will check whether this tile has a completed improvement of the given type.
 boolean hasLostCityRumour()
          Returns true if this Tile has a lostCityRumour on it.
 boolean hasResource()
          Returns true if this Tile has a resource on it.
 boolean hasRiver()
          Returns true if this Tile has a River.
 boolean hasRoad()
          Returns true if this Tile has a road.
 boolean hasUnexploredAdjacent()
          Determine whether this tile has adjacent tiles that are unexplored.
 boolean isAdjacent(Tile tile)
          Determines whether this tile is adjacent to the specified tile.
 boolean isCoast()
          Returns true if this tile has at least one adjacent land tile (if water), or at least one adjacent water tile (if land).
 boolean isColonizeable()
          Check to see if this tile can be used to construct a new Colony.
 boolean isConnected()
          Whether this tile is connected to Europe.
 boolean isExplored()
          Check if the tile has been explored.
 boolean isExploredBy(Player player)
          Checks if this Tile has been explored by the given Player.
 boolean isForested()
          Returns true if this Tile is forested.
 boolean isLand()
          Returns true if this Tile is a land Tile, 'false' otherwise.
 boolean isOccupied()
          Checks whether there is a fortified enemy unit in the tile.
 boolean isSettleable()
          Check if the tile type is suitable for a Settlement, either by a Colony or an IndianSettlement.
 boolean isViewShared()
           
 int potential(GoodsType goodsType, UnitType unitType)
          The potential of this tile to produce a certain type of goods.
 GoodsType primaryGoods()
          The type of primary good (food) this tile produces best (used for Town Commons squares).
 void remove(Locatable locatable)
          Removes a Locatable from this Location.
 void removeLostCityRumour()
          Removes the lost city rumour from this Tile if there is one.
 void removeUnitNoUpdate(Unit unit)
          Removes the unit from the tile.
 GoodsType secondaryGoods()
          The type of secondary good (non-food) this tile produces best (used for Town Commons squares).
 void setConnected(boolean newConnected)
          Set the Connected value.
 void setExploredBy(Player player, boolean explored)
          Sets this Tile to be explored by the given Player.
 void setMoveToEurope(java.lang.Boolean newMoveToEurope)
          Set the MoveToEurope value.
 void setOwner(Player owner)
          Sets the nation that should consider this tile to be their property.
 void setOwningSettlement(Settlement owner)
          Sets the owner of this tile.
 void setRegion(Region newRegion)
          Set the Region value.
 void setResource(ResourceType r)
          Sets the Resource for this Tile
 void setSettlement(Settlement s)
          Puts a Settlement on this Tile.
 void setStyle(int newStyle)
          Set the Style value.
 void setTileItemContainer(TileItemContainer newTileItemContainer)
          Sets the TileItemContainer.
 void setType(TileType t)
          Sets the type for this Tile.
 java.lang.String toString()
          Returns a String representation of this Tile.
 void toXMLMinimal(javax.xml.stream.XMLStreamWriter out)
           
 void updateIndianSettlementInformation(Player player)
          Updates the information about the IndianSettlement located on this Tile.
 void updateIndianSettlementSkill(Player player)
          Updates the skill available from the IndianSettlement located on this Tile.
 void updatePlayerExploredTile(Player player)
          Updates the information about this Tile for the given Player.
 void updatePlayerExploredTiles()
          Updates the PlayerExploredTile for each player.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
addToRemoveElement, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toXML, updateFreeColGameObject, updateID
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.freecol.common.model.Location
getId
 

Field Detail

UNIT_CHANGE

public static final java.lang.String UNIT_CHANGE
See Also:
Constant Field Values
Constructor Detail

Tile

public Tile(Game game,
            TileType type,
            int locX,
            int locY)
A constructor to use.

Parameters:
game - The Game this Tile belongs to.
type - The type.
locX - The x-position of this tile on the map.
locY - The y-position of this tile on the map.

Tile

public Tile(Game game,
            javax.xml.stream.XMLStreamReader in)
     throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Parameters:
game - The Game this Tile should be created in.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

Tile

public Tile(Game game,
            org.w3c.dom.Element e)
Initialize this object from an XML-representation of this object.

Parameters:
game - The Game this Tile should be created in.
e - An XML-element that will be used to initialize this object.

Tile

public Tile(Game game,
            java.lang.String id)
Initiates a new Tile with the given ID. The object should later be initialized by calling either FreeColGameObject.readFromXML(XMLStreamReader) or FreeColObject.readFromXMLElement(Element).

Parameters:
game - The Game in which this object belong.
id - The unique identifier for this object.
Method Detail

isViewShared

public boolean isViewShared()

getRegion

public Region getRegion()
Get the Region value.

Returns:
a Region value

setRegion

public void setRegion(Region newRegion)
Set the Region value.

Parameters:
newRegion - The new Region value.

getDiscoverableRegion

public Region getDiscoverableRegion()
Return the discoverable Region of this Tile, or null if there is none.

Returns:
a Region value

getStyle

public int getStyle()
Get the Style value.

Returns:
an int value

setStyle

public void setStyle(int newStyle)
Set the Style value.

Parameters:
newStyle - The new Style value.

getDistanceTo

public int getDistanceTo(Tile tile)
Gets the distance in tiles between this Tile and the specified one.

Parameters:
tile - The Tile to check the distance to.
Returns:
Distance

getGoodsContainer

public GoodsContainer getGoodsContainer()
Returns null.

Specified by:
getGoodsContainer in interface Location
Returns:
null

getTileItemContainer

public TileItemContainer getTileItemContainer()
Returns the TileItemContainer.

Returns:
a TileItemContainer value

setTileItemContainer

public void setTileItemContainer(TileItemContainer newTileItemContainer)
Sets the TileItemContainer.

Parameters:
newTileItemContainer - a TileItemContainer value

getTileImprovements

public java.util.List<TileImprovement> getTileImprovements()
Returns a List of TileImprovements.

Returns:
a List of TileImprovements

getCompletedTileImprovements

public java.util.List<TileImprovement> getCompletedTileImprovements()
Returns a List of completed TileImprovements.

Returns:
a List of TileImprovements

getDefendingUnit

public Unit getDefendingUnit(Unit attacker)
Gets the Unit that is currently defending this Tile.

If this tile has a settlement, the units inside the settlement are also considered as potential defenders.

As this method is quite expensive, it should not be used to test for the presence of enemy units.

Parameters:
attacker - The target that would be attacking this tile.
Returns:
The Unit that has been chosen to defend this tile.

getMoveCost

public int getMoveCost(Tile fromTile)
Returns the cost of moving onto this tile from a given Tile.

This method does not take special unit behavior into account. Use Unit.getMoveCost(net.sf.freecol.common.model.Tile) whenever it is possible.

Parameters:
fromTile - The Tile the moving Unit comes from.
Returns:
The cost of moving the unit.
See Also:
Unit.getMoveCost(net.sf.freecol.common.model.Tile)

disposeAllUnits

public void disposeAllUnits()
Disposes all units on this Tile.


dispose

public void dispose()
Description copied from class: FreeColGameObject
Removes all references to this object.

Overrides:
dispose in class FreeColGameObject

getFirstUnit

public Unit getFirstUnit()
Gets the first Unit on this tile.

Returns:
The first Unit on this tile.

getLastUnit

public Unit getLastUnit()
Gets the last Unit on this tile.

Returns:
The last Unit on this tile.

getTotalUnitCount

public int getTotalUnitCount()
Returns the total amount of Units at this Location. This also includes units in a carrier

Returns:
The total amount of Units at this Location.

contains

public boolean contains(Locatable locatable)
Checks if this Tile contains the specified Locatable.

Specified by:
contains in interface Location
Parameters:
locatable - The Locatable to test the presence of.
Returns:
  • true if the specified Locatable is on this Tile and
  • false otherwise.

getMap

public Map getMap()
Gets the Map in which this Tile belongs.

Returns:
The Map.

isConnected

public boolean isConnected()
Whether this tile is connected to Europe.

Returns:
a boolean value

setConnected

public void setConnected(boolean newConnected)
Set the Connected value.

Parameters:
newConnected - The new Connected value.

canMoveToEurope

public boolean canMoveToEurope()
Get the MoveToEurope value.

Returns:
a Boolean value

setMoveToEurope

public void setMoveToEurope(java.lang.Boolean newMoveToEurope)
Set the MoveToEurope value.

Parameters:
newMoveToEurope - The new MoveToEurope value.

isExplored

public boolean isExplored()
Check if the tile has been explored.

Returns:
true if tile is known.

isLand

public boolean isLand()
Returns true if this Tile is a land Tile, 'false' otherwise.

Returns:
true if this Tile is a land Tile, 'false' otherwise.

isForested

public boolean isForested()
Returns true if this Tile is forested.

Returns:
true if this Tile is forested.

hasRiver

public boolean hasRiver()
Returns true if this Tile has a River.

Returns:
true if this Tile has a River.

hasResource

public boolean hasResource()
Returns true if this Tile has a resource on it.

Returns:
true if this Tile has a resource on it.

hasLostCityRumour

public boolean hasLostCityRumour()
Returns true if this Tile has a lostCityRumour on it.

Returns:
true if this Tile has a lostCityRumour on it.

hasRoad

public boolean hasRoad()
Returns true if this Tile has a road.

Returns:
true if this Tile has a road.

getRoad

public TileImprovement getRoad()
Returns the road on this tile, if there is one, and null otherwise.

Returns:
a TileImprovement value

getType

public TileType getType()
Returns the type of this Tile. Returns UNKNOWN if the type of this Tile is unknown.

Specified by:
getType in interface Typed<TileType>
Returns:
The type of this Tile.

getOwner

public Player getOwner()
The nation that consider this tile to be their property.

Specified by:
getOwner in interface Ownable
Returns:
The player owning this tile.

setOwner

public void setOwner(Player owner)
Sets the nation that should consider this tile to be their property.

Specified by:
setOwner in interface Ownable
Parameters:
owner - The player, new owner of this tile.
See Also:
getOwner()

claimable

public boolean claimable(Player player)
Can the ownership of this tile be claimed? Quick test that does not handle the curly case of tile transfer between colonies, or guarantee success (natives may want to be paid), but just that success is possible.

Parameters:
player - The Player that may wish to claim the tile.
Returns:
True if the tile ownership can be claimed.

getRiver

public TileImprovement getRiver()
Returns the river on this Tile if any

Returns:
River TileImprovement

getLostCityRumour

public LostCityRumour getLostCityRumour()
Returns the lost city rumour on this Tile if any

Returns:
a LostCityRumour value

removeLostCityRumour

public void removeLostCityRumour()
Removes the lost city rumour from this Tile if there is one.


getRiverStyle

public int getRiverStyle()
Returns the style of a river TileImprovement on this Tile.

Returns:
an int value

getNeighbourOrNull

public Tile getNeighbourOrNull(Map.Direction d)
Describe getNeighbourOrNull method here.

Parameters:
d - a Direction value
Returns:
a Tile value

hasUnexploredAdjacent

public boolean hasUnexploredAdjacent()
Determine whether this tile has adjacent tiles that are unexplored.

Returns:
true if at least one neighbouring tiles is unexplored, otherwise false

isCoast

public boolean isCoast()
Returns true if this tile has at least one adjacent land tile (if water), or at least one adjacent water tile (if land).

Returns:
a boolean value

setSettlement

public void setSettlement(Settlement s)
Puts a Settlement on this Tile. A Tile can only have one Settlement located on it. The Settlement will also become the owner of this Tile.

Parameters:
s - The Settlement that shall be located on this Tile.
See Also:
getSettlement()

getSettlement

public Settlement getSettlement()
Gets the Settlement located on this Tile.

Returns:
The Settlement that is located on this Tile or null if no Settlement apply.
See Also:
setSettlement(net.sf.freecol.common.model.Settlement)

getColony

public Colony getColony()
Gets the Colony located on this Tile. Only a convenience method for getSettlement() that makes sure that the settlement is a colony.

Specified by:
getColony in interface Location
Returns:
The Colony that is located on this Tile or null if no Colony apply.
See Also:
getSettlement()

setOwningSettlement

public void setOwningSettlement(Settlement owner)
Sets the owner of this tile. A Settlement become an owner of a Tile when having workers placed on it.

Parameters:
owner - The Settlement that owns this tile.
See Also:
getOwner()

getOwningSettlement

public Settlement getOwningSettlement()
Gets the owner of this tile.

Returns:
The Settlement that owns this tile.
See Also:
setOwner(net.sf.freecol.common.model.Player)

setResource

public void setResource(ResourceType r)
Sets the Resource for this Tile


setType

public void setType(TileType t)
Sets the type for this Tile.

Parameters:
t - The new TileType for this Tile.

getX

public int getX()
Returns the x-coordinate of this Tile.

Returns:
The x-coordinate of this Tile.

getY

public int getY()
Returns the y-coordinate of this Tile.

Returns:
The y-coordinate of this Tile.

getPosition

public Map.Position getPosition()
Gets the Position of this Tile.

Returns:
The Position of this Tile.

isSettleable

public boolean isSettleable()
Check if the tile type is suitable for a Settlement, either by a Colony or an IndianSettlement.

Returns:
true if tile suitable for settlement

isColonizeable

public boolean isColonizeable()
Check to see if this tile can be used to construct a new Colony. If there is a colony here or in a tile next to this one, it is unsuitable for colonization.

Returns:
true if tile is suitable for colonization, false otherwise

getMovableUnit

public Unit getMovableUnit()
Gets a Unit that can become active. This is preferably a Unit not currently performing any work.

Returns:
A Unit with movesLeft > 0 or null if no such Unit is located on this Tile.

getTile

public Tile getTile()
Gets the Tile where this Location is located or null if no Tile applies.

Specified by:
getTile in interface Location
Returns:
This Tile.

add

public void add(Locatable locatable)
Adds a Locatable to this Location.

Specified by:
add in interface Location
Parameters:
locatable - The Locatable to add to this Location.

remove

public void remove(Locatable locatable)
Removes a Locatable from this Location.

Specified by:
remove in interface Location
Parameters:
locatable - The Locatable to remove from this Location.

removeUnitNoUpdate

public void removeUnitNoUpdate(Unit unit)
Removes the unit from the tile. It does not updatePlayerExploredTiles.

Parameters:
unit - The unit to be removed

addUnitNoUpdate

public void addUnitNoUpdate(Unit unit)
Adds the unit to the tile. It does not updatePlayerExploredTiles.

Parameters:
unit - The unit to be added

getUnitCount

public int getUnitCount()
Returns the amount of units at this Location.

Specified by:
getUnitCount in interface Location
Returns:
The amount of units at this Location.

getUnitList

public java.util.List<Unit> getUnitList()
Gets a List/code> of every Unit directly located on this Tile. This does not include Units located in a Settlement or on another Unit on this Tile.

Specified by:
getUnitList in interface Location
Returns:
The List.

getUnitIterator

public java.util.Iterator<Unit> getUnitIterator()
Gets an Iterator of every Unit directly located on this Tile. This does not include Units located in a Settlement or on another Unit on this Tile.

Specified by:
getUnitIterator in interface Location
Returns:
The Iterator.

canAdd

public boolean canAdd(Locatable locatable)
Checks whether or not the specified locatable may be added to this Location.

Specified by:
canAdd in interface Location
Parameters:
locatable - a Locatable value
Returns:
a boolean value

potential

public int potential(GoodsType goodsType,
                     UnitType unitType)
The potential of this tile to produce a certain type of goods.

Parameters:
goodsType - The type of goods to check the potential for.
unitType - an UnitType value
Returns:
The normal potential of this tile to produce that amount of goods.

getMaximumPotential

public int getMaximumPotential(GoodsType goodsType,
                               UnitType unitType)
Gets the maximum potential for producing the given type of goods. The maximum potential is the potential of a tile after the tile has been plowed/built road on.

Parameters:
goodsType - The type of goods.
unitType - an UnitType value
Returns:
The maximum potential.

getProductionBonus

public java.util.Set<Modifier> getProductionBonus(GoodsType goodsType,
                                                  UnitType unitType)
Describe getProductionBonus method here.

Parameters:
goodsType - a GoodsType value
Returns:
a Modifier value

canGetRoad

public boolean canGetRoad()
Checks whether this Tile can have a road or not. This method will return false if a road has already been built.

Returns:
The result.

findTileImprovementType

public TileImprovement findTileImprovementType(TileImprovementType type)
Finds the TileImprovement of a given Type, or null if there is no match.


hasImprovement

public boolean hasImprovement(TileImprovementType type)
Will check whether this tile has a completed improvement of the given type. Useful for checking whether the tile for instance has a road or is plowed.

Parameters:
type - The type to check for.
Returns:
Whether the tile has the improvement and the improvement is completed.

getTileTypePotential

public static int getTileTypePotential(TileType tileType,
                                       GoodsType goodsType,
                                       TileItemContainer tiContainer,
                                       UnitType unitType)
Calculates the potential of a certain GoodsType.

Parameters:
tileType - The TileType.
goodsType - The GoodsType to check the potential for.
tiContainer - The TileItemContainer with any TileItems to give bonuses.
unitType - an UnitType value The Bonus Fish to be considered if valid
Returns:
The amount of goods.

getSortedPotential

public java.util.List<AbstractGoods> getSortedPotential()
Sorts GoodsTypes according to potential based on TileType, TileItemContainer if any.

Returns:
The sorted GoodsTypes.

getSortedPotential

public java.util.List<AbstractGoods> getSortedPotential(Unit unit)
Sorts GoodsTypes according to potential based on TileType, TileItemContainer if any.

Parameters:
unit - the Unit to work on this Tile
Returns:
The sorted GoodsTypes.

getSortedPotential

public java.util.List<AbstractGoods> getSortedPotential(UnitType unitType,
                                                        Player owner)
Sorts GoodsTypes according to potential based on TileType, TileItemContainer if any.

Parameters:
unitType - the UnitType to work on this Tile
owner - the Player owning the unit
Returns:
The sorted GoodsTypes.

primaryGoods

public GoodsType primaryGoods()
The type of primary good (food) this tile produces best (used for Town Commons squares).

Returns:
The type of primary good best produced by this tile.

secondaryGoods

public GoodsType secondaryGoods()
The type of secondary good (non-food) this tile produces best (used for Town Commons squares).

Returns:
The type of secondary good best produced by this tile (or null if none found).

expendResource

public void expendResource(GoodsType goodsType,
                           UnitType unitType,
                           Settlement settlement)
This method is called only when a new turn is beginning. It will reduce the quantity of the bonus Resource that is on the tile, if any and if applicable.

See Also:
ResourceType, ColonyTile.newTurn()

getPlayerExploredTile

public PlayerExploredTile getPlayerExploredTile(Player player)
Gets the PlayerExploredTile for the given Player.

Parameters:
player - The Player.
See Also:
PlayerExploredTile

updatePlayerExploredTile

public void updatePlayerExploredTile(Player player)
Updates the information about this Tile for the given Player.

Parameters:
player - The Player.

updatePlayerExploredTiles

public void updatePlayerExploredTiles()
Updates the PlayerExploredTile for each player. This update will only be performed if the player can see this Tile.


isExploredBy

public boolean isExploredBy(Player player)
Checks if this Tile has been explored by the given Player.

Parameters:
player - The Player.
Returns:
true if this Tile has been explored by the given Player and false otherwise.

setExploredBy

public void setExploredBy(Player player,
                          boolean explored)
Sets this Tile to be explored by the given Player.

Parameters:
player - The Player.
explored - true if this Tile should be explored by the given Player and false otherwise.

updateIndianSettlementSkill

public void updateIndianSettlementSkill(Player player)
Updates the skill available from the IndianSettlement located on this Tile.

Parameters:
player - The Player which should get the updated information.
Throws:
java.lang.NullPointerException - If there is no settlement on this Tile.
java.lang.ClassCastException - If the Settlement on this Tile is not an IndianSettlement.
See Also:
IndianSettlement

updateIndianSettlementInformation

public void updateIndianSettlementInformation(Player player)
Updates the information about the IndianSettlement located on this Tile.

Parameters:
player - The Player which should get the updated information.
Throws:
java.lang.NullPointerException - If there is no settlement on this Tile.
java.lang.ClassCastException - If the Settlement on this Tile is not an IndianSettlement.
See Also:
IndianSettlement

getWorkAmount

public int getWorkAmount(TileImprovementType workType)
Returns the number of turns it takes for a non-expert pioneer to perform the given TileImprovementType. It will check if it is valid for this TileType.

Parameters:
workType - The TileImprovementType
Returns:
The number of turns it should take a non-expert pioneer to finish the work.

getOccupyingUnit

public Unit getOccupyingUnit()
Returns the unit who is occupying the tile

Returns:
the unit who is occupying the tile
See Also:
isOccupied()

isOccupied

public boolean isOccupied()
Checks whether there is a fortified enemy unit in the tile. Units can't produce in occupied tiles

Returns:
true if an fortified enemy unit is in the tile

isAdjacent

public boolean isAdjacent(Tile tile)
Determines whether this tile is adjacent to the specified tile.

Parameters:
tile - A potentially adjacent Tile.
Returns:
true if the tile is adjacent to this tile

toString

public java.lang.String toString()
Returns a String representation of this Tile.

Overrides:
toString in class FreeColGameObject
Returns:
A String representation of this Tile.

toXMLMinimal

public void toXMLMinimal(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the tag name of the root element representing this object.

Returns:
"tile".