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