Class TileType

    • Field Detail

      • WATER

        public static final TileType WATER
        Use these tile types only for "land maps", i.e. maps that only distinguish water and land.
      • LAND

        public static final TileType LAND
      • forest

        private boolean forest
        Is this a forested tile?
      • water

        private boolean water
        Is this a water tile?
      • canSettle

        private boolean canSettle
        Can this tile be settled?
      • connected

        private boolean connected
        Whether this TileType is connected to Europe.
      • elevation

        private boolean elevation
        Is this elevated terrain?
      • basicMoveCost

        private int basicMoveCost
        The base movement cost for this tile type.
      • basicWorkTurns

        private int basicWorkTurns
        The base work turns for this tile type.
      • humidity

        private final int[] humidity
        The humidity range for this tile type.
      • temperature

        private final int[] temperature
        The temperature range for this tile type.
      • altitude

        private final int[] altitude
        The altitude range for this tile type.
      • resourceTypes

        private java.util.List<RandomChoice<ResourceType>> resourceTypes
        The resource types that are valid for this tile type.
      • disasters

        private java.util.List<RandomChoice<Disaster>> disasters
        The disasters that may strike this type of tile.
      • productionTypes

        private final java.util.List<ProductionType> productionTypes
        The possible production types of this tile type. This includes the production types available if a tile of this type is a colony center tile.
      • ALTITUDE_MIN_TAG

        private static final java.lang.String ALTITUDE_MIN_TAG
        See Also:
        Constant Field Values
      • ALTITUDE_MAX_TAG

        private static final java.lang.String ALTITUDE_MAX_TAG
        See Also:
        Constant Field Values
      • BASIC_MOVE_COST_TAG

        private static final java.lang.String BASIC_MOVE_COST_TAG
        See Also:
        Constant Field Values
      • BASIC_WORK_TURNS_TAG

        private static final java.lang.String BASIC_WORK_TURNS_TAG
        See Also:
        Constant Field Values
      • HUMIDITY_MIN_TAG

        private static final java.lang.String HUMIDITY_MIN_TAG
        See Also:
        Constant Field Values
      • HUMIDITY_MAX_TAG

        private static final java.lang.String HUMIDITY_MAX_TAG
        See Also:
        Constant Field Values
      • IS_CONNECTED_TAG

        private static final java.lang.String IS_CONNECTED_TAG
        See Also:
        Constant Field Values
      • IS_ELEVATION_TAG

        private static final java.lang.String IS_ELEVATION_TAG
        See Also:
        Constant Field Values
      • TEMPERATURE_MIN_TAG

        private static final java.lang.String TEMPERATURE_MIN_TAG
        See Also:
        Constant Field Values
      • TEMPERATURE_MAX_TAG

        private static final java.lang.String TEMPERATURE_MAX_TAG
        See Also:
        Constant Field Values
      • PRIMARY_PRODUCTION_TAG

        private static final java.lang.String PRIMARY_PRODUCTION_TAG
        See Also:
        Constant Field Values
      • SECONDARY_PRODUCTION_TAG

        private static final java.lang.String SECONDARY_PRODUCTION_TAG
        See Also:
        Constant Field Values
      • OLD_ALTITUDE_MIN_TAG

        private static final java.lang.String OLD_ALTITUDE_MIN_TAG
        See Also:
        Constant Field Values
      • OLD_ALTITUDE_MAX_TAG

        private static final java.lang.String OLD_ALTITUDE_MAX_TAG
        See Also:
        Constant Field Values
      • OLD_HUMIDITY_MIN_TAG

        private static final java.lang.String OLD_HUMIDITY_MIN_TAG
        See Also:
        Constant Field Values
      • OLD_HUMIDITY_MAX_TAG

        private static final java.lang.String OLD_HUMIDITY_MAX_TAG
        See Also:
        Constant Field Values
      • OLD_TEMPERATURE_MIN_TAG

        private static final java.lang.String OLD_TEMPERATURE_MIN_TAG
        See Also:
        Constant Field Values
      • OLD_TEMPERATURE_MAX_TAG

        private static final java.lang.String OLD_TEMPERATURE_MAX_TAG
        See Also:
        Constant Field Values
    • Constructor Detail

      • TileType

        public TileType​(java.lang.String id,
                        Specification specification)
        Create a new tile type.
        Parameters:
        id - The object identifier.
        specification - The Specification to refer to.
      • TileType

        private TileType​(java.lang.String id,
                         boolean water)
        Creates a new TileType instance. This constructor is used to create the "virtual" tile types LAND and WATER, which are intended to simplify map loading.
        Parameters:
        id - The object identifier.
        water - True if this is a water tile.
    • Method Detail

      • isForested

        public boolean isForested()
        Is this tile type forested?
        Returns:
        True if this is a forested tile type.
      • isWater

        public boolean isWater()
        Is this a water tile type?
        Returns:
        True if this is a water tile type.
      • canSettle

        public boolean canSettle()
        Can this tile type be settled?
        Returns:
        True if this is a settleable tile type.
      • isHighSeasConnected

        public boolean isHighSeasConnected()
        Is this tile type connected to the high seas, by definition.
        Returns:
        True if the tile type is inherently connected to the high seas.
      • isDirectlyHighSeasConnected

        public boolean isDirectlyHighSeasConnected()
        Is this tile type directly connected to the high seas, that is, a unit on a tile of this type can move immediately to the high seas.
        Returns:
        True if the tile type is directly connected.
      • isElevation

        public boolean isElevation()
        Is this an elevated tile type?
        Returns:
        True if this is an elevated tile type.
      • getBasicMoveCost

        public int getBasicMoveCost()
        Gets the basic movement cost through this tile type.
        Returns:
        The basic movement cost.
      • getBasicWorkTurns

        public int getBasicWorkTurns()
        Gets the basic work turns to build an improvement on this tile type.
        Returns:
        The basic work turns.
      • getHumidity

        protected int getHumidity​(int i)
      • setHumidity

        protected void setHumidity​(int i,
                                   int value)
      • getTemperature

        protected int getTemperature​(int i)
      • setTemperature

        protected void setTemperature​(int i,
                                      int value)
      • getAltitude

        protected int getAltitude​(int i)
      • setAltitude

        protected void setAltitude​(int i,
                                   int value)
      • withinRange

        public boolean withinRange​(TileType.RangeType rangeType,
                                   int value)
        Is this tile type suitable for a given range type value.
        Parameters:
        rangeType - The RangeType to test.
        value - The value to check.
        Returns:
        True if the tile type meets the range limits.
      • getResourceTypes

        public java.util.List<RandomChoice<ResourceType>> getResourceTypes()
        Gets the resources that can be placed on this tile type.
        Returns:
        A weighted list of resource types.
      • setResourceTypes

        protected void setResourceTypes​(java.util.List<RandomChoice<ResourceType>> resourceTypes)
        Set the resource types list.
        Parameters:
        resourceTypes - The list of resource type choices.
      • getResourceTypeValues

        public java.util.List<ResourceType> getResourceTypeValues()
        Gets the resource types that can be found on this tile type.
        Returns:
        A list of ResourceTypes.
      • addResourceType

        private void addResourceType​(ResourceType type,
                                     int prob)
        Add a resource type.
        Parameters:
        type - The ResourceType to add.
        prob - The percentage probability of the resource being present.
      • canHaveResourceType

        public boolean canHaveResourceType​(ResourceType resourceType)
        Can this tile type contain a specified resource type?
        Parameters:
        resourceType - The ResourceType to test.
        Returns:
        True if the ResourceType is compatible.
      • getDisasters

        protected java.util.List<RandomChoice<Disaster>> getDisasters()
        Get the disaster choices.
        Returns:
        A list of Disaster choices.
      • setDisasters

        protected void setDisasters​(java.util.List<RandomChoice<Disaster>> disasters)
        Set the disaster choices.
        Parameters:
        disasters - The new Disaster choice list.
      • getDisasterChoices

        public java.util.stream.Stream<RandomChoice<Disaster>> getDisasterChoices()
        Gets the natural disasters than can strike this tile type.
        Returns:
        A stream of Disaster choices.
      • addDisaster

        private void addDisaster​(Disaster disaster,
                                 int probability)
        Add a disaster.
        Parameters:
        disaster - The Disaster to add.
        probability - The probability of the disaster.
      • getProductionTypes

        protected java.util.List<ProductionType> getProductionTypes()
        Get the production type list.
        Returns:
        The ProductionType list.
      • setProductionTypes

        protected void setProductionTypes​(java.util.List<ProductionType> productionTypes)
        Set the production type list.
        Parameters:
        productionTypes - The new ProductionType list.
      • getAvailableProductionTypes

        public java.util.List<ProductionType> getAvailableProductionTypes​(boolean unattended)
        Gets the production types available at the current difficulty level.
        Specified by:
        getAvailableProductionTypes in interface BaseProduction
        Parameters:
        unattended - Whether the production is unattended.
        Returns:
        A list of ProductionTypes.
      • getAvailableProductionTypes

        public java.util.List<ProductionType> getAvailableProductionTypes​(boolean unattended,
                                                                          java.lang.String level)
        Gets the production types available for the given combination of colony center tile and production level. If the production level is null, all production levels will be returned. Public for the test suite.
        Parameters:
        unattended - Whether the production is unattended.
        level - The production level.
        Returns:
        A list of ProductionTypes.
      • canProduce

        public boolean canProduce​(GoodsType goodsType,
                                  UnitType unitType)
        Can a tile of this type produce a given goods type?
        Parameters:
        goodsType - The GoodsType to produce.
        unitType - An optional UnitType that is to do the work, if null the unattended production is considered.
        Returns:
        True if this tile type produces the goods.
      • getPotentialProduction

        public int getPotentialProduction​(GoodsType goodsType,
                                          UnitType unitType)
        Get the amount of goods of given goods type the given unit type could produce on a tile of this tile type.
        Parameters:
        goodsType - The GoodsType to produce.
        unitType - An optional UnitType that is to do the work, if null the unattended production is considered.
        Returns:
        The amount of goods produced.
      • getPossibleProduction

        public java.util.stream.Stream<AbstractGoods> getPossibleProduction​(boolean unattended)
        Get all possible goods produced at a tile of this type. Used by static tile type displays that just list unattended production values. Planning and production routines should use getPotentialProduction(GoodsType, UnitType)
        Parameters:
        unattended - Select unattended production.
        Returns:
        A stream of produced AbstractGoods.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class FreeColSpecObjectType
        Type Parameters:
        T - The FreeColObject subclass of the object to copy in.
        Parameters:
        other - The other object.
        Returns:
        True if the copy in is succesful.
      • writeAttributes

        protected void writeAttributes​(FreeColXMLWriter xw)
                                throws javax.xml.stream.XMLStreamException
        Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.
        Overrides:
        writeAttributes in class FreeColObject
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • writeChildren

        protected void writeChildren​(FreeColXMLWriter xw)
                              throws javax.xml.stream.XMLStreamException
        Write the children of this object to a stream. To be overridden if required by any object that has children and uses the toXML(FreeColXMLWriter, String) call.
        Overrides:
        writeChildren in class FreeColSpecObjectType
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • readAttributes

        protected void readAttributes​(FreeColXMLReader xr)
                               throws javax.xml.stream.XMLStreamException
        Reads the attributes of this object from an XML stream.
        Overrides:
        readAttributes in class FreeColSpecObjectType
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • readChildren

        protected void readChildren​(FreeColXMLReader xr)
                             throws javax.xml.stream.XMLStreamException
        Reads the children of this object from an XML stream.
        Overrides:
        readChildren in class FreeColSpecObjectType
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • readChild

        protected void readChild​(FreeColXMLReader xr)
                          throws javax.xml.stream.XMLStreamException
        Reads a single child object. Subclasses must override to read their enclosed elements. This particular instance of the routine always throws XMLStreamException because we should never arrive here. However it is very useful to always call super.readChild() when an unexpected tag is encountered, as the exception thrown here provides some useful debugging context.
        Overrides:
        readChild in class FreeColSpecObjectType
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • getXMLTagName

        public java.lang.String getXMLTagName()
        Get the serialization tag for this object.
        Specified by:
        getXMLTagName in class FreeColObject
        Returns:
        The tag.