Class Europe

    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • EUROPE_CLASS_INDEX

        private static final int EUROPE_CLASS_INDEX
        Class index for Europe.
        See Also:
        Constant Field Values
      • RECRUIT_PRICE_INITIAL

        private static final int RECRUIT_PRICE_INITIAL
        The initial recruit price.
        See Also:
        Constant Field Values
      • LOWER_CAP_INITIAL

        private static final int LOWER_CAP_INITIAL
        The initial lower bound on recruitment price.
        See Also:
        Constant Field Values
      • ABILITY_DRESS_MISSIONARY

        public static final Ability ABILITY_DRESS_MISSIONARY
      • recruitables

        protected final java.util.List<AbstractUnit> recruitables
        This list represents the types of the units that can be recruited in Europe.
      • unitPrices

        protected final java.util.Map<UnitType,​java.lang.Integer> unitPrices
        Prices for trainable or purchasable units.
      • baseRecruitPrice

        protected int baseRecruitPrice
        Current price to recruit a unit.
      • recruitLowerCap

        protected int recruitLowerCap
        The lower bound on recruitment price.
      • owner

        private Player owner
        The owner of this instance of Europe.
      • featureContainer

        private final FeatureContainer featureContainer
        A feature container for this Europe's special features.
      • RECRUIT_LOWER_CAP_TAG

        private static final java.lang.String RECRUIT_LOWER_CAP_TAG
        See Also:
        Constant Field Values
      • RECRUIT_NUMBER_TAG

        private static final java.lang.String RECRUIT_NUMBER_TAG
        See Also:
        Constant Field Values
      • RECRUIT_PRICE_TAG

        private static final java.lang.String RECRUIT_PRICE_TAG
        See Also:
        Constant Field Values
      • RECRUIT_ROLE_TAG

        private static final java.lang.String RECRUIT_ROLE_TAG
        See Also:
        Constant Field Values
      • RECRUIT_TYPE_TAG

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

      • Europe

        protected Europe​(Game game,
                         Player owner)
        Constructor for ServerEurope.
        Parameters:
        game - The enclosing Game.
        owner - The owning Player.
      • Europe

        public Europe​(Game game,
                      java.lang.String id)
        Creates a new Europe with the given identifier. ( The object should be initialized later.
        Parameters:
        game - The enclosing Game.
        id - The object identifier.
    • Method Detail

      • getRecruitables

        protected java.util.List<AbstractUnit> getRecruitables()
        Get a list of the current recruitables.
        Returns:
        A list of recruitable AbstractUnits.
      • getExpandedRecruitables

        public java.util.List<AbstractUnit> getExpandedRecruitables​(boolean full)
        Get an expanded list of recruitable abstract units, with single counts and limited to valid indices.
        Parameters:
        full - If true, return the full list, otherwise limit to the standard number of migrants.
        Returns:
        A list of AbstractUnits.
      • setRecruitables

        private void setRecruitables​(java.util.List<AbstractUnit> recruitables)
        Set the recruitables list.
        Parameters:
        recruitables - The new list of recruitables AbstractUnits.
      • addRecruitable

        protected boolean addRecruitable​(AbstractUnit au,
                                         boolean force)
        Add a recruitable abstract unit.
        Parameters:
        au - The recruitable AbstractUnit to add.
        force - If true, add beyond the standard limit.
        Returns:
        True if the recruitable was added.
      • addRecruitable

        protected boolean addRecruitable​(UnitType unitType,
                                         boolean force)
        Add a recruitable unit type.
        Parameters:
        unitType - The recruitable UnitType to add.
        force - If true, add beyond the standard limit.
        Returns:
        True if the recruitable was added.
      • getUnitPrices

        protected java.util.Map<UnitType,​java.lang.Integer> getUnitPrices()
        Get the unit price map.
        Returns:
        The map of UnitType to its price.
      • setUnitPrices

        protected void setUnitPrices​(java.util.Map<UnitType,​java.lang.Integer> unitPrices)
        Set the unit price map.
        Parameters:
        unitPrices - The new map of UnitTypes to price.
      • getUnitPrice

        public int getUnitPrice​(UnitType unitType)
        Gets the price of a unit in Europe.
        Parameters:
        unitType - The UnitType to price.
        Returns:
        The price of this unit when trained/purchased in Europe, or UNDEFINED on failure.
      • getBaseRecruitPrice

        protected int getBaseRecruitPrice()
        Get the base recruit price.
        Returns:
        The base recruit price.
      • getCurrentRecruitPrice

        public int getCurrentRecruitPrice()
        Gets the current price for a recruit.
        Returns:
        The current price of the recruit in this Europe.
      • getRecruitLowerCap

        protected int getRecruitLowerCap()
        Get the recruit lower cap price.
        Returns:
        The lower cap on the recruit price.
      • getImmigration

        public int getImmigration​(int production)
        Get any immigration produced in Europe. Col1 penalizes immigration by -4 per unit in Europe per turn, but there is a +2 player bonus, which we might as well add here. Total immigration per turn can not be negative, but that is handled in ServerPlayer.
        Parameters:
        production - The current total colony production.
        Returns:
        Immigration produced this turn in Europe.
      • add

        public boolean add​(Locatable locatable)
        Adds a Locatable to this Location.
        Specified by:
        add in interface Location
        Overrides:
        add in class UnitLocation
        Parameters:
        locatable - The Locatable to add to this Location.
        Returns:
        True if the locatable was added.
      • canAdd

        public boolean canAdd​(Locatable locatable)
        Checks whether or not the specified locatable may be added to this Location.
        Specified by:
        canAdd in interface Location
        Overrides:
        canAdd in class UnitLocation
        Parameters:
        locatable - The Locatable to add.
        Returns:
        True if the locatable can be added to this location.
      • up

        public Location up()
        Promote this location to a more meaningful one if possible. For example: a settlement is more meaningful than the tile it occupies.
        Specified by:
        up in interface Location
        Returns:
        A more meaningful Location, or this one.
      • getRank

        public int getRank()
        Get a integer for this location, for the benefit of location comparators.
        Specified by:
        getRank in interface Location
        Returns:
        A suitable integer.
      • toShortString

        public java.lang.String toShortString()
        Get a short description of this location.
        Specified by:
        toShortString in interface Location
        Returns:
        A short description.
      • getLocationImageKey

        public java.lang.String getLocationImageKey()
        Get an image key for this location.
        Specified by:
        getLocationImageKey in interface Location
        Returns:
        A key for image lookup, null by default.
      • priceGoods

        public int priceGoods​(java.util.List<AbstractGoods> goods)
                       throws FreeColException
        What would the price be for a collection of goods at this location?
        Overrides:
        priceGoods in class UnitLocation
        Parameters:
        goods - The list of AbstractGoods to check for.
        Returns:
        The net cost of acquiring the goods at this location.
        Throws:
        FreeColException - if the goods are unavailable for any reason.
      • equipForRole

        public boolean equipForRole​(Unit unit,
                                    Role role,
                                    int roleCount)
        Equip a unit for a role using resources at this location.
        Overrides:
        equipForRole in class UnitLocation
        Parameters:
        unit - The Unit to equip.
        role - The Role to build for.
        roleCount - The role count.
        Returns:
        True if the equipping succeeded.
      • getNameKey

        public java.lang.String getNameKey()
        Gets the name of this named object. Try to avoid using this directly except in i18n-related routines or to implement itself in more complext objects.
        Specified by:
        getNameKey in interface Named
        Returns:
        The name of the Named.
      • getOwner

        public Player getOwner()
        Gets the owner of this Ownable.
        Specified by:
        getOwner in interface Ownable
        Returns:
        The Player controlling this Ownable.
      • setOwner

        public void setOwner​(Player p)
        Sets the owner of this Ownable.
        Specified by:
        setOwner in interface Ownable
        Parameters:
        p - The Player that should take ownership of this Ownable.
      • getAvailableGoodsCount

        public int getAvailableGoodsCount​(GoodsType goodsType)
        Get the amount of a given goods type at this trade location.
        Specified by:
        getAvailableGoodsCount in interface TradeLocation
        Parameters:
        goodsType - The GoodsType to check.
        Returns:
        The amount of goods present.
      • getExportAmount

        public int getExportAmount​(GoodsType goodsType,
                                   int turns)
        Gets the amount of a given goods type that can be exported from this trade location after a given number of turns.
        Specified by:
        getExportAmount in interface TradeLocation
        Parameters:
        goodsType - The GoodsType to check.
        turns - The number of turns before the goods is required.
        Returns:
        The amount of goods to export.
      • getImportAmount

        public int getImportAmount​(GoodsType goodsType,
                                   int turns)
        Gets the amount of a given goods type that can be imported to this trade location after a given number of turns.
        Specified by:
        getImportAmount in interface TradeLocation
        Parameters:
        goodsType - The GoodsType to check.
        turns - The number of turns before the goods will arrive.
        Returns:
        The amount of goods to import.
      • getLocationName

        public java.lang.String getLocationName​(TradeLocation tradeLocation)
        Function for returning the name of a TradeLocation
        Specified by:
        getLocationName in interface TradeLocation
        Parameters:
        tradeLocation - The TradeLocation to return the name.
        Returns:
        The name.
      • canBeInput

        public boolean canBeInput()
        Can a TradeLocation be set as the input location on a TradeRouteInputPanel
        Specified by:
        canBeInput in interface TradeLocation
        Returns:
        True if possible, false by default.
      • disposeResources

        public void disposeResources()
        Dispose of the resources of this object, and finally remove it from the game. To be extended by subclasses, but they must tail call up towards this.
        Overrides:
        disposeResources in class UnitLocation
      • getLinkTarget

        public FreeColGameObject getLinkTarget​(Player player)
        Get a suitable game object to use as a clickable link in messages to a player. Objects do not have links by default, hence the null return here. However, for example, a player's colony should return itself as a link target.
        Overrides:
        getLinkTarget in class FreeColGameObject
        Parameters:
        player - The Player to make a link for.
        Returns:
        A suitable link target if available, although usually null.
      • getAbilities

        public java.util.stream.Stream<Ability> getAbilities​(java.lang.String id,
                                                             FreeColSpecObjectType fcgot,
                                                             Turn turn)
        Gets the set of abilities with the given identifier from this object. Subclasses with complex ability handling should override this as all prior routines are derived from it.
        Overrides:
        getAbilities in class FreeColObject
        Parameters:
        id - The object identifier.
        fcgot - An optional FreeColSpecObjectType the ability applies to.
        turn - An optional applicable Turn.
        Returns:
        A set of abilities.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class UnitLocation
        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 UnitLocation
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • readAttributes

        public void readAttributes​(FreeColXMLReader xr)
                            throws javax.xml.stream.XMLStreamException
        Reads the attributes of this object from an XML stream.
        Overrides:
        readAttributes in class FreeColGameObject
        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 UnitLocation
        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 UnitLocation
        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.