|
@ -5,7 +5,7 @@ |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
#include "map.h" |
|
|
#include "map.h" |
|
|
#include "nav_helper.h" |
|
|
|
|
|
|
|
|
#include "utils.h" |
|
|
#include "items.h" |
|
|
#include "items.h" |
|
|
#include "shop.h" |
|
|
#include "shop.h" |
|
|
#include "player.h" |
|
|
#include "player.h" |
|
@ -16,7 +16,7 @@ bool gameRunning; |
|
|
bool acceptedRules; |
|
|
bool acceptedRules; |
|
|
|
|
|
|
|
|
// declare needed variables |
|
|
// declare needed variables |
|
|
Room *map; //game Map |
|
|
|
|
|
|
|
|
Room *gameMap; //game Map |
|
|
Item *availableItems; //shop items |
|
|
Item *availableItems; //shop items |
|
|
Player actualPlayer; //player |
|
|
Player actualPlayer; //player |
|
|
int inputCounter = 0; //need to check on some positions |
|
|
int inputCounter = 0; //need to check on some positions |
|
@ -86,7 +86,7 @@ void setUp() |
|
|
gameRunning = 1; |
|
|
gameRunning = 1; |
|
|
|
|
|
|
|
|
// get Content |
|
|
// get Content |
|
|
map = getMap(gameMapFile); |
|
|
|
|
|
|
|
|
gameMap = getMap(gameMapFile); |
|
|
availableItems = getItems(itemsMapFile); |
|
|
availableItems = getItems(itemsMapFile); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -129,7 +129,7 @@ void processInput(char userInput[20]) |
|
|
{ |
|
|
{ |
|
|
lastPlayerPosition = playerPosition; //playerPosition doesn't change but lastPlayerPosition needs update |
|
|
lastPlayerPosition = playerPosition; //playerPosition doesn't change but lastPlayerPosition needs update |
|
|
|
|
|
|
|
|
Room actualRoom = map[playerPosition]; |
|
|
|
|
|
|
|
|
Room actualRoom = gameMap[playerPosition]; |
|
|
if (actualRoom.shopAvailable == 1) |
|
|
if (actualRoom.shopAvailable == 1) |
|
|
{ |
|
|
{ |
|
|
int *result = malloc(sizeof(int) * 2); |
|
|
int *result = malloc(sizeof(int) * 2); |
|
@ -172,7 +172,7 @@ 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 = gameMap[playerPosition]; |
|
|
inputCounter += 1; |
|
|
inputCounter += 1; |
|
|
if (strcmp(userInput, "north") == 0) |
|
|
if (strcmp(userInput, "north") == 0) |
|
|
{ |
|
|
{ |
|
@ -232,6 +232,6 @@ void printStatus() |
|
|
|
|
|
|
|
|
if (lastPlayerPosition != playerPosition || lastPlayerPosition == playerPosition || playerPosition == 0 && inputCounter == 0) |
|
|
if (lastPlayerPosition != playerPosition || lastPlayerPosition == playerPosition || playerPosition == 0 && inputCounter == 0) |
|
|
{ |
|
|
{ |
|
|
printRoomStatus(moveMessage, map[playerPosition], playerPosition); |
|
|
|
|
|
|
|
|
printRoomStatus(moveMessage, gameMap[playerPosition], playerPosition); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |