net.sf.freecol.common.model
Class TileType

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.TileType

public final class TileType
extends FreeColGameObjectType


Nested Class Summary
static class TileType.RangeType
           
 
Field Summary
private  int[] altitude
           
private  int basicMoveCost
           
private  int basicWorkTurns
           
private  boolean canSettle
           
private  boolean connected
          Whether this TileType is connected to Europe.
private  boolean elevation
           
private  boolean forest
           
private  int[] humidity
           
private  AbstractGoods primaryGoods
          The primary goods produced by this tile type.
private  java.util.Map<java.lang.String,AbstractGoods> primaryGoodsMap
           
private  java.util.List<AbstractGoods> production
          A list of AbstractGoods produced by this TileType when it is not the colony center tile.
private  java.util.Map<java.lang.String,java.util.Map<GoodsType,AbstractGoods>> productionMap
           
private  java.util.List<RandomChoice<ResourceType>> resourceType
           
private  AbstractGoods secondaryGoods
          The secondary goods produced by this tile type.
private  java.util.Map<java.lang.String,AbstractGoods> secondaryGoodsMap
           
private  int[] temperature
           
private  boolean water
           
 
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
TileType(java.lang.String id, Specification specification)
           
 
Method Summary
 void applyDifficultyLevel(OptionGroup difficultyLevel)
          Applies the difficulty level to this TileType.
 boolean canHaveImprovement(TileImprovementType improvement)
          Returns true if this TileType supports the given TileImprovementType.
 boolean canHaveResourceType(ResourceType resourceType)
          Can this TileType contain a specified ResourceType?
 boolean canSettle()
           
 int getBasicMoveCost()
           
 int getBasicWorkTurns()
           
 java.util.Set<Modifier> getDefenceBonus()
           
 int getIndex()
          Returns the index of this FreeColGameObjectType.
 AbstractGoods getPrimaryGoods()
          Get the PrimaryGoods value.
 AbstractGoods getPrimaryGoods(java.lang.String tileProduction)
          Get the PrimaryGoods value at the tileProduction level with the ID given.
 java.util.List<AbstractGoods> getProduction()
          Returns a list of all types of AbstractGoods produced by this TileType when it is not the colony center tile.
 java.util.List<AbstractGoods> getProduction(java.lang.String tileProduction)
          Returns a list of all types of AbstractGoods produced by this TileType when it is not the colony center tile.
 java.util.Set<Modifier> getProductionBonus(GoodsType goodsType)
          Returns the production bonus for the given GoodsType.
 int getProductionOf(GoodsType goodsType, UnitType unitType)
          Returns the amount of goods of given GoodsType this TileType can produce.
 java.util.List<ResourceType> getResourceTypeList()
           
 AbstractGoods getSecondaryGoods()
          Get the SecondaryGoods value.
 AbstractGoods getSecondaryGoods(java.lang.String tileProduction)
          Get the SecondaryGoods value at the tileProduction level with the ID given.
 java.util.List<RandomChoice<ResourceType>> getWeightedResources()
           
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean isConnected()
          Get the Connected value.
 boolean isElevation()
          Is this tile an elevation.
 boolean isForested()
           
 boolean isPrimaryGoodsType(GoodsType type)
          Returns true if the given GoodsType is the primary goods type of this TileType.
 boolean isSecondaryGoodsType(GoodsType type)
          Returns true if the given GoodsType is the secondary goods type of this TileType.
 boolean isWater()
           
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 setPrimaryGoods(AbstractGoods newPrimaryGoods)
          Set the PrimaryGoods value.
 void setSecondaryGoods(AbstractGoods newSecondaryGoods)
          Set the SecondaryGoods value.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
 boolean withinRange(TileType.RangeType rangeType, int value)
           
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, getDescriptionKey, getFeatureContainer, 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

forest

private boolean forest

water

private boolean water

canSettle

private boolean canSettle

elevation

private boolean elevation

basicMoveCost

private int basicMoveCost

basicWorkTurns

private int basicWorkTurns

humidity

private int[] humidity

temperature

private int[] temperature

altitude

private int[] altitude

resourceType

private java.util.List<RandomChoice<ResourceType>> resourceType

connected

private boolean connected
Whether this TileType is connected to Europe.


primaryGoods

private AbstractGoods primaryGoods
The primary goods produced by this tile type. In the original game, this is always food or null (in the case of the arctic).


secondaryGoods

private AbstractGoods secondaryGoods
The secondary goods produced by this tile type. In the original game, this is never food, but may be null (in the case of the arctic).


production

private java.util.List<AbstractGoods> production
A list of AbstractGoods produced by this TileType when it is not the colony center tile.


primaryGoodsMap

private java.util.Map<java.lang.String,AbstractGoods> primaryGoodsMap

secondaryGoodsMap

private java.util.Map<java.lang.String,AbstractGoods> secondaryGoodsMap

productionMap

private java.util.Map<java.lang.String,java.util.Map<GoodsType,AbstractGoods>> productionMap
Constructor Detail

TileType

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

getIndex

public int getIndex()
Returns the index of this FreeColGameObjectType. The index imposes a total ordering consistent with equals on each class extending FreeColGameObjectType, but this ordering is nothing but the order in which the objects of the respective class were defined. It is guaranteed to remain stable only for a particular revision of a particular specification.

Overrides:
getIndex in class FreeColGameObjectType
Returns:
an int value

isForested

public boolean isForested()

isWater

public boolean isWater()

isConnected

public boolean isConnected()
Get the Connected value.

Returns:
a boolean value

isElevation

public boolean isElevation()
Is this tile an elevation.

Returns:
true if and only if the tile is an elevation, false otherwise.

canSettle

public boolean canSettle()

canHaveImprovement

public boolean canHaveImprovement(TileImprovementType improvement)
Returns true if this TileType supports the given TileImprovementType.

Parameters:
improvement - a TileImprovementType value
Returns:
a boolean value

getBasicMoveCost

public int getBasicMoveCost()

getBasicWorkTurns

public int getBasicWorkTurns()

getDefenceBonus

public java.util.Set<Modifier> getDefenceBonus()

getProductionOf

public int getProductionOf(GoodsType goodsType,
                           UnitType unitType)
Returns the amount of goods of given GoodsType this TileType can produce. This method applies the production bonus to 0f. Thus, it will always return 0 unless an additive modifier is present. This is intentional.

Parameters:
goodsType - a GoodsType value
unitType - an UnitType value
Returns:
an int value
See Also:
getProductionBonus(GoodsType)

getProductionBonus

public java.util.Set<Modifier> getProductionBonus(GoodsType goodsType)
Returns the production bonus for the given GoodsType.

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

getPrimaryGoods

public AbstractGoods getPrimaryGoods()
Get the PrimaryGoods value.

Returns:
an AbstractGoods value

getPrimaryGoods

public AbstractGoods getPrimaryGoods(java.lang.String tileProduction)
Get the PrimaryGoods value at the tileProduction level with the ID given.

Returns:
an AbstractGoods value

isPrimaryGoodsType

public boolean isPrimaryGoodsType(GoodsType type)
Returns true if the given GoodsType is the primary goods type of this TileType.

Parameters:
type - a GoodsType value
Returns:
a boolean value

setPrimaryGoods

public void setPrimaryGoods(AbstractGoods newPrimaryGoods)
Set the PrimaryGoods value.

Parameters:
newPrimaryGoods - The new PrimaryGoods value.

getSecondaryGoods

public AbstractGoods getSecondaryGoods()
Get the SecondaryGoods value.

Returns:
an AbstractGoods value

getSecondaryGoods

public AbstractGoods getSecondaryGoods(java.lang.String tileProduction)
Get the SecondaryGoods value at the tileProduction level with the ID given.

Returns:
an AbstractGoods value

setSecondaryGoods

public void setSecondaryGoods(AbstractGoods newSecondaryGoods)
Set the SecondaryGoods value.

Parameters:
newSecondaryGoods - The new SecondaryGoods value.

isSecondaryGoodsType

public boolean isSecondaryGoodsType(GoodsType type)
Returns true if the given GoodsType is the secondary goods type of this TileType.

Parameters:
type - a GoodsType value
Returns:
a boolean value

getProduction

public java.util.List<AbstractGoods> getProduction()
Returns a list of all types of AbstractGoods produced by this TileType when it is not the colony center tile.

Returns:
a List value

getProduction

public java.util.List<AbstractGoods> getProduction(java.lang.String tileProduction)
Returns a list of all types of AbstractGoods produced by this TileType when it is not the colony center tile.

Parameters:
tileProduction -
Returns:
a List value

getWeightedResources

public java.util.List<RandomChoice<ResourceType>> getWeightedResources()

getResourceTypeList

public java.util.List<ResourceType> getResourceTypeList()

canHaveResourceType

public boolean canHaveResourceType(ResourceType resourceType)
Can this TileType contain a specified ResourceType?

Parameters:
resourceType - a ResourceType to test
Returns:
Whether this TileType contains the specified ResourceType

withinRange

public boolean withinRange(TileType.RangeType rangeType,
                           int value)

applyDifficultyLevel

public void applyDifficultyLevel(OptionGroup difficultyLevel)
Applies the difficulty level to this TileType.

Overrides:
applyDifficultyLevel in class FreeColGameObjectType
Parameters:
difficultyLevel - difficulty level to apply

toXMLImpl

protected 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:
"tile-type".