Package net.sf.freecol.server.generator
Class River
- java.lang.Object
-
- net.sf.freecol.server.generator.River
-
public class River extends java.lang.ObjectA river for the map generator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classRiver.DirectionChangePossible direction changes for a river.
-
Field Summary
Fields Modifier and Type Field Description private booleanconnectedWhether the river is connected to the high seas.private DirectiondirectionCurrent direction the river is flowing in.private static java.util.logging.Loggerloggerprivate MapmapThe map on which the river flows.private RivernextRiverThe next river.private java.util.RandomrandomThe random number source.private ServerRegionregionThe ServerRegion this River belongs to.private java.util.Map<Tile,River>riverMapA hashtable of position-river pairs.private TileImprovementTyperiverTypeprivate java.util.List<RiverSection>sectionsA list of river sections.
-
Constructor Summary
Constructors Constructor Description River(Map map, java.util.Map<Tile,River> riverMap, ServerRegion region, java.util.Random random)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Tile tile, Direction direction)Adds a new section to this river.private booleancontains(Tile tile)Returns true if this river already contains the given tile.private voidcreateDelta(Tile tile, Direction direction, RiverSection section)private voiddelta(Tile tile, Direction direction, RiverSection section, Direction d)private voiddrawToMap(java.util.List<RiverSection> sections)Draws the completed river to the map.private booleanflow(Tile source)Lets the river flow from the given tile.booleanflowFromSource(Tile tile)Creates a river flowing from the given tile if possible.RiverSectiongetLastSection()intgetLength()Returns the length of this river.ServerRegiongetRegion()Get theServerRegionvalue.java.util.List<RiverSection>getSections()private voidgrow(RiverSection lastSection, Tile tile)Increases the size of this river.private booleanisNextToSelf(Tile tile)Returns true if the given tile is next to this river.private booleanisNextToWater(Tile tile)Returns true if the given tile is next to a river, lake or sea.voidsetRegion(ServerRegion newServerRegion)Set theServerRegionvalue.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
riverType
private final TileImprovementType riverType
-
direction
private Direction direction
Current direction the river is flowing in.
-
map
private final Map map
The map on which the river flows.
-
sections
private java.util.List<RiverSection> sections
A list of river sections.
-
nextRiver
private River nextRiver
The next river.
-
region
private ServerRegion region
The ServerRegion this River belongs to.
-
random
private final java.util.Random random
The random number source.
-
connected
private boolean connected
Whether the river is connected to the high seas.
-
-
Constructor Detail
-
River
public River(Map map, java.util.Map<Tile,River> riverMap, ServerRegion region, java.util.Random random)
Constructor.- Parameters:
map- The map on which the river flows.riverMap- A hashtable of position-river pairs.region- The region for this river.random- TheRandomnumber source to use.
-
-
Method Detail
-
getSections
public java.util.List<RiverSection> getSections()
-
getLength
public int getLength()
Returns the length of this river.- Returns:
- the length of this river.
-
getLastSection
public RiverSection getLastSection()
-
getRegion
public final ServerRegion getRegion()
Get theServerRegionvalue.- Returns:
- a
ServerRegionvalue
-
setRegion
public final void setRegion(ServerRegion newServerRegion)
Set theServerRegionvalue.- Parameters:
newServerRegion- The new ServerRegion value.
-
add
public void add(Tile tile, Direction direction)
Adds a new section to this river.- Parameters:
tile- TheTilewhere this section is located.direction- TheDirectionthe river is flowing in.
-
grow
private void grow(RiverSection lastSection, Tile tile)
Increases the size of this river.- Parameters:
lastSection- The last section of the river flowing into this one.tile- TheTileof the confluence.
-
isNextToSelf
private boolean isNextToSelf(Tile tile)
Returns true if the given tile is next to this river.- Parameters:
tile- A map tile.- Returns:
- true if the given tile is next to this river.
-
isNextToWater
private boolean isNextToWater(Tile tile)
Returns true if the given tile is next to a river, lake or sea.- Parameters:
tile- A map tile.- Returns:
- true if the given tile is next to a river, lake or sea.
-
contains
private boolean contains(Tile tile)
Returns true if this river already contains the given tile.- Parameters:
tile- A map tile.- Returns:
- true if this river already contains the given tile.
-
flowFromSource
public boolean flowFromSource(Tile tile)
Creates a river flowing from the given tile if possible.- Parameters:
tile- An origin mapTile.- Returns:
- True if a river was created, false otherwise.
-
flow
private boolean flow(Tile source)
Lets the river flow from the given tile.- Parameters:
source- A map tile.- Returns:
- true if a river was created, false otherwise.
-
createDelta
private void createDelta(Tile tile, Direction direction, RiverSection section)
-
delta
private void delta(Tile tile, Direction direction, RiverSection section, Direction d)
-
drawToMap
private void drawToMap(java.util.List<RiverSection> sections)
Draws the completed river to the map.- Parameters:
sections- A list ofRiverSections to draw.
-
-