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 aTileItemitem on aTile.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerloggerprotected TiletileThe 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 newTileItemwith the given identifier.TileItem(Game game, FreeColXMLReader xr)Creates a newTileItemfrom an XML stream.protectedTileItem(Game game, Tile tile)Creates a newTileItem.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intapplyBonus(GoodsType goodsType, UnitType unitType, int potential)Applies the production bonus for the given goods type and unit type to the given potential production.abstract booleancanProduce(GoodsType goodsType, UnitType unitType)Does this tile item allow its enclosing tile to produce a given goods type?Constants.IntegrityTypecheckIntegrity(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.LayergetLayer()Get the layer associated with this tile item.LocationgetLocation()Gets the location of thisLocatable.abstract java.lang.StringgetNameKey()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.intgetSpaceTaken()Gets the number of cargo slots consumed when thisLocatableif put onto a carrier.TilegetTile()Get theTilewhere thisLocatableis located, ornullif it is inEurope.abstract intgetZIndex()Get theZIndexvalue.abstract booleanisComplete()Is this improvement complete?booleanisInEurope()Is this locatable in Europe.abstract booleanisNatural()Is this a natural TileItem?abstract booleanisTileTypeAllowed(TileType tileType)Is a tile type compatible with this tile item?booleansetLocation(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 newTileItemfrom 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 newTileItemwith 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 theZIndexvalue.- Returns:
- The z-index.
-
isTileTypeAllowed
public abstract boolean isTileTypeAllowed(TileType tileType)
Is a tile type compatible with this tile item?- Parameters:
tileType- TheTileTypeto 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- TheGoodsTypeto produce.unitType- TheUnitTypethat 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- TheGoodsTypeto produce.unitType- The optionalunitTypeto 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- TheGoodsTypeto produce.unitType- The optionalunitTypeto 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:
getLocationin interfaceLocatable- Returns:
- The location of this
Locatable.
-
setLocation
public boolean setLocation(Location newLocation)
Sets the location for thisLocatable.- Specified by:
setLocationin interfaceLocatable- Parameters:
newLocation- The newLocationfor theLocatable.- Returns:
- True if the location change succeeds.
-
isInEurope
public boolean isInEurope()
Is this locatable in Europe.- Specified by:
isInEuropein interfaceLocatable- Returns:
- True if the
Locatableis inEurope.
-
getTile
public Tile getTile()
Get theTilewhere thisLocatableis located, ornullif it is inEurope.
-
getSpaceTaken
public int getSpaceTaken()
Gets the number of cargo slots consumed when thisLocatableif put onto a carrier.- Specified by:
getSpaceTakenin 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:
getNameKeyin interfaceNamed- Returns:
- The name of the
Named.
-
checkIntegrity
public Constants.IntegrityType checkIntegrity(boolean fix, LogBuilder lb)
Checks the integrity of this game object.- Overrides:
checkIntegrityin classFreeColGameObject- Parameters:
fix- If true, fix problems if possible.lb- ALogBuilderto 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:
copyInin classFreeColGameObject- Type Parameters:
T- TheFreeColObjectsubclass of the object to copy in.- Parameters:
other- The other object.- Returns:
- True if the copy in is succesful.
-
-