Class ServerRegion

    • Field Detail

      • PACIFIC_SCORE_VALUE

        public static final int PACIFIC_SCORE_VALUE
        Score for being first to discover the pacific.
        See Also:
        Constant Field Values
      • size

        private int size
        The size of this Region (number of Tiles).
      • bounds

        private java.awt.Rectangle bounds
        A Rectangle that contains all points of the Region.
    • Constructor Detail

      • ServerRegion

        public ServerRegion​(Game game,
                            java.lang.String id)
        Trivial constructor for serialization.
        Parameters:
        game - The Game to create in.
        id - The object identifier.
      • ServerRegion

        public ServerRegion​(Game game,
                            Region region)
        Constructor for copying in a new region from an imported game.
        Parameters:
        game - The Game to create in.
        region - A Region to copy.
      • ServerRegion

        public ServerRegion​(Game game,
                            Region.RegionType type)
        Create a new discoverable server region of a given type.
        Parameters:
        game - The Game to create in.
        type - The RegionType to use.
      • ServerRegion

        private ServerRegion​(Map map,
                             java.lang.String key,
                             Region.RegionType type,
                             Region parent)
        Create a new fixed server region.
        Parameters:
        map - The Map to create in.
        key - The key for the region.
        type - The RegionType to use.
        parent - The Region to be the parent of this one.
      • ServerRegion

        private ServerRegion​(Game game,
                             java.lang.String key,
                             Region.RegionType type,
                             Region parent)
        Create a new fixed server region.
        Parameters:
        game - The Game to create in.
        key - The key for the region.
        type - The RegionType to use.
        parent - The Region to be the parent of this one.
    • Method Detail

      • getSize

        public final int getSize()
        Get the number of tiles in this region.
        Returns:
        The number of tiles in this region.
      • setSize

        public final void setSize​(int size)
        Set the number of tiles in this region.
        Parameters:
        size - The new number of tiles.
      • getBounds

        public final java.awt.Rectangle getBounds()
        Get the bounding rectangle for this region.
        Returns:
        The bounding Rectangle.
      • isGeographic

        public final boolean isGeographic()
        Is this a geographic region?
        Returns:
        True if this is a geographic region.
      • getCenter

        public int[] getCenter()
        Get the center of the regions bounds.
        Returns:
        An two member array [x,y] of the center coordinate.
      • containsCenter

        public boolean containsCenter​(ServerRegion other)
        Does this region contain the center of another?
        Parameters:
        other - The other ServerRegion to check.
        Returns:
        True if the center of the other region is within this one.
      • addTile

        public void addTile​(Tile tile)
        Add the given tile to this region.
        Parameters:
        tile - A Tile to add.
      • csDiscover

        public void csDiscover​(Player player,
                               Unit unit,
                               Turn turn,
                               java.lang.String newName,
                               ChangeSet cs)
        Discover this region.
        Parameters:
        player - The discovering Player.
        unit - The discovering Unit.
        turn - The discovery Turn.
        newName - The name of the region.
        cs - A ChangeSet to update.
      • requireFixedRegions

        public static java.util.List<ServerRegion> requireFixedRegions​(Map map,
                                                                       LogBuilder lb)
        Make the fixed regions if they do not exist in a given map.
        Parameters:
        map - The Map to check.
        lb - A LogBuilder to log to.
        Returns:
        A list of fixed server regions.
      • fillOcean

        private static int fillOcean​(Map map,
                                     Tile tile,
                                     ServerRegion region,
                                     java.awt.Rectangle bounds)
        Flood fill ocean regions.
        Parameters:
        map - The Map to fill in.
        tile - A valid starting Tile.
        region - A ServerRegion to fill with.
        bounds - A Rectangle that bounds the filling.
        Returns:
        The number of tiles filled.
      • toString

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