Class Hand
- java.lang.Object
-
- page.codeberg.terratactician_expandoria.world.Hand
-
- All Implemented Interfaces:
java.lang.Iterable<Tile.TileType>
public class Hand extends java.lang.Object implements java.lang.Iterable<Tile.TileType>
Hand class is list of Tiles. This class will be used to communicate the cards currently placeable to the bot in challenge mode.
-
-
Field Summary
Fields Modifier and Type Field Description java.util.List<Tile.TileType>
hand
placeable cards
-
Constructor Summary
Constructors Constructor Description Hand()
Creates a empty hand.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Hand
deserialize(org.json.JSONArray data)
deserialize Hand from jsonTile.TileType
get(int i)
Gets the Card from the Hand at a given index.boolean
isEmpty()
If no card is available.java.util.Iterator<Tile.TileType>
iterator()
Iterates over all available Cards on the hand.int
len()
Amount of playable cards available.java.lang.String
toString()
-
-
-
Field Detail
-
hand
public java.util.List<Tile.TileType> hand
placeable cards
-
-
Method Detail
-
deserialize
public static Hand deserialize(org.json.JSONArray data)
deserialize Hand from json- Parameters:
data
- json input- Returns:
- deserialize hand
-
get
public Tile.TileType get(int i) throws java.lang.IndexOutOfBoundsException
Gets the Card from the Hand at a given index.- Parameters:
i
- index in the hand- Returns:
- playable card
- Throws:
java.lang.IndexOutOfBoundsException
- gets thrown if slot is empty / does not exists
-
len
public int len()
Amount of playable cards available.- Returns:
- amount of playable cards
-
isEmpty
public boolean isEmpty()
If no card is available.- Returns:
- whether hand is empty
-
iterator
public java.util.Iterator<Tile.TileType> iterator()
Iterates over all available Cards on the hand.- Specified by:
iterator
in interfacejava.lang.Iterable<Tile.TileType>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-