Class SettlementType

    • Field Detail

      • capital

        private boolean capital
        Whether this SettlementType is a capital.
      • visibleRadius

        private int visibleRadius
        How many tiles this SettlementType can see.
      • claimableRadius

        private int claimableRadius
        How many tiles this SettlementType can claim.
      • extraClaimableRadius

        private int extraClaimableRadius
        The extra radius beyond the claimableRadius where wandering units may claim as yet unclaimed tiles.
      • wanderingRadius

        private int wanderingRadius
        How far units from this SettlementType may roam.
      • minimumSize

        private int minimumSize
        The minimum number of units for this SettlementType.
      • maximumSize

        private int maximumSize
        The maximum number of units for this SettlementType.
      • minimumGrowth

        private int minimumGrowth
        The minimum number of tiles to grow this SettlementType.
      • maximumGrowth

        private int maximumGrowth
        The maximum number of tiles to grown this SettlementType.
      • tradeBonus

        private int tradeBonus
        The general trade bonus, roughly proportional to the settlement size and general sophistication.
      • convertThreshold

        private int convertThreshold
        The threshold at which a new convert occurs.
      • plunderTypes

        private java.util.List<PlunderType> plunderTypes
        The plunder this SettlementType generates when destroyed.
      • gifts

        private RandomRange gifts
        The gifts this SettlementType generates when visited by a scout.
      • CLAIMABLE_RADIUS_TAG

        private static final java.lang.String CLAIMABLE_RADIUS_TAG
        See Also:
        Constant Field Values
      • CONVERT_THRESHOLD_TAG

        private static final java.lang.String CONVERT_THRESHOLD_TAG
        See Also:
        Constant Field Values
      • EXTRA_CLAIMABLE_RADIUS_TAG

        private static final java.lang.String EXTRA_CLAIMABLE_RADIUS_TAG
        See Also:
        Constant Field Values
      • MAXIMUM_GROWTH_TAG

        private static final java.lang.String MAXIMUM_GROWTH_TAG
        See Also:
        Constant Field Values
      • MAXIMUM_SIZE_TAG

        private static final java.lang.String MAXIMUM_SIZE_TAG
        See Also:
        Constant Field Values
      • MINIMUM_GROWTH_TAG

        private static final java.lang.String MINIMUM_GROWTH_TAG
        See Also:
        Constant Field Values
      • MINIMUM_SIZE_TAG

        private static final java.lang.String MINIMUM_SIZE_TAG
        See Also:
        Constant Field Values
      • VISIBLE_RADIUS_TAG

        private static final java.lang.String VISIBLE_RADIUS_TAG
        See Also:
        Constant Field Values
      • WANDERING_RADIUS_TAG

        private static final java.lang.String WANDERING_RADIUS_TAG
        See Also:
        Constant Field Values
      • OLD_CLAIMABLE_RADIUS_TAG

        private static final java.lang.String OLD_CLAIMABLE_RADIUS_TAG
        See Also:
        Constant Field Values
      • OLD_CONVERT_THRESHOLD_TAG

        private static final java.lang.String OLD_CONVERT_THRESHOLD_TAG
        See Also:
        Constant Field Values
      • OLD_EXTRA_CLAIMABLE_RADIUS_TAG

        private static final java.lang.String OLD_EXTRA_CLAIMABLE_RADIUS_TAG
        See Also:
        Constant Field Values
      • OLD_MAXIMUM_GROWTH_TAG

        private static final java.lang.String OLD_MAXIMUM_GROWTH_TAG
        See Also:
        Constant Field Values
      • OLD_MAXIMUM_SIZE_TAG

        private static final java.lang.String OLD_MAXIMUM_SIZE_TAG
        See Also:
        Constant Field Values
      • OLD_MINIMUM_GROWTH_TAG

        private static final java.lang.String OLD_MINIMUM_GROWTH_TAG
        See Also:
        Constant Field Values
      • OLD_MINIMUM_SIZE_TAG

        private static final java.lang.String OLD_MINIMUM_SIZE_TAG
        See Also:
        Constant Field Values
      • OLD_TRADE_BONUS_TAG

        private static final java.lang.String OLD_TRADE_BONUS_TAG
        See Also:
        Constant Field Values
      • OLD_VISIBLE_RADIUS_TAG

        private static final java.lang.String OLD_VISIBLE_RADIUS_TAG
        See Also:
        Constant Field Values
      • OLD_WANDERING_RADIUS_TAG

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

      • SettlementType

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

        public SettlementType​(FreeColXMLReader xr,
                              Specification specification)
                       throws javax.xml.stream.XMLStreamException
        Creates a new settlement type.
        Parameters:
        xr - The FreeColXMLReader to read from.
        specification - The Specification to refer to.
        Throws:
        javax.xml.stream.XMLStreamException - if there is problem reading the stream.
    • Method Detail

      • isCapital

        public final boolean isCapital()
        Is this a capital settlement type?
        Returns:
        True if this is a capital.
      • getMinimumSize

        public final int getMinimumSize()
        Get the minimum size of this settlement type.
        Returns:
        The minimum settlement size.
      • getMaximumSize

        public final int getMaximumSize()
        Get the maximum size of this settlement type.
        Returns:
        The maximum settlement size.
      • getVisibleRadius

        public final int getVisibleRadius()
        Get the visible radius of this settlement type.
        Returns:
        The visible radius.
      • getClaimableRadius

        public final int getClaimableRadius()
        Get the claimable radius of this settlement type.
        Returns:
        The claimable radius.
      • getExtraClaimableRadius

        public final int getExtraClaimableRadius()
        Get the extra claimable radius.
        Returns:
        The extra claimable radius.
      • getWanderingRadius

        public final int getWanderingRadius()
        Get the wandering radius for this settlement type.
        Returns:
        The wandering radius.
      • getMinimumGrowth

        public final int getMinimumGrowth()
        Get the minimum growth value.
        Returns:
        The minimum number of tiles to try to grow this settlement type by.
      • getMaximumGrowth

        public final int getMaximumGrowth()
        Get the maximum growth value.
        Returns:
        The maximum number of tiles to try to grow this settlement type by.
      • getTradeBonus

        public final int getTradeBonus()
        Gets the trade bonus.
        Returns:
        The general bonus to trade.
      • getConvertThreshold

        public int getConvertThreshold()
        Gets the convert threshold for this settlement.
        Returns:
        The convert threshold.
      • getPlunderTypes

        public java.util.List<PlunderType> getPlunderTypes()
        Get the list of plunder types.
        Returns:
        The list of PlunderTypes.
      • setPlunderTypes

        protected void setPlunderTypes​(java.util.List<PlunderType> plunderTypes)
        Set the plunder types.
        Parameters:
        plunderTypes - The new plunder type list.
      • getPlunderRange

        public final RandomRange getPlunderRange​(Unit unit)
        Gets the plunder range available for the supplied unit.
        Parameters:
        unit - The Unit to check.
        Returns:
        The plunder range, or null if none applicable.
      • addPlunderType

        private void addPlunderType​(PlunderType pt)
        Add a plunder type.
        Parameters:
        pt - The PlunderType to add.
      • getGifts

        public final RandomRange getGifts()
        Get the range of gifts available to a unit.
        Returns:
        A range of gifts, or null if none applicable.
      • getWarehouseCapacity

        public int getWarehouseCapacity()
        Gets the warehouse capacity of this settlement.
        Returns:
        The warehouse capacity of this settlement.
      • 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.