|
@ -49,12 +49,14 @@ int *openShop(Item *availableItems, Player player) |
|
|
|
|
|
|
|
|
while (shopIsOpen == 1) |
|
|
while (shopIsOpen == 1) |
|
|
{ |
|
|
{ |
|
|
printf("*** SHOP-Items *** \n\n"); |
|
|
|
|
|
|
|
|
char *header = "SHOP-Items"; |
|
|
|
|
|
printHeader(header); |
|
|
|
|
|
|
|
|
// printf("%-5s %-30s %5s\n", "Index", "Name", "Price"); |
|
|
// printf("%-5s %-30s %5s\n", "Index", "Name", "Price"); |
|
|
for (int i = 0; i < 6; i++) |
|
|
for (int i = 0; i < 6; i++) |
|
|
{ |
|
|
{ |
|
|
printf("%-5d %-40s %5d$\n", availableItems[i].id, availableItems[i].itemName, availableItems[i].price); |
|
|
|
|
|
|
|
|
//printf("%-5d %-40s %5d$\n", availableItems[i].id, availableItems[i].itemName, availableItems[i].price); |
|
|
|
|
|
printItem(header, availableItems[i].itemName, availableItems[i].id, availableItems[i].price); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
printf("\n-> to buy items type '[index of item]' \n-> write '0' to quit the shop'\n\n"); |
|
|
printf("\n-> to buy items type '[index of item]' \n-> write '0' to quit the shop'\n\n"); |
|
@ -92,14 +94,17 @@ int *openShop(Item *availableItems, Player player) |
|
|
{ |
|
|
{ |
|
|
if (player.itemCounter > 0) |
|
|
if (player.itemCounter > 0) |
|
|
{ |
|
|
{ |
|
|
printf("*** Your inventory *** \n\n"); |
|
|
|
|
|
|
|
|
char *header = "Your inventory"; |
|
|
|
|
|
|
|
|
|
|
|
printHeader(header); |
|
|
|
|
|
|
|
|
// printf("%-5s %-30s %5s\n", "Index", "Name", "Price"); |
|
|
// printf("%-5s %-30s %5s\n", "Index", "Name", "Price"); |
|
|
for (int i = 0; i < player.itemCounter; i++) |
|
|
for (int i = 0; i < player.itemCounter; i++) |
|
|
{ |
|
|
{ |
|
|
printf("%-5d %-40s %5d$\n", i+1, player.itemInventory[i].itemName, player.itemInventory[i].price); |
|
|
|
|
|
|
|
|
printItem(header, player.itemInventory[i].itemName, i+1, player.itemInventory[i].price); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n-> to sell items type '[index of item]' \n-> write '0' to quit the shop'\n\n"); |
|
|
printf("\n-> to sell items type '[index of item]' \n-> write '0' to quit the shop'\n\n"); |
|
|
|
|
|
|
|
|
while (scanf(" %d", &userInput) != 1) |
|
|
while (scanf(" %d", &userInput) != 1) |
|
|