Class RiverSection


  • public class RiverSection
    extends java.lang.Object
    This class facilitates building, editing the TileImprovement style for rivers Rivers on the Map are composed of many individual TileImprovements displayed on each Tile the river flows through The river TileImprovement on a Tile has a style which represents the inputs/outputs of water to/from neighboring Tiles This class allows manipulation of individual stream(s) to neighboring Tiles (there are many in case of confluence)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<Direction,​java.lang.Integer> branches
      River magnitude (size) for each direction toward the edges of the tile
      Direction direction
      Direction the river is flowing toward, at the current section
      private int size
      River magnitude (size) at the center of the tile
      private static char[] template  
      private Tile tile
      Tile of the current river section
    • Constructor Summary

      Constructors 
      Constructor Description
      RiverSection​(java.util.Map<Direction,​java.lang.Integer> branches)
      Creates a new RiverSection with the given branches.
      RiverSection​(Tile tile, Direction direction)
      Constructor used to automatically generate rivers.
    • Field Detail

      • template

        private static final char[] template
      • branches

        private java.util.Map<Direction,​java.lang.Integer> branches
        River magnitude (size) for each direction toward the edges of the tile
      • size

        private int size
        River magnitude (size) at the center of the tile
      • direction

        public Direction direction
        Direction the river is flowing toward, at the current section
      • tile

        private Tile tile
        Tile of the current river section
    • Constructor Detail

      • RiverSection

        public RiverSection​(java.util.Map<Direction,​java.lang.Integer> branches)
        Creates a new RiverSection with the given branches. This constructor is used by the map editor.
        Parameters:
        branches - The encoded style
      • RiverSection

        public RiverSection​(Tile tile,
                            Direction direction)
        Constructor used to automatically generate rivers.
        Parameters:
        tile - The map tile
        direction - The direction the river is flowing toward
    • Method Detail

      • getTile

        public final Tile getTile()
        Get the section tile.
        Returns:
        The Tile.
      • getSize

        public final int getSize()
        Returns the size
        Returns:
        size
      • setBranch

        public final void setBranch​(Direction direction,
                                    int size)
        Sets the size of a branch
        Parameters:
        direction - The Direction of the branch.
        size - The size to set.
      • getBranch

        private final int getBranch​(Direction direction)
        Gets the size of a branch
        Parameters:
        direction - The Direction of the branch.
        Returns:
        The branch size.
      • removeBranch

        public final void removeBranch​(Direction direction)
        Removes a branch
        Parameters:
        direction - The Direction of the branch.
      • growBranch

        public final void growBranch​(Direction direction,
                                     int increment)
        Increases the size a branch
        Parameters:
        direction - The Direction of the branch.
        increment - The amount to add to the branch size.
      • grow

        public void grow()
        Increases the size of this section by one.
      • encodeStyle

        public java.lang.String encodeStyle()