Browse Source

added items to main and game

remotes/origin/navigation
KRUGSON 2 years ago
parent
commit
3d9394cc71
  1. 16
      src/c/main.c

16
src/c/main.c

@ -6,17 +6,21 @@
#include "map.h" #include "map.h"
#include "nav_helper.h" #include "nav_helper.h"
#include "items.h"
#include "shop.h"
bool gameRunning; bool gameRunning;
bool acceptedRules; bool acceptedRules;
// declare needed variables // declare needed variables
Room *map; Room *map;
Item *availableItems;
int inputCounter = 0; int inputCounter = 0;
// content // content
char *gameInstructionsFile = "../../src/content/game_instructions.txt"; char *gameInstructionsFile = "../../src/content/game_instructions.txt";
char *gameMapFile = "../../src/content/game.map"; char *gameMapFile = "../../src/content/game.map";
char *itemsMapFile = "../../src/content/items.map";
// navigation // navigation
int playerPosition = 0; int playerPosition = 0;
@ -41,6 +45,7 @@ int main()
// get Content // get Content
map = getMap(gameMapFile); map = getMap(gameMapFile);
availableItems = getItems(itemsMapFile);
if (acceptedRules == 1) if (acceptedRules == 1)
{ {
@ -124,6 +129,15 @@ void processInput(char userInput[20])
gameRunning = 0; gameRunning = 0;
printf("!GAME EXIT!\n"); printf("!GAME EXIT!\n");
} }
else if (strcmp(userInput, "shop") == 0)
{
int result = openShop(availableItems); // result > 0 -> integer = index of item OR result = 0 -> cancel
if (result > 0)
{
// buyItem -> we need inventory for player first
}
printStatus();
}
else if (checkMove(userInput) == 1) else if (checkMove(userInput) == 1)
{ {
printf("Wrong Input!\n"); printf("Wrong Input!\n");
@ -143,7 +157,7 @@ int checkExit(char userInput[20])
return 0; return 0;
} }
//check is user moved
// check is user moved
int checkMove(char userInput[20]) int checkMove(char userInput[20])
{ {

Loading…
Cancel
Save