Class Map
- java.lang.Object
-
- page.codeberg.terratactician_expandoria.world.Map
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Map.MapIterator
Iterator for the map.
-
Field Summary
Fields Modifier and Type Field Description java.util.HashMap<CubeCoordinate,Tile>
map
Map containing all placed tiles.
-
Constructor Summary
Constructors Constructor Description Map()
Creates a empty map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tile
at(CubeCoordinate coord)
Get Tile at a position.static Map
deserialize(org.json.JSONArray data)
deserializes the map from jsonjava.util.Iterator<Tile>
getArea(CubeCoordinate coord, int radius)
Returns an Iterator, that iterates over all existing tiles in a given radius.java.util.Iterator<Tile>
getNeighbors(CubeCoordinate coord)
Returns all existing Tile that are direct neighbors of the given coordinate.java.util.Iterator<Tile>
getRing(CubeCoordinate coord, int radius)
Returns an Iterator, that iterates over all existing tiles on a hexagon outline.java.util.Collection<Tile>
iterateTiles()
Returns a Collections of all tiles on the map.java.util.Iterator<Tile>
iterator()
java.lang.String
toString()
-
-
-
Field Detail
-
map
public java.util.HashMap<CubeCoordinate,Tile> map
Map containing all placed tiles.
-
-
Method Detail
-
deserialize
public static Map deserialize(org.json.JSONArray data)
deserializes the map from json- Parameters:
data
- json data- Returns:
- deserialized map
-
at
public Tile at(CubeCoordinate coord)
Get Tile at a position. Returns null if there is no Tile.- Parameters:
coord
- Query position- Returns:
- Tile or null
-
iterateTiles
public java.util.Collection<Tile> iterateTiles()
Returns a Collections of all tiles on the map.- Returns:
- collection of all tiles on the map
-
getArea
public java.util.Iterator<Tile> getArea(CubeCoordinate coord, int radius)
Returns an Iterator, that iterates over all existing tiles in a given radius. The radius does define the size of a hexagon.- Parameters:
coord
- center of the hexagonradius
- size of the hexagon, min 1- Returns:
- tile area iterator
-
getRing
public java.util.Iterator<Tile> getRing(CubeCoordinate coord, int radius)
Returns an Iterator, that iterates over all existing tiles on a hexagon outline. The radius does define the size of the hexagon.- Parameters:
coord
- center of the hexagonradius
- size of the hexagon, min 0- Returns:
- tile ring iterator
-
getNeighbors
public java.util.Iterator<Tile> getNeighbors(CubeCoordinate coord)
Returns all existing Tile that are direct neighbors of the given coordinate.- Parameters:
coord
- center- Returns:
- neighbors iterator
-
iterator
public java.util.Iterator<Tile> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Tile>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-