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