Class BuildingType

    • Field Detail

      • level

        private int level
        The level of building.
      • workPlaces

        private int workPlaces
        The number of work places a unit can work in buildings of this type.
      • minSkill

        private int minSkill
        The minimum unit skill to work in buildings of this type.
      • maxSkill

        private int maxSkill
        The maximum unit skill to work in buildings of this type.
      • upkeep

        private int upkeep
        Upkeep per turn for buildings ot this type.
      • priority

        private int priority
        Consumption order.
      • expertConnectionProduction

        private int expertConnectionProduction
        Maximum production from the "experts have connections" option.
      • competenceFactor

        private float competenceFactor
        A multiplier for any unit goods-specific bonus for this building type.
      • rebelFactor

        private float rebelFactor
        The multiplier for the colony rebel bonus for this building type.
      • upgradesFrom

        private BuildingType upgradesFrom
        The building type this upgrades from.
      • upgradesTo

        private BuildingType upgradesTo
        The building type this upgrades to.
      • productionTypes

        private final java.util.List<ProductionType> productionTypes
        The possible production types of this building type.
      • COMPETENCE_FACTOR_TAG

        private static final java.lang.String COMPETENCE_FACTOR_TAG
        See Also:
        Constant Field Values
      • EXPERTS_WITH_CONNECTION_PRODUCTION_TAG

        private static final java.lang.String EXPERTS_WITH_CONNECTION_PRODUCTION_TAG
        See Also:
        Constant Field Values
      • MAXIMUM_SKILL_TAG

        private static final java.lang.String MAXIMUM_SKILL_TAG
        See Also:
        Constant Field Values
      • MINIMUM_SKILL_TAG

        private static final java.lang.String MINIMUM_SKILL_TAG
        See Also:
        Constant Field Values
      • REBEL_FACTOR_TAG

        private static final java.lang.String REBEL_FACTOR_TAG
        See Also:
        Constant Field Values
      • UPGRADES_FROM_TAG

        private static final java.lang.String UPGRADES_FROM_TAG
        See Also:
        Constant Field Values
      • OLD_MAX_SKILL_TAG

        private static final java.lang.String OLD_MAX_SKILL_TAG
        See Also:
        Constant Field Values
      • OLD_MIN_SKILL_TAG

        private static final java.lang.String OLD_MIN_SKILL_TAG
        See Also:
        Constant Field Values
      • OLD_UPGRADES_FROM_TAG

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

      • BuildingType

        public BuildingType​(java.lang.String id,
                            Specification specification)
        Creates a new BuildingType instance.
        Parameters:
        id - The object identifier.
        specification - The Specification to refer to.
    • Method Detail

      • getLevel

        public int getLevel()
        Get the level of this BuildingType.
        Returns:
        The building level.
      • getWorkPlaces

        public int getWorkPlaces()
        Gets the number of workplaces, that is the maximum number of Units that can work in this BuildingType.
        Returns:
        The number of work places.
      • getMinimumSkill

        public int getMinimumSkill()
      • getMaximumSkill

        public int getMaximumSkill()
      • getUpkeep

        public int getUpkeep()
        Gets the amount of gold necessary to maintain a Building of this type for one turn.
        Returns:
        The per turn upkeep for this building type.
      • getExpertConnectionProduction

        public int getExpertConnectionProduction()
        Get the maximum production for the Experts-With-Connections option.
        Returns:
        The production amount.
      • getCompetenceFactor

        public float getCompetenceFactor()
        Get a work location specific factor to multiply any unit goods specific bonuses by.
        Returns:
        The competence factor.
      • getRebelFactor

        public float getRebelFactor()
        Get a work location specific factor to multiply the colony rebel bonus by.
        Returns:
        The rebel factor.
      • getPriority

        public int getPriority()
        The consumption priority of a Building of this type. The higher the priority, the earlier will the Consumer be allowed to consume the goods it requires.
        Returns:
        The consumption priority.
      • getNoAddReason

        public UnitLocation.NoAddReason getNoAddReason​(UnitType unitType)
        Gets the reason why a given unit type can not be added to a building of this type.
        Parameters:
        unitType - The UnitType to test.
        Returns:
        The reason why adding would fail.
      • canAdd

        public boolean canAdd​(UnitType unitType)
        Can a unit of a given type be added to a Building of this type?
        Parameters:
        unitType - The UnitType to check.
        Returns:
        True if the unit type can be added.
      • getType

        public FreeColSpecObjectType getType()
        Gets the type of the building type, which is trivially just this object.
        Returns:
        This.
      • getUpgradesFrom

        public BuildingType getUpgradesFrom()
        Gets the BuildingType this BuildingType upgrades from.
        Returns:
        The BuildingType that upgrades to this one.
      • getUpgradesTo

        public BuildingType getUpgradesTo()
        Get the BuildingType this BuildingType upgrades to.
        Returns:
        The BuildingType to upgrade to from this one.
      • getFirstLevel

        public BuildingType getFirstLevel()
        Gets the first level of this BuildingType.
        Returns:
        The base BuildingType.
      • isAutomaticBuild

        public boolean isAutomaticBuild()
        Is this building type automatically built in any colony?
        Returns:
        True if this building type is automatically built.
      • 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.
      • addProductionType

        public void addProductionType​(ProductionType productionType)
        Add a production type to this building type.
        Parameters:
        productionType - The ProductionType to add.
      • getAvailableProductionTypes

        public java.util.List<ProductionType> getAvailableProductionTypes​(boolean unattended)
        Get the production types provided by this building type 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 at the current difficulty level. FIXME: TileType.getAvailableProductionTypes(boolean) uses the GameOptions.TILE_PRODUCTION option. Should we implement a corresponding one for BuildingTypes?
        Parameters:
        unattended - Whether the production is unattended.
        level - The production level (NYI).
        Returns:
        A list of ProductionTypes.
      • getProducedGoodsType

        public GoodsType getProducedGoodsType()
        Gets the type of goods produced by this BuildingType.
        Returns:
        The produced GoodsType.
      • isDefenceType

        public boolean isDefenceType()
        Is this a defence-related building type? Such buildings (stockade et al) are visible to other players.
        Returns:
        True if this is a defence related building.
      • 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 a 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.
      • canBeBuiltInColony

        public Colony.NoBuildReason canBeBuiltInColony​(Colony colony,
                                                       java.util.List<BuildableType> assumeBuilt)
        Check to see if this buildable type can be built in a colony based on the buildings or units available.
        Specified by:
        canBeBuiltInColony in class BuildableType
        Parameters:
        colony - The Colony to check.
        assumeBuilt - A list of BuildableTypes.
        Returns:
        The reason the for failure, or NoBuildReason.NONE on success.
      • compareTo

        public int compareTo​(FreeColObject other)
        Base for Comparable implementations.
        Specified by:
        compareTo in interface java.lang.Comparable<FreeColObject>
        Overrides:
        compareTo in class FreeColObject
        Parameters:
        other - The other FreeColObject subclass to compare.
        Returns:
        The comparison result.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class BuildableType
        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 BuildableType
        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 BuildableType
        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 BuildableType
        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 BuildableType
        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.