| 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.2 2003/06/17 04:25:25 dillon 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 | 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 | } |