Class Tile
- java.lang.Object
-
- page.codeberg.terratactician_expandoria.world.tiles.Tile
-
- Direct Known Subclasses:
BeehiveTile
,ChameleonTile
,DoubleHouseTile
,ForestTile
,GrassTile
,MarketplaceTile
,MoaiTile
,RgbTile
,SmallHouseTile
,StoneHillTile
,StoneMountainTile
,StoneQuarryTile
,StoneRocksTile
,WheatTile
,WindmillTile
public abstract class Tile extends java.lang.Object
Abstract class for a tile. A tile is entity/card/building placed or placeable on the map.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Tile.TileType
Encodes all Tile variants.
-
Field Summary
Fields Modifier and Type Field Description CubeCoordinate
coord
Coordinate of this tile.float
reclaimTime
Time left to reclaim (pick up again) a Tile.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Tile
clone()
Creates a clone of the tile.java.lang.String
dataToString()
Can be used by tile to add internal data to `toString`.static Tile
deserialize(java.lang.String json)
Deserializes a Tile without data.static Tile
deserialize(org.json.JSONObject json)
Deserializes a Tile with data.CubeCoordinate
getCoordinate()
Returns Coordinate of Tile.abstract java.lang.String
getName()
Name of Tile in Api interface.boolean
reclaimable()
Returns whether a tile can be taken again.org.json.JSONObject
serialize()
serializes a tile to a json object.org.json.JSONObject
serializeData()
Serializes extra Data of an Tile, to be send.boolean
takeable()
Returns whether a tile can be taken again.java.lang.String
toString()
-
-
-
Field Detail
-
coord
public CubeCoordinate coord
Coordinate of this tile. This may be null if tile is not placed.
-
reclaimTime
public float reclaimTime
Time left to reclaim (pick up again) a Tile. NaN if a tile is not pickup able.
-
-
Method Detail
-
clone
public abstract Tile clone()
Creates a clone of the tile.- Overrides:
clone
in classjava.lang.Object
- Returns:
- the new tile
-
getCoordinate
public CubeCoordinate getCoordinate()
Returns Coordinate of Tile.- Returns:
- coordinate of the tile
-
reclaimable
public boolean reclaimable()
Returns whether a tile can be taken again. This will cost a small amount of resources.- Returns:
- if tile is reclaimable
-
takeable
public boolean takeable()
Returns whether a tile can be taken again. This will cost a small amount of resources.- Returns:
- if tile is takeable
-
serializeData
public org.json.JSONObject serializeData()
Serializes extra Data of an Tile, to be send.- Returns:
- null or JSONObject with at least a valid "type" field.
-
getName
public abstract java.lang.String getName()
Name of Tile in Api interface.- Returns:
- api name of the tile
-
deserialize
public static Tile deserialize(org.json.JSONObject json)
Deserializes a Tile with data. Takes a JSONObject as argument and tries to parse it. Returns null on error.- Parameters:
json
- json data- Returns:
- Event or null on error.
-
deserialize
public static Tile deserialize(java.lang.String json)
Deserializes a Tile without data. Takes a String as argument and tries to parse it. Returns null on error.- Parameters:
json
- json data- Returns:
- Event or null on error.
-
serialize
public org.json.JSONObject serialize()
serializes a tile to a json object.- Returns:
- json data
-
dataToString
public java.lang.String dataToString()
Can be used by tile to add internal data to `toString`. Returned string should start with: ", "- Returns:
- additional data stringified
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-