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