Class ServerPlayer

    • Field Detail

      • logger

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

        public static final int SCORE_SETTLEMENT_DESTROYED
        See Also:
        Constant Field Values
      • SCORE_INDEPENDENCE_BONUS_FIRST

        public static final int SCORE_INDEPENDENCE_BONUS_FIRST
        See Also:
        Constant Field Values
      • SCORE_INDEPENDENCE_BONUS_SECOND

        public static final int SCORE_INDEPENDENCE_BONUS_SECOND
        See Also:
        Constant Field Values
      • SCORE_INDEPENDENCE_BONUS_THIRD

        public static final int SCORE_INDEPENDENCE_BONUS_THIRD
        See Also:
        Constant Field Values
      • connection

        private Connection connection
        The connection for this player.
      • remainingEmigrants

        private int remainingEmigrants
        Remaining emigrants to select due to a fountain of youth
      • stanceDirty

        private final java.util.List<Player> stanceDirty
        Players with respect to which stance has changed.
      • extraTrades

        private final java.util.List<AbstractGoods> extraTrades
        Accumulate extra trades here.
    • Constructor Detail

      • ServerPlayer

        public ServerPlayer​(Game game,
                            java.lang.String id)
        Trivial constructor for Game.newInstance.
        Parameters:
        game - The Game this object belongs to.
        id - The object identifier.
      • ServerPlayer

        public ServerPlayer​(Game game,
                            Connection connection)
        Special constructor to make a simple stub player with only the connection information valid. Needed when a new player logs in.
        Parameters:
        game - The Game this player belongs to.
        connection - The initial Connection.
      • ServerPlayer

        public ServerPlayer​(Game game,
                            boolean admin,
                            Nation nation)
        Creates a new ServerPlayer.
        Parameters:
        game - The Game this object belongs to.
        admin - Whether the player is the game administrator or not.
        nation - The nation of the Player.
    • Method Detail

      • initialize

        public final void initialize​(Game game,
                                     boolean admin,
                                     Nation nation)
        Complete initialization for this server player. Used above and for the stub players created at login.
        Parameters:
        game - The Game this object belongs to.
        admin - Whether the player is the game administrator or not.
        nation - The nation for this player.
      • getConnection

        public final Connection getConnection()
        Gets the connection of this player.
        Overrides:
        getConnection in class Player
        Returns:
        The Connection.
      • setConnection

        public final void setConnection​(Connection connection)
        Sets the connection of this player.
        Overrides:
        setConnection in class Player
        Parameters:
        connection - The Connection.
      • send

        public boolean send​(ChangeSet cs)
        Send a change set across the connection.
        Overrides:
        send in class Player
        Parameters:
        cs - The ChangeSet to send.
        Returns:
        True if the message was sent.
      • updateCurrentFather

        public void updateCurrentFather​(FoundingFather ff)
        Update the current father.
        Parameters:
        ff - The FoundingFather to recruit.
      • newTradeRoute

        public TradeRoute newTradeRoute()
        Get a new trade route.
        Returns:
        The new TradeRoute.
      • addExtraTrade

        public void addExtraTrade​(AbstractGoods ag)
        Accumulate extra trades.
        Parameters:
        ag - The AbstractGoods describing the sale.
      • flushExtraTrades

        public void flushExtraTrades​(java.util.Random random)
        Flush the extra trades.
        Parameters:
        random - A pseudo-random number source.
      • randomizeGame

        public void randomizeGame​(java.util.Random random)
        Performs initial randomizations for this player.
        Parameters:
        random - A pseudo-random number source.
      • checkForDeath

        public ServerPlayer.DeadCheck checkForDeath()
        Checks if this player has died.
        Returns:
        The appropriate DeadCheck value.
      • checkForREFDefeat

        private boolean checkForREFDefeat()
        Check if a REF player has been defeated and should surrender.
        Returns:
        True if this REF player has been defeated.
      • csKill

        private void csKill​(ChangeSet cs)
        Kill off a player and clear out its remains. +vis: Albeit killing the player makes visibility changes moot. +til: Fixes the appearance changes too.
        Parameters:
        cs - A ChangeSet to update.
      • csWithdraw

        public void csWithdraw​(ChangeSet cs,
                               ModelMessage mm,
                               HistoryEvent he)
        Withdraw a player from the new world. Called from the standard endTurn processing when a player is found to have died, and from the Spanish Succession routine.
        Parameters:
        mm - A ModelMessage explaining why the player is leaving, or null if the standard death message should be used.
        he - A corresponding HistoryEvent, or null if the standard death message should be used.
        cs - A ChangeSet to update.
      • getRemainingEmigrants

        public int getRemainingEmigrants()
      • setRemainingEmigrants

        public void setRemainingEmigrants​(int emigrants)
      • checkFoundingFather

        private FoundingFather checkFoundingFather()
        Checks whether the current founding father has been recruited.
        Returns:
        The new founding father, or null if none available or ready.
      • canRecruitFoundingFather

        public boolean canRecruitFoundingFather()
        Checks whether to start recruiting a founding father.
        Returns:
        True if a new father should be chosen.
      • getRandomFoundingFathers

        private java.util.List<FoundingFather> getRandomFoundingFathers​(java.util.Random random)
        Build a list of random FoundingFathers, one per type. Do not include any the player has or are not available.
        Parameters:
        random - A pseudo-random number source.
        Returns:
        A list of FoundingFathers.
      • addHistory

        public void addHistory​(HistoryEvent event)
        Add a HistoryEvent to this player.
        Overrides:
        addHistory in class Player
        Parameters:
        event - The HistoryEvent to add.
      • updateScore

        private boolean updateScore()
        Update the current score for this player. Known incompatibility with the Col1 manual: ``In addition, you get one point per liberty bell produced after foreign intervention'' However you are already getting a point per liberty bell produced, so this implies you get no further liberty after declaring independence!?, but it can then start again if the foreign intervention happens (penalizing players who quickly thrash the REF:-S). Whatever this really means, it is incompatible with our extensions to allow playing on (and defeating other Europeans), so for now at least just leave the simple liberty==score rule in place.
        Returns:
        True if the player score changed.
      • hasExplored

        public boolean hasExplored​(Tile tile)
        Checks if this Player has explored the given Tile.
        Overrides:
        hasExplored in class Player
        Parameters:
        tile - The Tile.
        Returns:
        true if the Tile has been explored and false otherwise.
      • exploreTile

        public boolean exploreTile​(Tile tile)
        Sets the given tile to be explored by this player and updates the player's information about the tile. +til: Exploring the tile also updates the pet.
        Parameters:
        tile - The Tile to explore.
        Returns:
        True if the tile is newly explored by this action.
      • exploreTiles

        public java.util.Set<Tile> exploreTiles​(java.util.Collection<? extends Tile> tiles)
        Sets the tiles within the given Unit's line of sight to be explored by this player.
        Parameters:
        tiles - A list of Tiles.
        Returns:
        A list of newly explored Tiles.
        See Also:
        hasExplored(net.sf.freecol.common.model.Tile)
      • exploreForSettlement

        public java.util.Set<Tile> exploreForSettlement​(Settlement settlement)
        Sets the tiles visible to a given settlement to be explored by this player and updates the player's information about the tiles. Note that the player does not necessarily own the settlement (e.g. missionary at native settlement).
        Parameters:
        settlement - The Settlement that is exploring.
        Returns:
        A list of newly explored Tiles.
      • exploreForUnit

        public java.util.Set<Tile> exploreForUnit​(Unit unit)
        Sets the tiles within the given Unit's line of sight to be explored by this player.
        Parameters:
        unit - The Unit.
        Returns:
        A list of newly explored Tiles.
        See Also:
        hasExplored(net.sf.freecol.common.model.Tile)
      • exploreMap

        public java.util.Set<Tile> exploreMap​(boolean reveal)
        Makes the entire map visible or invisible.
        Parameters:
        reveal - If true, reveal the map, if false, hide it.
        Returns:
        A list of tiles whose visibility changed.
      • collectNewTiles

        public java.util.Set<Tile> collectNewTiles​(Tile center,
                                                   int radius)
        Given a tile and new radius of visibility, explore unexplored tiles and return those plus the previously invisible tiles.
        Parameters:
        center - The center Tile to explore from.
        radius - A radius to explore to.
        Returns:
        A set of newly explored or currently invisible Tiles.
      • collectNewTiles

        public java.util.Set<Tile> collectNewTiles​(java.util.Collection<Tile> collection)
        Given a tile and new radius of visibility, explore unexplored tiles and return those plus the previously invisible tiles.
        Parameters:
        collection - A Collection of tiles to check.
        Returns:
        A set of newly explored or currently invisible Tiles.
      • collectNewTiles

        public java.util.Set<Tile> collectNewTiles​(java.util.stream.Stream<Tile> tiles)
        Given a stream of tiles, explore unexplored tiles and return those plus the previously invisible tiles.
        Parameters:
        tiles - A stream of Tiles to check.
        Returns:
        A set of newly explored or currently invisible Tiles.
      • reassignTiles

        public void reassignTiles​(java.util.Collection<Tile> tiles,
                                  Settlement avoid)
        Try to reassign the ownership of a collection of tiles, preferring this player. Do it in two passes so the first successful claim does not give a large advantage.
        Parameters:
        tiles - The collection of Tiles to reassign.
        avoid - An optional Settlement to consider last when making claims.
      • createUnits

        public java.util.List<Unit> createUnits​(java.util.List<AbstractUnit> abstractUnits,
                                                Location location,
                                                java.util.Random random)
        Create units from a list of abstract units. Only used by Europeans at present. -vis: Visibility issues depending on location. -til: Tile appearance issue if created in a colony (not ATM)
        Parameters:
        abstractUnits - The list of AbstractUnits to create.
        location - The Location where the units will be created.
        random - A pseudo-random number source.
        Returns:
        A list of units created.
      • loadShips

        public java.util.List<Unit> loadShips​(java.util.List<Unit> landUnits,
                                              java.util.List<Unit> navalUnits,
                                              java.util.Random random)
        Embark the land units. For all land units, find a naval unit to carry it. Fill greedily, so as if there is excess naval capacity then the naval units at the end of the list will tend to be empty or very lightly filled, allowing them to defend the whole fleet at full strength. Returns a list of units that could not be placed on ships. -vis: Has visibility implications depending on the initial location of the loaded units. Usually ATM this is Europe which is safe, but beware. -til: Safe while in Europe though.
        Parameters:
        landUnits - A list of land units to put on ships.
        navalUnits - A list of ships to put land units on.
        random - An optional pseudo-random number source.
        Returns:
        a list of units left over
      • csFlushMarket

        public boolean csFlushMarket​(ChangeSet cs)
        Flush any market price changes.
        Parameters:
        cs - A ChangeSet to update.
        Returns:
        True if the market has changed.
      • csFlushMarket

        public boolean csFlushMarket​(GoodsType type,
                                     ChangeSet cs)
        Flush any market price changes for a specified goods type.
        Parameters:
        type - The GoodsType to check.
        cs - A ChangeSet to update.
        Returns:
        True if the market price had changed.
      • buyInEurope

        public int buyInEurope​(java.util.Random random,
                               GoodsContainer container,
                               GoodsType type,
                               int amount)
        Buy goods in Europe.
        Parameters:
        random - A pseudo-random number source.
        container - The GoodsContainer to carry the goods.
        type - The GoodsType to buy.
        amount - The amount of goods to buy.
        Returns:
        The amount actually removed from the market, or negative on failure.
      • sellInEurope

        public int sellInEurope​(java.util.Random random,
                                GoodsContainer container,
                                GoodsType type,
                                int amount)
        Sell goods in Europe.
        Parameters:
        random - A pseudo-random number source.
        container - An optional GoodsContainer carrying the goods.
        type - The GoodsType to sell.
        amount - The amount of goods to sell.
        Returns:
        The amount actually added to the market, or negative on failure.
      • addStanceChange

        private void addStanceChange​(Player other)
        Adds a player to the list of players for whom the stance has changed.
        Parameters:
        other - The Player to add.
      • csChangeStance

        public boolean csChangeStance​(Stance stance,
                                      Player otherPlayer,
                                      boolean symmetric,
                                      ChangeSet cs)
        Modifies stance.
        Parameters:
        stance - The new Stance.
        otherPlayer - The Player wrt which the stance changes.
        symmetric - If true, change the otherPlayer stance as well.
        cs - A ChangeSet to update.
        Returns:
        True if there was a change in stance at all.
      • csModifyTension

        public void csModifyTension​(Player player,
                                    int add,
                                    ChangeSet cs)
        Modifies the hostility against the given player. +til: Handles tile modifications.
        Parameters:
        player - The Player.
        add - The amount to add to the current tension level.
        cs - A ChangeSet to update.
      • csModifyTension

        public void csModifyTension​(Player player,
                                    int add,
                                    Settlement origin,
                                    ChangeSet cs)
        Modifies the hostility against the given player. +til: Handles tile modifications.
        Parameters:
        player - The Player.
        add - The amount to add to the current tension level.
        origin - A Settlement where the alarming event occurred.
        cs - A ChangeSet to update.
      • csPayUpkeep

        private void csPayUpkeep​(java.util.Random random,
                                 ChangeSet cs)
        Pay upkeep on the player resources.
        Parameters:
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csNaturalDisasters

        private void csNaturalDisasters​(java.util.Random random,
                                        ChangeSet cs,
                                        int probability)
        Check for natural disasters.
        Parameters:
        random - A Random number source.
        cs - A ChangeSet to update.
        probability - The percentage probability of a disaster occuring.
      • csApplyDisaster

        public java.util.List<ModelMessage> csApplyDisaster​(java.util.Random random,
                                                            Colony colony,
                                                            Disaster disaster,
                                                            ChangeSet cs)
        Apply the effects of the given Disaster to the given Colony, or the Player if the Colony is null, and return a list of appropriate ModelMessages. Note that a disaster might have no effect on a particular colony. In that case, the returned list is empty.
        Parameters:
        random - A Random number source.
        colony - A Colony, or null.
        disaster - A Disaster value.
        cs - A ChangeSet to update.
        Returns:
        A list of ModelMessages, possibly empty.
      • getBuildingForEffect

        private Building getBuildingForEffect​(Colony colony,
                                              Effect effect,
                                              java.util.Random random)
      • getUnitForEffect

        private Unit getUnitForEffect​(Colony colony,
                                      Effect effect,
                                      java.util.Random random)
      • propagateToEuropeanMarkets

        public void propagateToEuropeanMarkets​(GoodsType type,
                                               int amount,
                                               java.util.Random random)
        Propagate an European market trade to the other European markets.
        Parameters:
        type - The type of goods that was traded.
        amount - The amount of goods that was traded.
        random - A pseudo-random number source (note: may be null in some cases).
      • csYearlyGoodsAdjust

        public void csYearlyGoodsAdjust​(java.util.Random random,
                                        ChangeSet cs)
        Add or remove a standard yearly amount of storable goods, and a random extra amount of a random type. Then push out all the accumulated trades. Public for the test suite.
        Parameters:
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • 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.
      • csBombardEnemyShips

        private void csBombardEnemyShips​(java.util.Random random,
                                         ChangeSet cs)
        All player colonies bombard all available targets.
        Parameters:
        random - A random number source.
        cs - A ChangeSet to update.
      • csAddFoundingFather

        public void csAddFoundingFather​(FoundingFather father,
                                        java.util.Random random,
                                        ChangeSet cs)
        Adds a founding father to a players continental congress.
        Parameters:
        father - The FoundingFather to add.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • getFreeBuildingTypes

        public java.util.List<BuildingType> getFreeBuildingTypes()
        Get a list of free building types this player has access to through its choice of founding fathers. Used to upgrade newly captured colonies.
        Returns:
        A list of free BuildingTypes.
      • csClaimLand

        public void csClaimLand​(Tile tile,
                                Settlement settlement,
                                int price,
                                ChangeSet cs)
        Claim land.
        Parameters:
        tile - The Tile to claim.
        settlement - The Settlement to claim for.
        price - The price to pay for the land, which must agree with the owner valuation, unless negative which denotes stealing.
        cs - A ChangeSet to update.
      • csEmigrate

        public void csEmigrate​(int slot,
                               Europe.MigrationType type,
                               java.util.Random random,
                               ChangeSet cs)
        A unit migrates from Europe.
        Parameters:
        slot - The slot within Europe to select the unit from.
        type - The type of migration occurring.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csCombat

        public void csCombat​(FreeColGameObject attacker,
                             FreeColGameObject defender,
                             java.util.List<CombatModel.CombatResult> crs,
                             java.util.Random random,
                             ChangeSet cs)
        Combat.
        Parameters:
        attacker - The FreeColGameObject that is attacking.
        defender - The FreeColGameObject that is defending.
        crs - A list of CombatResults defining the result.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • getSlaughterTension

        private int getSlaughterTension​(Unit loser)
        Gets the amount to raise tension by when a unit is slaughtered.
        Parameters:
        loser - The Unit that dies.
        Returns:
        An amount to raise tension by.
      • csAutoequipUnit

        private void csAutoequipUnit​(Unit unit,
                                     Settlement settlement,
                                     ChangeSet cs)
        Notifies of automatic arming.
        Parameters:
        unit - The Unit that is auto-equipping.
        settlement - The Settlement being defended.
        cs - A ChangeSet to update.
      • csBurnMissions

        private void csBurnMissions​(Unit attacker,
                                    IndianSettlement is,
                                    ChangeSet cs)
        Burns a players missions.
        Parameters:
        attacker - The Unit that attacked.
        is - The IndianSettlement that was attacked.
        cs - The ChangeSet to update.
      • csCaptureAutoEquip

        private void csCaptureAutoEquip​(Unit attacker,
                                        Unit defender,
                                        ChangeSet cs)
        Defender auto equips but loses and attacker captures the equipment.
        Parameters:
        attacker - The Unit that attacked.
        defender - The Unit that defended and loses equipment.
        cs - A ChangeSet to update.
      • csCaptureColony

        private void csCaptureColony​(Unit attacker,
                                     ServerColony colony,
                                     java.util.Random random,
                                     ChangeSet cs)
        Captures a colony.
        Parameters:
        attacker - The attacking Unit.
        colony - The ServerColony to capture.
        random - A pseudo-random number source.
        cs - The ChangeSet to update.
      • csCaptureConvert

        private void csCaptureConvert​(Unit attacker,
                                      IndianSettlement is,
                                      java.util.Random random,
                                      ChangeSet cs)
        Extracts a convert from a native settlement.
        Parameters:
        attacker - The Unit that is attacking.
        is - The IndianSettlement under attack.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csCaptureEquip

        private void csCaptureEquip​(Unit winner,
                                    Unit loser,
                                    ChangeSet cs)
        Captures equipment.
        Parameters:
        winner - The Unit that captures equipment.
        loser - The Unit that defended and loses equipment.
        cs - A ChangeSet to update.
      • csCaptureEquipment

        private void csCaptureEquipment​(Unit winner,
                                        Unit loser,
                                        Role role,
                                        ChangeSet cs)
        Capture equipment.
        Parameters:
        winner - The Unit that is capturing equipment.
        loser - The Unit that is losing equipment.
        role - The Role wrest from the loser.
        cs - A ChangeSet to update.
      • csCaptureUnit

        private void csCaptureUnit​(Unit winner,
                                   Unit loser,
                                   ChangeSet cs)
        Capture a unit.
        Parameters:
        winner - A Unit that is capturing.
        loser - A Unit to capture.
        cs - A ChangeSet to update.
      • csDamageColonyShips

        private void csDamageColonyShips​(Unit attacker,
                                         Colony colony,
                                         ChangeSet cs)
        Damages all ships in a colony in preparation for capture.
        Parameters:
        attacker - The Unit that is damaging.
        colony - The Colony to damage ships in.
        cs - A ChangeSet to update.
      • csDamageShipAttack

        private void csDamageShipAttack​(Unit attacker,
                                        Unit ship,
                                        ChangeSet cs)
        Damage a ship through normal attack.
        Parameters:
        attacker - The attacker Unit.
        ship - The Unit which is a ship to damage.
        cs - A ChangeSet to update.
      • csDamageShipBombard

        private void csDamageShipBombard​(Settlement settlement,
                                         Unit ship,
                                         ChangeSet cs)
        Damage a ship through bombard.
        Parameters:
        settlement - The attacker Settlement.
        ship - The Unit which is a ship to damage.
        cs - A ChangeSet to update.
      • csDamageShip

        private void csDamageShip​(Unit ship,
                                  Location repair,
                                  ChangeSet cs)
        Damage a ship.
        Parameters:
        ship - The naval Unit to damage.
        repair - The Location to send it to.
        cs - A ChangeSet to update.
      • csDemoteUnit

        private void csDemoteUnit​(Unit winner,
                                  Unit loser,
                                  ChangeSet cs)
        Demotes a unit.
        Parameters:
        winner - The Unit that won.
        loser - The Unit that lost and should be demoted.
        cs - A ChangeSet to update.
      • csDestroyColony

        private void csDestroyColony​(Unit attacker,
                                     Colony colony,
                                     java.util.Random random,
                                     ChangeSet cs)
        Destroy a colony.
        Parameters:
        attacker - The Unit that attacked.
        colony - The Colony that was attacked.
        random - A pseudo-random number source.
        cs - The ChangeSet to update.
      • csDestroySettlement

        private void csDestroySettlement​(Unit attacker,
                                         IndianSettlement is,
                                         java.util.Random random,
                                         ChangeSet cs)
        Destroys an Indian settlement.
        Parameters:
        attacker - The attacking Unit.
        is - An IndianSettlement to destroy.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csDisposeSettlement

        public void csDisposeSettlement​(Settlement settlement,
                                        ChangeSet cs)
        Disposes of a settlement and reassign its tiles. +vis,til: Resolves the whole mess.
        Parameters:
        settlement - The Settlement under attack.
        cs - A ChangeSet to update.
      • csEvadeAttack

        private void csEvadeAttack​(Unit attacker,
                                   Unit defender,
                                   ChangeSet cs)
        Evade a normal attack.
        Parameters:
        attacker - The attacker Unit.
        defender - A naval Unit that evades the attacker.
        cs - A ChangeSet to update.
      • csEvadeBombard

        private void csEvadeBombard​(Settlement settlement,
                                    Unit defender,
                                    ChangeSet cs)
        Evade a bombardment.
        Parameters:
        settlement - The attacker Settlement.
        defender - A naval Unit that evades the attacker.
        cs - A ChangeSet to update.
      • csLootShip

        private void csLootShip​(Unit winner,
                                Unit loser,
                                ChangeSet cs)
        Loot a ship.
        Parameters:
        winner - The winning naval Unit.
        loser - The losing naval Unit
        cs - A ChangeSet to update.
      • csLoseAutoEquip

        private void csLoseAutoEquip​(Unit attacker,
                                     Unit defender,
                                     ChangeSet cs)
        Unit auto equips but loses equipment.
        Parameters:
        attacker - The Unit that attacked.
        defender - The Unit that defended and loses equipment.
        cs - A ChangeSet to update.
      • csLoseEquip

        private void csLoseEquip​(Unit winner,
                                 Unit loser,
                                 ChangeSet cs)
        Unit drops some equipment.
        Parameters:
        winner - The Unit that won.
        loser - The Unit that lost and loses equipment.
        cs - A ChangeSet to update.
      • csLoseLocation

        public void csLoseLocation​(Location loc,
                                   ChangeSet cs)
        Hook for when a player loses access to a location for whatever reason. Useful for disabling trade routes.
        Parameters:
        loc - The Location that was lost.
        cs - A ChangeSet to update.
      • csPillageColony

        private void csPillageColony​(Unit attacker,
                                     Colony colony,
                                     java.util.Random random,
                                     ChangeSet cs)
        Damage a building or a ship or steal some goods or gold.
        Parameters:
        attacker - The attacking Unit.
        colony - The Colony to pillage.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csDamageBuilding

        private void csDamageBuilding​(Building building,
                                      ChangeSet cs)
        Damage a building in a colony by downgrading it if possible and destroying it otherwise. This is called as a result of pillaging, which always updates the colony tile.
        Parameters:
        building - The Building to damage.
        cs - a ChangeSet value
      • csPromoteUnit

        private void csPromoteUnit​(Unit winner,
                                   ChangeSet cs)
        Promotes a unit.
        Parameters:
        winner - The Unit that won and should be promoted.
        cs - A ChangeSet to update.
      • csSinkColonyShips

        private void csSinkColonyShips​(Unit attacker,
                                       Colony colony,
                                       ChangeSet cs)
        Sinks all ships in a colony.
        Parameters:
        attacker - The attacker Unit.
        colony - The Colony to sink ships in.
        cs - A ChangeSet to update.
      • csSinkShipAttack

        private void csSinkShipAttack​(Unit attacker,
                                      Unit ship,
                                      ChangeSet cs)
        Sinks this ship as result of a normal attack.
        Parameters:
        attacker - The attacker Unit.
        ship - The naval Unit to sink.
        cs - A ChangeSet to update.
      • csSinkShipBombard

        private void csSinkShipBombard​(Settlement settlement,
                                       Unit ship,
                                       ChangeSet cs)
        Sinks this ship as result of a bombard.
        Parameters:
        settlement - The bombarding Settlement.
        ship - The naval Unit to sink.
        cs - A ChangeSet to update.
      • csSinkShip

        private void csSinkShip​(Unit ship,
                                Player attackerPlayer,
                                ChangeSet cs)
        Sink the ship.
        Parameters:
        ship - The naval Unit to sink.
        attackerPlayer - The Player that attacked, or null
        cs - A ChangeSet to update.
      • csSlaughterUnit

        private void csSlaughterUnit​(Unit winner,
                                     Unit loser,
                                     ChangeSet cs)
        Slaughter a unit.
        Parameters:
        winner - The Unit that is slaughtering.
        loser - The Unit to slaughter.
        cs - A ChangeSet to update.
      • csSeeNewTiles

        public void csSeeNewTiles​(java.util.Collection<? extends Tile> newTiles,
                                  ChangeSet cs)
        Updates the player view for each new tile on a supplied list, and update a ChangeSet as well.
        Parameters:
        newTiles - A list of Tiles to update.
        cs - A ChangeSet to update.
      • makeTeaPartyModifier

        public Modifier makeTeaPartyModifier()
        Make a tea party modifier for the current turn. Public for the test suite.
        Returns:
        A tea party Modifier.
      • csRaiseTax

        public void csRaiseTax​(int tax,
                               Goods goods,
                               boolean accepted,
                               ChangeSet cs)
        Raises the players tax rate, or handles a goods party.
        Parameters:
        tax - The new tax rate.
        goods - The Goods to use in a goods party.
        accepted - Whether the tax raise was accepted.
        cs - A ChangeSet to update.
      • ignoreTax

        public void ignoreTax​(int tax,
                              Goods goods,
                              ChangeSet cs)
        Handle the end of a session where the player has ignored a tax increase demand.
        Parameters:
        tax - The new tax rate.
        goods - The Goods to use in a goods party.
        cs - A ChangeSet to update.
      • ignoreMercenaries

        public void ignoreMercenaries​(ChangeSet cs)
        Handle the end of a session where the player has ignored an offer of mercenaries.
        Parameters:
        cs - A ChangeSet to update.
      • csMercenaries

        public void csMercenaries​(int price,
                                  java.util.List<AbstractUnit> mercenaries,
                                  Monarch.MonarchAction action,
                                  java.util.Random random,
                                  ChangeSet cs)
        Add an independent (non-monarch) mercenary offer to the player.
        Parameters:
        price - The price to charge for the mercenaries.
        mercenaries - A list of mercenary units.
        action - The monarch action that caused the offer.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csSetTax

        public void csSetTax​(int tax,
                             ChangeSet cs)
        Set the player tax rate. If this requires a change to the bells bonuses, we have to update the whole player (bah) because we can not yet independently update the feature container.
        Parameters:
        tax - The new tax rate.
        cs - A ChangeSet to update.
      • csAddMercenaries

        public void csAddMercenaries​(java.util.List<AbstractUnit> mercs,
                                     int price,
                                     java.util.Random random,
                                     ChangeSet cs)
        Adds mercenaries that the player has accepted.
        Parameters:
        mercs - A list of mercenaries.
        price - The price to be charged for them.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csContact

        public boolean csContact​(Player other,
                                 ChangeSet cs)
        Make contact between two nations if necessary.
        Parameters:
        other - The other Player.
        cs - A ChangeSet to update.
        Returns:
        True if this was a first contact.
      • csNativeFirstContact

        public void csNativeFirstContact​(Player other,
                                         Tile tile,
                                         ChangeSet cs)
        Initiate first contact between this European and native player.
        Parameters:
        other - The native Player.
        tile - The Tile contact is made at if this is a first landing in the new world and it is owned by the other player.
        cs - A ChangeSet to update.
      • csEuropeanFirstContact

        public void csEuropeanFirstContact​(Unit unit,
                                           Settlement settlement,
                                           Unit otherUnit,
                                           ChangeSet cs)
        Initiate first contact between this European and another European player.
        Parameters:
        unit - The Unit making contact.
        settlement - The Settlement being contacted.
        otherUnit - The other Unit being contacted.
        cs - A ChangeSet to update.
      • csChangeOwner

        public boolean csChangeOwner​(Unit unit,
                                     Player newOwner,
                                     java.lang.String change,
                                     Location loc,
                                     ChangeSet cs)
        Change the owner of a unit or dispose of it if the change is impossible. Move the unit to a new location if necessary. Also handle disappearance of any carried units that will now be invisible to the new owner. -vis(owner,newOwner)
        Parameters:
        unit - The Unit to change ownership of.
        newOwner - The new owning Player.
        change - An optional accompanying change type.
        loc - A optional new Location for the unit.
        cs - A ChangeSet to update.
        Returns:
        True if the new owner can have this unit.
      • csCompleteNativeDemand

        public void csCompleteNativeDemand​(ServerPlayer demandPlayer,
                                           Unit unit,
                                           Colony colony,
                                           GoodsType type,
                                           int amount,
                                           Constants.IndianDemandAction result,
                                           ChangeSet cs)
        Accept the native demand at a players colony.
        Parameters:
        demandPlayer - The ServerPlayer that is demanding.
        unit - The Unit that demanded.
        colony - The Colony that was demanded of.
        type - The GoodsType demanded, or null for gold.
        amount - The amount demanded.
        result - The result of the demand.
        cs - A ChangeSet to update.
      • csDiplomacy

        public void csDiplomacy​(DiplomacySession session,
                                DiplomaticTrade agreement,
                                ChangeSet cs)
        Process European diplomacy according to an agreement.
        Parameters:
        session - The DiplomacySession underway.
        agreement - The DiplomaticTrade to consider.
        cs - A ChangeSet to update.
      • csEndTurn

        public void csEndTurn​(ChangeSet cs)
        Things to do just before ending the turn for a player.
        Parameters:
        cs - A ChangeSet to update.
      • csNewTurn

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

        public java.lang.String toString()
        Overrides:
        toString in class Player