diff --git a/Zoelda/src/main/entities/player/PlayerInventory.java b/Zoelda/src/main/entities/player/PlayerInventory.java index 945243f..1764a17 100644 --- a/Zoelda/src/main/entities/player/PlayerInventory.java +++ b/Zoelda/src/main/entities/player/PlayerInventory.java @@ -17,6 +17,7 @@ public class PlayerInventory { */ public PlayerInventory(int inventorySize){ items = new Item [inventorySize]; + currentItem = 0; } /** @@ -27,6 +28,30 @@ public class PlayerInventory { return coins; } + /** + * Setzt die Anzahl von Coins im Inventar zu angegebener Anzahl. + * @param coins Anzahl an coins als int, die im Inventar sein sollen. + */ + public void setCoins(int coins) { + this.coins = coins; + } + + /** + * Fügt die angegebene Anzahl an Coins in das Inventar hinzu. + * @param amount Die Anzahl an Coins als int, die hinzugefügt werden soll. + */ + public void addCoins(int amount){ + this.coins+= amount; + } + + /** + * Entfernt die angegebene Anzahl an Coins vom Inventar. + * @param amount Die Anzahl an Coins als int, die entfernt werden soll. + */ + public void subtractCoins(int amount){ + this.coins-= amount; + } + /** * Getter für das Items im Inventar. * @return gibt ein Array mit allen Item Objekten zurück, die im Inventar enthalten sind. @@ -43,6 +68,14 @@ public class PlayerInventory { this.items = items; } + /** + * Entfernt ein Item auf angegebner Position im Item-Array. + * @param itemPosition Position des Items das entfernt werden soll, angegeben als int. + */ + public void removeItem(int itemPosition) { + items[itemPosition]=null; + } + /** * Setzt das gerade ausgewählte Item fest. * @param currentItem int gibt an welcher Index des Item Arrays ausgewählt werden soll. @@ -51,6 +84,14 @@ public class PlayerInventory { this.currentItem = currentItem; } + /** + * Wechselt auf den nächsten Slot im Inventar. + */ + public void changeCurrentItem(){ + if(currentItem>=items.length) currentItem=0; + else currentItem++; + } + /** * Methode zum Hinzufügen von Items. * @param newItem Das Item, dass hinzugefügt werden soll.