From 20f014209a7973360d1a741c7108c361d63c1101 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Tue, 1 Jun 2021 00:31:50 +0200 Subject: [PATCH] feat: added inventory method to get inventory as array --- .../marvelous/gamelibrary/entities/Inventory.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Inventory.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Inventory.java index 28b589a..cf1bbbd 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Inventory.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Inventory.java @@ -80,6 +80,16 @@ public class Inventory implements Iterable { content.remove(stone); } + /** Returns the stones inside of the Inventory as Array of {@link StoneType StoneTypes} */ + public StoneType[] getStonesAsArray() { + var toReturn = new StoneType[content.size()]; + var iterator = content.iterator(); + for (int i = 0; i < content.size(); i++) { + toReturn[i] = iterator.next(); + } + return toReturn; + } + /** Iterates over the inventory. */ @Override public Iterator iterator() {