Class ServerIndianSettlement

    • Field Detail

      • logger

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

        public static final int ALARM_NEW_MISSIONARY
        Alarm added when a new missionary is added.
        See Also:
        Constant Field Values
      • MAX_CONVERT_DISTANCE

        public static final int MAX_CONVERT_DISTANCE
        How far to search for a colony to add an Indian convert to.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ServerIndianSettlement

        public ServerIndianSettlement​(Game game,
                                      java.lang.String id)
        Trivial constructor for Game.newInstance.
        Parameters:
        game - The Game in which this object belong.
        id - The object identifier.
      • ServerIndianSettlement

        public ServerIndianSettlement​(Game game,
                                      Player owner,
                                      java.lang.String name,
                                      Tile tile,
                                      boolean isCapital,
                                      UnitType learnableSkill,
                                      Unit missionary)
        Creates a new ServerIndianSettlement.
        Parameters:
        game - The Game in which this object belong.
        owner - The Player owning this settlement.
        name - The name for this settlement.
        tile - The location of the IndianSettlement.
        isCapital - True if settlement is tribe's capital
        learnableSkill - The skill that can be learned by Europeans at this settlement.
        missionary - The missionary in this settlement (or null).
      • ServerIndianSettlement

        public ServerIndianSettlement​(Game game,
                                      Player owner,
                                      Tile tile,
                                      IndianSettlement template)
        Creates a new ServerIndianSettlement from a template.
        Parameters:
        game - The Game in which this object belong.
        owner - The Player owning this settlement.
        tile - The location of the IndianSettlement.
        template - The template IndianSettlement to copy.
    • Method Detail

      • csStartTurn

        public void csStartTurn​(java.util.Random random,
                                ChangeSet cs)
        Starts a new turn for a player.
        Parameters:
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • addUnits

        public void addUnits​(java.util.Random random)
        Add a standard number of units to this settlement and tile. If a pseudo-random number source is provided use it to pick a random number of units within the ranges provided by the settlement type, otherwise use the average.
        Parameters:
        random - An optional pseudo-random number source.
      • addUnits

        public void addUnits​(int count)
        Add a given number of units to the settlement.
        Parameters:
        count - The number of units to add.
      • consumeGoods

        private void consumeGoods​(GoodsType type,
                                  int amount)
        Convenience function to remove an amount of goods.
        Parameters:
        type - The GoodsType to remove.
        amount - The amount of goods to remove.
      • setAlarm

        public void setAlarm​(Player player,
                             Tension newAlarm)
        Sets alarm towards the given player. -til: Might change tile appearance through most hated state
        Overrides:
        setAlarm in class IndianSettlement
        Parameters:
        player - The Player to set the alarm level for.
        newAlarm - The new alarm value.
      • removeAlarm

        public void removeAlarm​(Player player)
        Removes all alarm towards the given player. Used the a player leaves the game. -til: Might change tile appearance through most hated state
        Parameters:
        player - The Player to remove the alarm for.
      • updateMostHated

        private boolean updateMostHated()
        Updates the most hated nation of this settlement. Needs to be public so it can be set by backwards compatibility code in FreeColServer.loadGame. -til: This might change the tile appearance.
        Returns:
        True if the most hated nation changed.
      • changeAlarm

        private boolean changeAlarm​(Player player,
                                    int amount)
        Change the alarm level of this settlement by a given amount. -til: Might change tile appearance through most hated state
        Parameters:
        player - The Player the alarm level changes wrt.
        amount - The amount to change the alarm by.
        Returns:
        True if the Tension.Level of the settlement alarm changes as a result of this change.
      • csChangeAlarm

        private boolean csChangeAlarm​(Player player,
                                      int add,
                                      boolean propagate,
                                      ChangeSet cs)
        Modifies the alarm level towards the given player due to an event at this settlement, and propagate the alarm upwards through the tribe. -til: Might change tile appearance through most hated state
        Parameters:
        player - The Player to modify alarm for.
        add - The amount to add to the current alarm level.
        propagate - If true, propagate the alarm change upward to the owning player.
        cs - A ChangeSet to update.
        Returns:
        True if the alarm changed.
      • csModifyAlarm

        public boolean csModifyAlarm​(Player player,
                                     int add,
                                     boolean propagate,
                                     ChangeSet cs)
        Modifies the alarm level towards the given player due to an event at this settlement, and propagate the alarm upwards through the tribe. +til: Handles tile visibility changes.
        Parameters:
        player - The Player to modify alarm for.
        add - The amount to add to the current alarm level.
        propagate - If true, propagate the alarm change upward to the owning player.
        cs - A ChangeSet to update.
        Returns:
        True if the alarm changed and the tile added.
      • csChangeMissionary

        public void csChangeMissionary​(Unit missionary,
                                       ChangeSet cs)
        Changes the missionary for this settlement and updates other players. +vis: Handles the visibility implications. +til: Handles the tile appearance change.
        Parameters:
        missionary - The new missionary for this settlement.
        cs - A ChangeSet to update.
      • csKillMissionary

        public void csKillMissionary​(java.lang.Boolean destroy,
                                     ChangeSet cs)
        Kills the missionary at this settlement.
        Parameters:
        destroy - If true, the settlement is destroyed, if false the missionary is denounced, if null do not generate a message.
        cs - A ChangeSet to update.
      • csEquipForRole

        public boolean csEquipForRole​(Unit unit,
                                      Role role,
                                      int roleCount,
                                      java.util.Random random,
                                      ChangeSet cs)
        Equip a unit for a specific role.
        Parameters:
        unit - The Unit to equip.
        role - The Role to equip for.
        roleCount - The role count.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
        Returns:
        True if the equipping succeeds.
      • csCheckTension

        public void csCheckTension​(Player enemy,
                                   Tension.Level oldLevel,
                                   ChangeSet cs)
        Check if tension has increased with respect to an enemy.
        Parameters:
        enemy - The enemy Player.
        oldLevel - The previous tension Level.
        cs - A ChangeSet to update.
      • csNewTurn

        public void csNewTurn​(java.util.Random random,
                              LogBuilder lb,
                              ChangeSet cs)
        New turn for this native settlement.
        Specified by:
        csNewTurn in interface TurnTaker
        Parameters:
        random - A Random number source.
        lb - A LogBuilder to log to.
        cs - A ChangeSet to update.