From 434ef7a3e6bcefa31c212a3662d50d3f955dddb9 Mon Sep 17 00:00:00 2001 From: KRUGSON Date: Sun, 5 Feb 2023 03:42:58 +0100 Subject: [PATCH] added showInventory --- src/c/player.c | 22 ++++++++++++++++++++++ src/c/player.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/c/player.c b/src/c/player.c index c789fed..3b3afef 100644 --- a/src/c/player.c +++ b/src/c/player.c @@ -14,4 +14,26 @@ Player addItemToInventory(Item *availableItems, int itemIndex, Player actualPlay actualPlayer.itemCounter += 1; return actualPlayer; +} + +void showInventory(Player actualPlayer) +{ + int inventoryItemCounter = actualPlayer.itemCounter; + + if (inventoryItemCounter == 0) + { + printf("*** Inventory is empty *** \n\n"); + } + else + { + printf("*** Inventory *** \n\n"); + + for (int i = 0; i < actualPlayer.itemCounter; i++) + { + // printf("%d: %d - %s\n", i, inventory[i].id, inventory[i].itemName); + printf("> %s - %d\n", actualPlayer.itemInventory[i].itemName, i); + } + } + + printf("\n\n"); } \ No newline at end of file diff --git a/src/c/player.h b/src/c/player.h index 25a69be..fdb704a 100644 --- a/src/c/player.h +++ b/src/c/player.h @@ -13,4 +13,6 @@ typedef struct Player addItemToInventory(Item *availableItem, int itemIndex, Player actualPlayer); +void showInventory(Player actualPlayer); + #endif \ No newline at end of file