Class ServerUnit

    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
    • Constructor Detail

      • ServerUnit

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

        public ServerUnit​(Game game,
                          Location location,
                          Player owner,
                          UnitType type)
        Creates a new ServerUnit. -vis: Visibility issues depending on location. -til: Changes appearance if unit goes into a colony.
        Parameters:
        game - The Game in which this unit belongs.
        location - The Location to place this at.
        owner - The Player owning this unit.
        type - The type of the unit.
      • ServerUnit

        public ServerUnit​(Game game,
                          Location location,
                          Unit template)
        Create a new ServerUnit from a template. Note all FCGOTs are looked up in the specification by id, allowing the template to derive from a different specification as might happen when loading a scenario map. -vis: Visibility issues depending on location. -til: Changes appearance if unit goes into a colony.
        Parameters:
        game - The Game in which this unit belongs.
        location - The Location to place this at.
        template - A Unit to copy from.
      • ServerUnit

        public ServerUnit​(Game game,
                          Location location,
                          Player owner,
                          UnitType type,
                          Role role)
        Creates a new ServerUnit. -vis: Visibility issues depending on location. -til: Changes appearance if unit goes into a colony.
        Parameters:
        game - The Game in which this unit belongs.
        location - The Location to place this at.
        owner - The Player owning this unit.
        type - The type of the unit.
        role - The role of the unit.
    • Method Detail

      • csImproveTile

        private void csImproveTile​(java.util.Random random,
                                   ChangeSet cs)
        Completes a tile improvement. +til: Resolves the change of appearance.
        Parameters:
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csEmbark

        public void csEmbark​(Unit carrier,
                             ChangeSet cs)
        Embark a unit.
        Parameters:
        carrier - The Unit to embark on.
        cs - A ChangeSet to update.
      • csRepairUnit

        public void csRepairUnit​(ChangeSet cs)
        Repair a unit.
        Parameters:
        cs - A ChangeSet to update.
      • getSlowedBy

        private Unit getSlowedBy​(Tile newTile,
                                 java.util.Random random)
        If a unit moves, check if an opposing naval unit slows it down. Note that the unit moves are reduced here.
        Parameters:
        newTile - The Tile the unit is moving to.
        random - A pseudo-random number source.
        Returns:
        Either an enemy unit that causes a slowdown, or null if none.
      • csNativeBurialGround

        private void csNativeBurialGround​(ChangeSet cs)
        Explores a lost city, finding a native burial ground.
        Parameters:
        cs - A ChangeSet to add changes to.
      • csExploreLostCityRumour

        private boolean csExploreLostCityRumour​(java.util.Random random,
                                                ChangeSet cs)
        Explore a lost city.
        Parameters:
        random - A pseudo-random number source.
        cs - A ChangeSet to add changes to.
        Returns:
        True if the unit survives.
      • csNewContactCheck

        public void csNewContactCheck​(Tile newTile,
                                      boolean firstLanding,
                                      ChangeSet cs)
        Check for new contacts at a tile.
        Parameters:
        newTile - The Tile to check.
        firstLanding - True if this is the special "first landing"
        cs - A ChangeSet to update.
      • csActivateSentries

        private void csActivateSentries​(Tile tile,
                                        ChangeSet cs)
        Activate sentried units on a tile.
        Parameters:
        tile - The Tile to activate sentries on.
        cs - A ChangeSet to update.
      • csMove

        public void csMove​(Tile newTile,
                           java.util.Random random,
                           ChangeSet cs)
        Move a unit.
        Parameters:
        newTile - The Tile to move to.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
      • csCheckDiscoverRegion

        public void csCheckDiscoverRegion​(Tile tile,
                                          ChangeSet cs)
        Check for a new region.
        Parameters:
        tile - The Tile to check at.
        cs - A ChangeSet to update.
      • csVisit

        public void csVisit​(ServerPlayer serverPlayer,
                            IndianSettlement is,
                            int scout,
                            ChangeSet cs)
        Visits a native settlement, possibly scouting it fully if as a result of a scout actually asking to speak to the chief, or for other settlement-contacting events such as missionary actions, demanding tribute, learning skills and trading if the settlementActionsContactChief game option is enabled. It is still unclear what Col1 did here.
        Parameters:
        serverPlayer - The ServerPlayer that is contacting the settlement.
        is - The IndianSettlement to contact.
        scout - Positive if this contact is due to a scout asking to speak to the chief, zero if it is another unit, negative if this is from the greeting dialog generation.
        cs - A ChangeSet to update.
      • csRemove

        public void csRemove​(ChangeSet.See see,
                             Location loc,
                             ChangeSet cs)
        Remove this unit from the game.
        Parameters:
        see - The visibility of the change.
        loc - The Location of the change.
        cs - A ChangeSet to update.
      • csNewTurn

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