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>handplaceable 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 Handdeserialize(org.json.JSONArray data)deserialize Hand from jsonTile.TileTypeget(int i)Gets the Card from the Hand at a given index.booleanisEmpty()If no card is available.java.util.Iterator<Tile.TileType>iterator()Iterates over all available Cards on the hand.intlen()Amount of playable cards available.java.lang.StringtoString()
-
-
-
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:
iteratorin interfacejava.lang.Iterable<Tile.TileType>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-