Class ServerColony

    • Field Detail

      • logger

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

      • ServerColony

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

        public ServerColony​(Game game,
                            Player owner,
                            java.lang.String name,
                            Tile tile)
        Creates a new ServerColony.
        Parameters:
        game - The Game in which this object belongs.
        owner - The Player owning this Colony.
        name - The name of the new Colony.
        tile - The location of the Colony.
    • Method Detail

      • neededForBuildableType

        private boolean neededForBuildableType​(GoodsType goodsType)
        Is a goods type needed for a buildable that this colony could be building.
        Parameters:
        goodsType - The GoodsType to check.
        Returns:
        True if the goods could be used to build something.
      • csBuildUnit

        private Unit csBuildUnit​(BuildQueue<? extends BuildableType> buildQueue,
                                 java.util.Random random,
                                 ChangeSet cs)
        Build a unit from a build queue.
        Parameters:
        buildQueue - The BuildQueue to find the unit in.
        random - A pseudo-random number source.
        cs - A ChangeSet to update.
        Returns:
        The unit that was built.
      • ejectUnits

        public boolean ejectUnits​(WorkLocation workLocation,
                                  java.util.List<Unit> units)
        Eject units to any available work location. Called on building type changes, see below and
        Parameters:
        workLocation - The WorkLocation to eject from.
        units - A list of Units to eject.
        Returns:
        True if units were ejected.
        See Also:
        -til: Might change the visible colony size.
      • csBuildBuilding

        private boolean csBuildBuilding​(BuildQueue<? extends BuildableType> buildQueue,
                                        ChangeSet cs)
        Builds a building from a build queue.
        Parameters:
        buildQueue - The BuildQueue to build from.
        cs - A ChangeSet to update.
        Returns:
        True if the build succeeded.
      • csNextBuildable

        private BuildableType csNextBuildable​(BuildQueue<? extends BuildableType> queue,
                                              ChangeSet cs)
        Removes a buildable from a build queue, and updates the queue so that a valid buildable is now being built if possible.
        Parameters:
        queue - The BuildQueue to update.
        cs - A ChangeSet to update.
        Returns:
        The next buildable that can be built, or null if nothing.
      • csEvictUsers

        public void csEvictUsers​(Unit enemyUnit,
                                 ChangeSet cs)
        Evict the users from a tile used by this colony, due to military action from another unit.
        Parameters:
        enemyUnit - The Unit that has moved in.
        cs - A ChangeSet to update.
      • csChangeOwner

        public void csChangeOwner​(Player newOwner,
                                  boolean reassign,
                                  java.lang.String change,
                                  ChangeSet cs)
        Change the owner of this colony. -vis: Owner and new owner
        Parameters:
        newOwner - The new owning Player.
        reassign - If true, reassign the colony tiles.
        change - An optional accompanying change type for the units.
        cs - A ChangeSet to update.
      • csFreeBuilding

        public void csFreeBuilding​(BuildingType type,
                                   ChangeSet cs)
        Add a free building to this colony. Triggered directly by election of laSalle, or at end of turn.
        Parameters:
        type - The BuildingType to add.
        cs - A ChangeSet to update.
      • buildBuilding

        private boolean buildBuilding​(Building building)
        Build a new building in this colony.
        Parameters:
        building - The Building to build.
        Returns:
        True if the building was built.
      • 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.
      • csAddConvert

        public void csAddConvert​(Unit brave,
                                 ChangeSet cs)
        Add a new convert to this colony.
        Parameters:
        brave - The convert Unit.
        cs - A ChangeSet to update.
      • destroyBuilding

        public boolean destroyBuilding​(Building building)
        Destroy an existing building in this colony.
        Parameters:
        building - The Building to destroy.
        Returns:
        True if the building was destroyed.
      • csNewTurnWarnings

        public void csNewTurnWarnings​(java.util.Random random,
                                      LogBuilder lb,
                                      ChangeSet cs)
        Do the checks for user warnings that must wait for all player settlements, units and whatever to stabilize. Along the way, throw away excess goods. For example, a pioneer might clear a colony tile and change the lumber amount.
        Parameters:
        random - A Random number source.
        lb - A LogBuilder to log to.
        cs - A ChangeSet to update.
      • csNewTurn

        public void csNewTurn​(java.util.Random random,
                              LogBuilder lb,
                              ChangeSet cs)
        New turn for this colony. Try to find out if the colony is going to survive (last colonist does not starve) before generating lots of production-related messages.
        Specified by:
        csNewTurn in interface TurnTaker
        Parameters:
        random - A Random number source.
        lb - A LogBuilder to log to.
        cs - A ChangeSet to update.