From daea02f10a70bfd69fd65d13074e12c3b4bb6b95 Mon Sep 17 00:00:00 2001 From: Kai Kehres Date: Sat, 28 Jan 2023 20:15:44 +0100 Subject: [PATCH] prod: created initializeInventory function --- src/c/character.c | 7 +++++++ src/c/character.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/c/character.c b/src/c/character.c index 7bc246b..141be76 100644 --- a/src/c/character.c +++ b/src/c/character.c @@ -247,6 +247,13 @@ char* getItemName (Item *item) { return item->name; } +void initializeInventory (Character *character) { + for (int i = 0; i < 10; i++) + { + character->inventory[i] = NULL; + } +} + void putItemInInventory (Character *character, Item *item,int inventorySlot) { if(inventorySlot > 9) { printf("Inventory slot is out of range (0-9)\n"); diff --git a/src/c/character.h b/src/c/character.h index 4ff39f2..c47f8f6 100644 --- a/src/c/character.h +++ b/src/c/character.h @@ -123,4 +123,5 @@ char* getItemName (Item *item); void putItemInInventory (Character *character, Item *item, int inventorySlot); +void initializeInventory (Character *character); #endif \ No newline at end of file