Browse Source

added showInventory to main

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
0ba71809f4
  1. 13
      src/c/main.c

13
src/c/main.c

@ -137,16 +137,18 @@ void processInput(char userInput[20])
int result = openShop(availableItems); // result > 0 -> integer = index of item OR result = 0 -> cancel int result = openShop(availableItems); // result > 0 -> integer = index of item OR result = 0 -> cancel
if (result > 0) if (result > 0)
{ {
addItemToInventory(availableItems, result, actualPlayer);
actualPlayer = addItemToInventory(availableItems, result, actualPlayer);
} }
printStatus();
}
else if (strcmp(userInput, "inventory") == 0)
{
showInventory(actualPlayer);
} }
else if (checkMove(userInput) == 1) else if (checkMove(userInput) == 1)
{ {
printf("Wrong Input!\n"); printf("Wrong Input!\n");
} }
inputCounter += 1;
} }
// function for checking user input of exit // function for checking user input of exit
@ -163,12 +165,10 @@ int checkExit(char userInput[20])
// check is user moved // check is user moved
int checkMove(char userInput[20]) int checkMove(char userInput[20])
{ {
Room r = map[playerPosition]; Room r = map[playerPosition];
inputCounter += 1;
if (strcmp(userInput, "north") == 0) if (strcmp(userInput, "north") == 0)
{ {
printf("->N\n");
lastPlayerPosition = playerPosition; lastPlayerPosition = playerPosition;
if (playerPosition == (int)(mapMax - 1)) if (playerPosition == (int)(mapMax - 1))
{ {
@ -183,7 +183,6 @@ int checkMove(char userInput[20])
} }
else if (strcmp(userInput, "south") == 0) else if (strcmp(userInput, "south") == 0)
{ {
printf("->S\n");
lastPlayerPosition = playerPosition; lastPlayerPosition = playerPosition;
if (playerPosition > 0) if (playerPosition > 0)
{ {

Loading…
Cancel
Save