-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.h
81 lines (63 loc) · 1.56 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef UTIL_H
#define UTIL_H
typedef struct room room_t;
typedef struct item item_t;
typedef struct itemList itemList_t;
typedef struct world world_t;
#include <stdio.h>
#include "trigger.h"
#include "load.h"
struct item {
char * name;
char * description;
char * examine;
char ** actions;
};
struct room {
char * description;
room_t * north, * south, * east, * west, * up, * down;
itemList_t * items;
};
struct itemList {
item_t ** itemArray;
int capacity;
int size;
};
struct world {
room_t * allRooms;
int numRooms;
room_t * room;
itemList_t * inventory;
itemList_t * allItems;
trigger_t * allTrigs;
int numTrigs;
};
typedef enum {
NORTH,
SOUTH,
EAST,
WEST,
UP,
DOWN,
EAST_BY_EAST_WEST
} compass;
/* Reads a string from given file 'f' until delimiter 'd' or EOF is found
Returns an allocated string read from file */
char * getstring(char d, FILE * f);
/* Case insensitive string equivalence. Returns 1 when strings equal, 0 if not */
int striEqu(const char *, const char *);
/* Initializes everything in a room struct to NULL */
void roomInit(room_t newroom);
/* Adds a NULL item to an itemList */
void addItem(itemList_t * inv);
/* Adds a room to a world */
void addRoom(world_t * clarkson);
/* Adds a trigger to a world */
void addTrig(world_t * clarkson);
/* Links to rooms together */
void linkRoom(world_t * clarkson, int a, int b, compass dir);
/* Initializes a world to NULL and 0 rooms */
void worldInit(world_t * clarkson);
/* return compass direction based on user input for use by other functions */
compass direction(char * dir);
#endif