net.sf.freecol.common.model
Class TileImprovementType

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObjectType
          extended by net.sf.freecol.common.model.TileImprovementType

public final class TileImprovementType
extends FreeColGameObjectType


Field Summary
private  int addWorkTurns
           
private  java.util.Set<java.lang.String> allowedWorkers
           
private  int deliverAmount
           
private  GoodsType deliverGoodsType
           
private  int expendedAmount
           
private  EquipmentType expendedEquipmentType
           
private  int exposeResourcePercent
          Can this improvement expose a resource when completed? This should only apply to improvement types that change the underlying tile type (e.g.
private  int magnitude
           
private  int movementCost
           
private  float movementCostFactor
           
private  boolean natural
           
private  TileImprovementType requiredImprovementType
           
private  java.util.List<Scope> scopes
          The scopes define which TileTypes support this improvement.
private  java.util.Map<TileType,TileTypeChange> tileTypeChanges
           
private  int zIndex
          The layer a TileItem belongs to.
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
TileImprovementType(java.lang.String id, Specification specification)
           
 
Method Summary
 boolean changeContainsTarget(TileType tileType)
          Returns true if this TileImprovementType can change a tile type to the given tile type.
 int getAddWorkTurns()
           
 int getBonus(GoodsType goodsType)
           
 TileType getChange(TileType tileType)
          Returns the destination type of a tile type change (or null).
 int getExpendedAmount()
           
 EquipmentType getExpendedEquipmentType()
           
 int getExposeResourcePercent()
          Gets the percent chance that this tile improvement can expose a resource on the tile.
 int getImprovementValue(Tile tile, GoodsType goodsType)
          Gets the increase in production of the given GoodsType this tile improvement type would yield at a specified tile.
 int getMagnitude()
           
 int getMovementCost(int moveCost)
          Performs reduction of the movement-cost.
 AbstractGoods getProduction(TileType from)
          Returns the goods produced by applying this TileImprovementType to a Tile with the given TileType.
 Modifier getProductionModifier(GoodsType goodsType)
           
 TileImprovementType getRequiredImprovementType()
           
 java.util.List<Scope> getScopes()
          Get the Scopes value.
 java.lang.String getShortId()
          Return an ID of an appropriate action.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 int getZIndex()
          Get the ZIndex value.
 boolean isChangeType()
          Returns true if this TileImprovementType changes the underlying tile type.
 boolean isNatural()
           
 boolean isTileAllowed(Tile tile)
          Check if a given Tile is valid for this TileImprovement.
 boolean isTileTypeAllowed(TileType tileType)
          This will check if in principle this type of improvement can be used on this kind of tile, disregarding the current state of an actual tile.
 boolean isWorkerAllowed(Unit unit)
          Check if a given Unit can perform this TileImprovement.
 boolean isWorkerTypeAllowed(UnitType unitType)
           
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Reads the attributes of this object from an XML stream.
protected  void readChild(javax.xml.stream.XMLStreamReader in)
          Reads a child object.
 void setZIndex(int newZIndex)
          Set the ZIndex value.
 void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out)
          Write the children of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObjectType
addAbility, addModifier, applyDifficultyLevel, getDescriptionKey, getFeatureContainer, getIndex, getModifierIndex, getModifierIndex, getModifierSet, getNameKey, hasAbility, hasAbility, isAbstractType, readChildren, setAbstractType, setFeatureContainer, setIndex, setModifierIndex, toString, toXMLImpl
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, hasAttribute, hasListeners, readAttributes, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

natural

private boolean natural

magnitude

private int magnitude

addWorkTurns

private int addWorkTurns

requiredImprovementType

private TileImprovementType requiredImprovementType

allowedWorkers

private java.util.Set<java.lang.String> allowedWorkers

expendedEquipmentType

private EquipmentType expendedEquipmentType

expendedAmount

private int expendedAmount

deliverGoodsType

private GoodsType deliverGoodsType

deliverAmount

private int deliverAmount

tileTypeChanges

private java.util.Map<TileType,TileTypeChange> tileTypeChanges

movementCost

private int movementCost

movementCostFactor

private float movementCostFactor

zIndex

private int zIndex
The layer a TileItem belongs to. Items with higher zIndex will be displayed above items with a lower zIndex. E.g. the LostCityRumour would be displayed above the Plow improvement.


exposeResourcePercent

private int exposeResourcePercent
Can this improvement expose a resource when completed? This should only apply to improvement types that change the underlying tile type (e.g. clearing forests).


scopes

private java.util.List<Scope> scopes
The scopes define which TileTypes support this improvement. An eligible TileType must match all scopes.

Constructor Detail

TileImprovementType

public TileImprovementType(java.lang.String id,
                           Specification specification)
Method Detail

isNatural

public boolean isNatural()

getMagnitude

public int getMagnitude()

getAddWorkTurns

public int getAddWorkTurns()

getZIndex

public int getZIndex()
Get the ZIndex value.

Returns:
an int value

setZIndex

public void setZIndex(int newZIndex)
Set the ZIndex value.

Parameters:
newZIndex - The new ZIndex value.

getRequiredImprovementType

public TileImprovementType getRequiredImprovementType()

getExpendedEquipmentType

public EquipmentType getExpendedEquipmentType()

getExpendedAmount

public int getExpendedAmount()

getProduction

public AbstractGoods getProduction(TileType from)
Returns the goods produced by applying this TileImprovementType to a Tile with the given TileType.

Parameters:
from - a TileType value
Returns:
an AbstractGoods value

getScopes

public java.util.List<Scope> getScopes()
Get the Scopes value.

Returns:
a List value

getShortId

public java.lang.String getShortId()
Return an ID of an appropriate action.

Returns:
a String value

isWorkerTypeAllowed

public boolean isWorkerTypeAllowed(UnitType unitType)

isWorkerAllowed

public boolean isWorkerAllowed(Unit unit)
Check if a given Unit can perform this TileImprovement.

Returns:
true if Worker UnitType is allowed and expended Goods are available

isTileTypeAllowed

public boolean isTileTypeAllowed(TileType tileType)
This will check if in principle this type of improvement can be used on this kind of tile, disregarding the current state of an actual tile. If you want to find out if an improvement is allowed for a tile, call isTileAllowed(Tile).

Parameters:
tileType - The type of terrain
Returns:
true if improvement is possible

isTileAllowed

public boolean isTileAllowed(Tile tile)
Check if a given Tile is valid for this TileImprovement.

Returns:
true if Tile TileType is valid and required Improvement (if any) is present.

getBonus

public int getBonus(GoodsType goodsType)

getProductionModifier

public Modifier getProductionModifier(GoodsType goodsType)

isChangeType

public boolean isChangeType()
Returns true if this TileImprovementType changes the underlying tile type.

Returns:
a boolean value

getChange

public TileType getChange(TileType tileType)
Returns the destination type of a tile type change (or null).

Parameters:
tileType - a TileType value
Returns:
a TileType value

changeContainsTarget

public boolean changeContainsTarget(TileType tileType)
Returns true if this TileImprovementType can change a tile type to the given tile type.

Parameters:
tileType - a TileType value
Returns:
a boolean value

getMovementCost

public int getMovementCost(int moveCost)
Performs reduction of the movement-cost.

Parameters:
moveCost - Original movement cost
Returns:
The movement cost after any change

getExposeResourcePercent

public int getExposeResourcePercent()
Gets the percent chance that this tile improvement can expose a resource on the tile. This only applies to TileImprovementTypes that change the underlying tile type (e.g. clearing forests).

Returns:
The exposure chance.

getImprovementValue

public int getImprovementValue(Tile tile,
                               GoodsType goodsType)
Gets the increase in production of the given GoodsType this tile improvement type would yield at a specified tile.

Parameters:
tile - The Tile to be considered.
goodsType - A preferred GoodsType or null
Returns:
The increase in production

toXMLImpl

public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
               throws javax.xml.stream.XMLStreamException
Makes an XML-representation of this object.

Overrides:
toXMLImpl in class FreeColGameObjectType
Parameters:
out - The output stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream.

Overrides:
writeAttributes in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeChildren

protected void writeChildren(javax.xml.stream.XMLStreamWriter out)
                      throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream.

Overrides:
writeChildren in class FreeColGameObjectType
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readAttributes

protected void readAttributes(javax.xml.stream.XMLStreamReader in)
                       throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.

Overrides:
readAttributes in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChild

protected void readChild(javax.xml.stream.XMLStreamReader in)
                  throws javax.xml.stream.XMLStreamException
Reads a child object.

Overrides:
readChild in class FreeColGameObjectType
Parameters:
in - The XML stream to read.
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

getXMLElementTagName

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

Returns:
"tileimprovement-type".