xref: /original-bsd/games/rogue/play.c (revision b8338845)
1 /*
2  * Copyright (c) 1988 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Timothy C. Stoehr.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  */
20 
21 #ifndef lint
22 static char sccsid[] = "@(#)play.c	5.2 (Berkeley) 02/07/89";
23 #endif /* not lint */
24 
25 /*
26  * play.c
27  *
28  * This source herein may be modified and/or distributed by anybody who
29  * so desires, with the following restrictions:
30  *    1.)  No portion of this notice shall be removed.
31  *    2.)  Credit shall not be taken for the creation of this source.
32  *    3.)  This code is not to be traded, sold, or used for personal
33  *         gain or profit.
34  *
35  */
36 
37 #include "rogue.h"
38 
39 boolean interrupted = 0;
40 char *unknown_command = "unknown command";
41 
42 extern short party_room, bear_trap;
43 extern char hit_message[];
44 extern boolean wizard, trap_door;
45 
46 play_level()
47 {
48 	short ch;
49 	int count;
50 
51 	for (;;) {
52 		interrupted = 0;
53 		if (hit_message[0]) {
54 			message(hit_message, 1);
55 			hit_message[0] = 0;
56 		}
57 		if (trap_door) {
58 			trap_door = 0;
59 			return;
60 		}
61 		move(rogue.row, rogue.col);
62 		refresh();
63 
64 		ch = rgetchar();
65 CMCH:
66 		check_message();
67 		count = 0;
68 CH:
69 		switch(ch) {
70 		case '.':
71 			rest((count > 0) ? count : 1);
72 			break;
73 		case 's':
74 			search(((count > 0) ? count : 1), 0);
75 			break;
76 		case 'i':
77 			inventory(&rogue.pack, ALL_OBJECTS);
78 			break;
79 		case 'f':
80 			fight(0);
81 			break;
82 		case 'F':
83 			fight(1);
84 			break;
85 		case 'h':
86 		case 'j':
87 		case 'k':
88 		case 'l':
89 		case 'y':
90 		case 'u':
91 		case 'n':
92 		case 'b':
93 			(void) one_move_rogue(ch, 1);
94 			break;
95 		case 'H':
96 		case 'J':
97 		case 'K':
98 		case 'L':
99 		case 'B':
100 		case 'Y':
101 		case 'U':
102 		case 'N':
103 		case '\010':
104 		case '\012':
105 		case '\013':
106 		case '\014':
107 		case '\031':
108 		case '\025':
109 		case '\016':
110 		case '\002':
111 			multiple_move_rogue(ch);
112 			break;
113 		case 'e':
114 			eat();
115 			break;
116 		case 'q':
117 			quaff();
118 			break;
119 		case 'r':
120 			read_scroll();
121 			break;
122 		case 'm':
123 			move_onto();
124 			break;
125 		case ',':
126 			kick_into_pack();
127 			break;
128 		case 'd':
129 			drop();
130 			break;
131 		case 'P':
132 			put_on_ring();
133 			break;
134 		case 'R':
135 			remove_ring();
136 			break;
137 		case '\020':
138 			do {
139 				remessage(count++);
140 				ch = rgetchar();
141 			} while (ch == '\020');
142 			goto CMCH;
143 			break;
144 		case '\027':
145 			wizardize();
146 			break;
147 		case '>':
148 			if (drop_check()) {
149 				return;
150 			}
151 			break;
152 		case '<':
153 			if (check_up()) {
154 				return;
155 			}
156 			break;
157 		case ')':
158 		case ']':
159 			inv_armor_weapon(ch == ')');
160 			break;
161 		case '=':
162 			inv_rings();
163 			break;
164 		case '^':
165 			id_trap();
166 			break;
167 		case '/':
168 			id_type();
169 			break;
170 		case '?':
171 			id_com();
172 			break;
173 		case '!':
174 			do_shell();
175 			break;
176 		case 'o':
177 			edit_opts();
178 			break;
179 		case 'I':
180 			single_inv(0);
181 			break;
182 		case 'T':
183 			take_off();
184 			break;
185 		case 'W':
186 			wear();
187 			break;
188 		case 'w':
189 			wield();
190 			break;
191 		case 'c':
192 			call_it();
193 			break;
194 		case 'z':
195 			zapp();
196 			break;
197 		case 't':
198 			throw();
199 			break;
200 		case 'v':
201 			message("rogue-clone: Version III. (Tim Stoehr was here), tektronix!zeus!tims", 0);
202 			break;
203 		case 'Q':
204 			quit(0);
205 		case '0':
206 		case '1':
207 		case '2':
208 		case '3':
209 		case '4':
210 		case '5':
211 		case '6':
212 		case '7':
213 		case '8':
214 		case '9':
215 			move(rogue.row, rogue.col);
216 			refresh();
217 			do {
218 				if (count < 100) {
219 					count = (10 * count) + (ch - '0');
220 				}
221 				ch = rgetchar();
222 			} while (is_digit(ch));
223 			if (ch != CANCEL) {
224 				goto CH;
225 			}
226 			break;
227 		case ' ':
228 			break;
229 		case '\011':
230 			if (wizard) {
231 				inventory(&level_objects, ALL_OBJECTS);
232 			} else {
233 				message(unknown_command, 0);
234 			}
235 			break;
236 		case '\023':
237 			if (wizard) {
238 				draw_magic_map();
239 			} else {
240 				message(unknown_command, 0);
241 			}
242 			break;
243 		case '\024':
244 			if (wizard) {
245 				show_traps();
246 			} else {
247 				message(unknown_command, 0);
248 			}
249 			break;
250 		case '\017':
251 			if (wizard) {
252 				show_objects();
253 			} else {
254 				message(unknown_command, 0);
255 			}
256 			break;
257 		case '\001':
258 			show_average_hp();
259 			break;
260 		case '\003':
261 			if (wizard) {
262 				c_object_for_wizard();
263 			} else {
264 				message(unknown_command, 0);
265 			}
266 			break;
267 		case '\015':
268 			if (wizard) {
269 				show_monsters();
270 			} else {
271 				message(unknown_command, 0);
272 			}
273 			break;
274 		case 'S':
275 			save_game();
276 			break;
277 		default:
278 			message(unknown_command, 0);
279 			break;
280 		}
281 	}
282 }
283