Package net.sf.freecol.common.model
Class TileItem
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColGameObject
-
- net.sf.freecol.common.model.TileItem
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Locatable
,Named
,ObjectWithId
- Direct Known Subclasses:
LostCityRumour
,Resource
,TileImprovement
public abstract class TileItem extends FreeColGameObject implements Locatable, Named
Represents aTileItem
item on aTile
.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
protected Tile
tile
The tile where the tile item is.-
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Modifier Constructor Description TileItem(Game game, java.lang.String id)
Initiates a newTileItem
with the given identifier.TileItem(Game game, FreeColXMLReader xr)
Creates a newTileItem
from an XML stream.protected
TileItem(Game game, Tile tile)
Creates a newTileItem
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract int
applyBonus(GoodsType goodsType, UnitType unitType, int potential)
Applies the production bonus for the given goods type and unit type to the given potential production.abstract boolean
canProduce(GoodsType goodsType, UnitType unitType)
Does this tile item allow its enclosing tile to produce a given goods type?Constants.IntegrityType
checkIntegrity(boolean fix, LogBuilder lb)
Checks the integrity of this game object.<T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.abstract Map.Layer
getLayer()
Get the layer associated with this tile item.Location
getLocation()
Gets the location of thisLocatable
.abstract java.lang.String
getNameKey()
Gets the name of this named object.abstract java.util.stream.Stream<Modifier>
getProductionModifiers(GoodsType goodsType, UnitType unitType)
Gets the production modifiers for the given type of goods and unit.int
getSpaceTaken()
Gets the number of cargo slots consumed when thisLocatable
if put onto a carrier.Tile
getTile()
Get theTile
where thisLocatable
is located, ornull
if it is inEurope
.abstract int
getZIndex()
Get theZIndex
value.abstract boolean
isComplete()
Is this improvement complete?boolean
isInEurope()
Is this locatable in Europe.abstract boolean
isNatural()
Is this a natural TileItem?abstract boolean
isTileTypeAllowed(TileType tileType)
Is a tile type compatible with this tile item?boolean
setLocation(Location newLocation)
Sets the location for thisLocatable
.-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
dispose, disposeResources, equals, fundamentalDispose, getClassIndex, getDisposables, getGame, getLinkTarget, getSpecification, hashCode, intern, internId, isDisposed, isInitialized, isInternable, readAttributes, readFromXML, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, getXMLTagName, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toString, toXML, toXML, toXMLPartial, toXMLPartial, writeAttributes, writeChildren
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
tile
protected Tile tile
The tile where the tile item is.
-
-
Constructor Detail
-
TileItem
protected TileItem(Game game, Tile tile)
Creates a newTileItem
.- Parameters:
game
- The enclosingGame
.tile
- The location of thisTileItem
.
-
TileItem
public TileItem(Game game, FreeColXMLReader xr)
Creates a newTileItem
from an XML stream.- Parameters:
game
- The enclosingGame
.xr
- The input stream containing the XML.
-
TileItem
public TileItem(Game game, java.lang.String id)
Initiates a newTileItem
with the given identifier. The object should later be initialized by calling eitherFreeColGameObject.readFromXML(FreeColXMLReader)
.- Parameters:
game
- The enclosingGame
.id
- The object identifier.
-
-
Method Detail
-
getZIndex
public abstract int getZIndex()
Get theZIndex
value.- Returns:
- The z-index.
-
isTileTypeAllowed
public abstract boolean isTileTypeAllowed(TileType tileType)
Is a tile type compatible with this tile item?- Parameters:
tileType
- TheTileType
to check.- Returns:
- True if the tile type is compatible.
-
applyBonus
public abstract int applyBonus(GoodsType goodsType, UnitType unitType, int potential)
Applies the production bonus for the given goods type and unit type to the given potential production.- Parameters:
goodsType
- TheGoodsType
to produce.unitType
- TheUnitType
that is to work.potential
- The base potential production.- Returns:
- The production with resource bonuses.
-
canProduce
public abstract boolean canProduce(GoodsType goodsType, UnitType unitType)
Does this tile item allow its enclosing tile to produce a given goods type?- Parameters:
goodsType
- TheGoodsType
to produce.unitType
- The optionalunitType
to produce with.- Returns:
- True if this tile item produces the goods.
-
getProductionModifiers
public abstract java.util.stream.Stream<Modifier> getProductionModifiers(GoodsType goodsType, UnitType unitType)
Gets the production modifiers for the given type of goods and unit.- Parameters:
goodsType
- TheGoodsType
to produce.unitType
- The optionalunitType
to produce them.- Returns:
- A stream of the applicable modifiers.
-
isNatural
public abstract boolean isNatural()
Is this a natural TileItem?- Returns:
- True if this is a natural
TileItem
.
-
isComplete
public abstract boolean isComplete()
Is this improvement complete?- Returns:
- True if complete.
-
getLayer
public abstract Map.Layer getLayer()
Get the layer associated with this tile item.- Returns:
- The layer.
-
getLocation
public Location getLocation()
Gets the location of thisLocatable
.- Specified by:
getLocation
in interfaceLocatable
- Returns:
- The location of this
Locatable
.
-
setLocation
public boolean setLocation(Location newLocation)
Sets the location for thisLocatable
.- Specified by:
setLocation
in interfaceLocatable
- Parameters:
newLocation
- The newLocation
for theLocatable
.- Returns:
- True if the location change succeeds.
-
isInEurope
public boolean isInEurope()
Is this locatable in Europe.- Specified by:
isInEurope
in interfaceLocatable
- Returns:
- True if the
Locatable
is inEurope
.
-
getTile
public Tile getTile()
Get theTile
where thisLocatable
is located, ornull
if it is inEurope
.
-
getSpaceTaken
public int getSpaceTaken()
Gets the number of cargo slots consumed when thisLocatable
if put onto a carrier.- Specified by:
getSpaceTaken
in interfaceLocatable
- Returns:
- The number of cargo slots required.
-
getNameKey
public abstract java.lang.String getNameKey()
Gets the name of this named object. Try to avoid using this directly except in i18n-related routines or to implement itself in more complext objects.- Specified by:
getNameKey
in interfaceNamed
- Returns:
- The name of the
Named
.
-
checkIntegrity
public Constants.IntegrityType checkIntegrity(boolean fix, LogBuilder lb)
Checks the integrity of this game object.- Overrides:
checkIntegrity
in classFreeColGameObject
- Parameters:
fix
- If true, fix problems if possible.lb
- ALogBuilder
to log to.- Returns:
- A suitable
IntegrityType
.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyIn
in classFreeColGameObject
- Type Parameters:
T
- TheFreeColObject
subclass of the object to copy in.- Parameters:
other
- The other object.- Returns:
- True if the copy in is succesful.
-
-