Package net.sf.freecol.server.generator
Class River
- java.lang.Object
-
- net.sf.freecol.server.generator.River
-
public class River extends java.lang.Object
A river for the map generator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
River.DirectionChange
Possible direction changes for a river.
-
Field Summary
Fields Modifier and Type Field Description private boolean
connected
Whether the river is connected to the high seas.private Direction
direction
Current direction the river is flowing in.private static java.util.logging.Logger
logger
private Map
map
The map on which the river flows.private River
nextRiver
The next river.private java.util.Random
random
The random number source.private ServerRegion
region
The ServerRegion this River belongs to.private java.util.Map<Tile,River>
riverMap
A hashtable of position-river pairs.private TileImprovementType
riverType
private java.util.List<RiverSection>
sections
A 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 void
add(Tile tile, Direction direction)
Adds a new section to this river.private boolean
contains(Tile tile)
Returns true if this river already contains the given tile.private void
createDelta(Tile tile, Direction direction, RiverSection section)
private void
delta(Tile tile, Direction direction, RiverSection section, Direction d)
private void
drawToMap(java.util.List<RiverSection> sections)
Draws the completed river to the map.private boolean
flow(Tile source)
Lets the river flow from the given tile.boolean
flowFromSource(Tile tile)
Creates a river flowing from the given tile if possible.RiverSection
getLastSection()
int
getLength()
Returns the length of this river.ServerRegion
getRegion()
Get theServerRegion
value.java.util.List<RiverSection>
getSections()
private void
grow(RiverSection lastSection, Tile tile)
Increases the size of this river.private boolean
isNextToSelf(Tile tile)
Returns true if the given tile is next to this river.private boolean
isNextToWater(Tile tile)
Returns true if the given tile is next to a river, lake or sea.void
setRegion(ServerRegion newServerRegion)
Set theServerRegion
value.
-
-
-
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
- TheRandom
number 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 theServerRegion
value.- Returns:
- a
ServerRegion
value
-
setRegion
public final void setRegion(ServerRegion newServerRegion)
Set theServerRegion
value.- Parameters:
newServerRegion
- The new ServerRegion value.
-
add
public void add(Tile tile, Direction direction)
Adds a new section to this river.- Parameters:
tile
- TheTile
where this section is located.direction
- TheDirection
the 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
- TheTile
of 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 ofRiverSection
s to draw.
-
-