Commit | Line | Data |
---|---|---|
fdc7d56f | 1 | /* |
e95fc82a KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
a6547b1d | 5 | * %sccs.include.redist.c% |
fdc7d56f EW |
6 | */ |
7 | ||
8340cf9a | 8 | #ifndef lint |
a6547b1d | 9 | static char sccsid[] = "@(#)room.c 5.3 (Berkeley) %G%"; |
e95fc82a | 10 | #endif /* not lint */ |
8340cf9a EW |
11 | |
12 | #include "externs.h" | |
13 | ||
14 | writedes() | |
15 | { | |
16 | int compass; | |
17 | register char *p; | |
18 | register c; | |
19 | ||
20 | printf("\n\t%s\n", location[position].name); | |
a7c71d1e | 21 | if (beenthere[position] < 3) { |
8340cf9a EW |
22 | compass = NORTH; |
23 | for (p = location[position].desc; c = *p++;) | |
24 | if (c != '-' && c != '*' && c != '+') | |
25 | putchar(c); | |
26 | else { | |
27 | if (c != '*') | |
28 | printf(truedirec(compass, c)); | |
29 | compass++; | |
30 | } | |
31 | } | |
32 | } | |
33 | ||
34 | printobjs() | |
35 | { | |
a7c71d1e | 36 | register unsigned int *p = location[position].objects; |
8340cf9a EW |
37 | register n; |
38 | ||
39 | printf("\n"); | |
a7c71d1e EW |
40 | for (n = 0; n < NUMOFOBJECTS; n++) |
41 | if (testbit(p, n) && objdes[n]) | |
42 | puts(objdes[n]); | |
8340cf9a EW |
43 | } |
44 | ||
45 | whichway(here) | |
46 | struct room here; | |
47 | { | |
48 | switch(direction) { | |
49 | ||
50 | case NORTH: | |
51 | left = here.west; | |
52 | right = here.east; | |
53 | ahead = here.north; | |
54 | back = here.south; | |
55 | break; | |
56 | ||
57 | case SOUTH: | |
58 | left = here.east; | |
59 | right = here.west; | |
60 | ahead = here.south; | |
61 | back = here.north; | |
62 | break; | |
63 | ||
64 | case EAST: | |
65 | left = here.north; | |
66 | right = here.south; | |
67 | ahead = here.east; | |
68 | back = here.west; | |
69 | break; | |
70 | ||
71 | case WEST: | |
72 | left = here.south; | |
73 | right = here.north; | |
74 | ahead = here.west; | |
75 | back = here.east; | |
76 | break; | |
77 | ||
78 | } | |
79 | } | |
80 | ||
81 | char * | |
82 | truedirec(way, option) | |
83 | int way; | |
84 | char option; | |
85 | { | |
86 | switch(way) { | |
87 | ||
88 | case NORTH: | |
89 | switch(direction) { | |
90 | case NORTH: | |
91 | return("ahead"); | |
92 | case SOUTH: | |
93 | return(option == '+' ? "behind you" : "back"); | |
94 | case EAST: | |
95 | return("left"); | |
96 | case WEST: | |
97 | return("right"); | |
98 | } | |
99 | ||
100 | case SOUTH: | |
101 | switch(direction) { | |
102 | case NORTH: | |
103 | return(option == '+' ? "behind you" : "back"); | |
104 | case SOUTH: | |
105 | return("ahead"); | |
106 | case EAST: | |
107 | return("right"); | |
108 | case WEST: | |
109 | return("left"); | |
110 | } | |
111 | ||
112 | case EAST: | |
113 | switch(direction) { | |
114 | case NORTH: | |
115 | return("right"); | |
116 | case SOUTH: | |
117 | return("left"); | |
118 | case EAST: | |
119 | return("ahead"); | |
120 | case WEST: | |
121 | return(option == '+' ? "behind you" : "back"); | |
122 | } | |
123 | ||
124 | case WEST: | |
125 | switch(direction) { | |
126 | case NORTH: | |
127 | return("left"); | |
128 | case SOUTH: | |
129 | return("right"); | |
130 | case EAST: | |
131 | return(option == '+' ? "behind you" : "back"); | |
132 | case WEST: | |
133 | return("ahead"); | |
134 | } | |
135 | ||
136 | default: | |
137 | printf("Error: room %d. More than four directions wanted.", position); | |
138 | return("!!"); | |
139 | } | |
140 | } | |
141 | ||
142 | newway(thisway) | |
143 | int thisway; | |
144 | { | |
145 | switch(direction){ | |
146 | ||
147 | case NORTH: | |
148 | switch(thisway){ | |
149 | case LEFT: | |
150 | direction = WEST; | |
151 | break; | |
152 | case RIGHT: | |
153 | direction = EAST; | |
154 | break; | |
155 | case BACK: | |
156 | direction = SOUTH; | |
157 | break; | |
158 | } | |
159 | break; | |
160 | case SOUTH: | |
161 | switch(thisway){ | |
162 | case LEFT: | |
163 | direction = EAST; | |
164 | break; | |
165 | case RIGHT: | |
166 | direction = WEST; | |
167 | break; | |
168 | case BACK: | |
169 | direction = NORTH; | |
170 | break; | |
171 | } | |
172 | break; | |
173 | case EAST: | |
174 | switch(thisway){ | |
175 | case LEFT: | |
176 | direction = NORTH; | |
177 | break; | |
178 | case RIGHT: | |
179 | direction = SOUTH; | |
180 | break; | |
181 | case BACK: | |
182 | direction = WEST; | |
183 | break; | |
184 | } | |
185 | break; | |
186 | case WEST: | |
187 | switch(thisway){ | |
188 | case LEFT: | |
189 | direction = SOUTH; | |
190 | break; | |
191 | case RIGHT: | |
192 | direction = NORTH; | |
193 | break; | |
194 | case BACK: | |
195 | direction = EAST; | |
196 | break; | |
197 | } | |
198 | break; | |
199 | } | |
200 | } |