-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroom.c
More file actions
61 lines (50 loc) · 1.59 KB
/
Copy pathroom.c
File metadata and controls
61 lines (50 loc) · 1.59 KB
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
#include "room.h"
#include <time.h>
Room* createRoom(char *name, char *description, Item *item, Room *north, Room *west, Room *east, Room *up, Room *down, bool omen, bool Event)
{
Room *newRoom = (Room*) malloc(sizeof(Room));
newRoom->name = name;
newRoom->description = description;
newRoom->item = item;
newRoom->north = north;
newRoom->west = west;
newRoom->east = east;
newRoom->up = up;
newRoom->down = down;
newRoom->omen = omen;
newRoom->Event = Event;
return newRoom;
}
void printArray(int arr[])
{
for (int i = 0; i < 6; i++)
printf("%d ", arr[i]);
printf("\n");
}
void randArry(int array[])
{
//randomizes numbers between 1 and 6 (each number corresponds to a room)
srand(time(NULL)); //to make sure the same seed isn't used
for (int i = 1; i < 6; i++)
{
int j = rand() % i; //generate rand number between 1 and 6
//swapping elements
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
void adjRoomLook(Room *adjRoom)
{
//prints adj rooms to see if the exist or not
if (adjRoom->north == NULL) printf("North is an Unexplored Area\n");
else printf("North is %s\n", adjRoom->north->name);
if (adjRoom->east == NULL) printf("East is an Unexplored Area\n");
else printf("East is %s\n", adjRoom->east->name);
if (adjRoom->west == NULL) printf("West is an Unexplored Area\n");
else printf("West is %s\n", adjRoom->west->name);
if (adjRoom->up == NULL) printf("Up is an Unexplored Area\n");
else printf("Up is %s\n", adjRoom->up->name);
if (adjRoom->down == NULL) printf("Down is an Unexplored Area\n\n");
else printf("Down is %s\n\n", adjRoom->down->name);
}