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