Browse Source

added showInventory

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
434ef7a3e6
  1. 22
      src/c/player.c
  2. 2
      src/c/player.h

22
src/c/player.c

@ -14,4 +14,26 @@ Player addItemToInventory(Item *availableItems, int itemIndex, Player actualPlay
actualPlayer.itemCounter += 1; actualPlayer.itemCounter += 1;
return actualPlayer; 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");
} }

2
src/c/player.h

@ -13,4 +13,6 @@ typedef struct
Player addItemToInventory(Item *availableItem, int itemIndex, Player actualPlayer); Player addItemToInventory(Item *availableItem, int itemIndex, Player actualPlayer);
void showInventory(Player actualPlayer);
#endif #endif
Loading…
Cancel
Save