1 /* $NetBSD: play.c,v 1.10 2019/02/03 03:19:25 mrg 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.10 2019/02/03 03:19:25 mrg 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 60 static const char unknown_command[] = "unknown command"; 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 messagef(1, "%s", hit_message); 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 (void)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 messagef(0, "rogue-clone: Version III. (Tim Stoehr was here), tektronix!zeus!tims"); 219 break; 220 case 'Q': 221 quit(0); 222 __unreachable(); 223 case '0': 224 case '1': 225 case '2': 226 case '3': 227 case '4': 228 case '5': 229 case '6': 230 case '7': 231 case '8': 232 case '9': 233 move(rogue.row, rogue.col); 234 refresh(); 235 do { 236 if (count < 100) { 237 count = (10 * count) + (ch - '0'); 238 } 239 ch = rgetchar(); 240 } while (is_digit(ch)); 241 if (ch != CANCEL) { 242 goto CH; 243 } 244 break; 245 case ' ': 246 break; 247 case '\011': 248 if (wizard) { 249 inventory(&level_objects, ALL_OBJECTS); 250 } else { 251 messagef(0, "%s", unknown_command); 252 } 253 break; 254 case '\023': 255 if (wizard) { 256 draw_magic_map(); 257 } else { 258 messagef(0, "%s", unknown_command); 259 } 260 break; 261 case '\024': 262 if (wizard) { 263 show_traps(); 264 } else { 265 messagef(0, "%s", unknown_command); 266 } 267 break; 268 case '\017': 269 if (wizard) { 270 show_objects(); 271 } else { 272 messagef(0, "%s", unknown_command); 273 } 274 break; 275 case '\001': 276 show_average_hp(); 277 break; 278 case '\003': 279 if (wizard) { 280 c_object_for_wizard(); 281 } else { 282 messagef(0, "%s", unknown_command); 283 } 284 break; 285 case '\015': 286 if (wizard) { 287 show_monsters(); 288 } else { 289 messagef(0, "%s", unknown_command); 290 } 291 break; 292 case 'S': 293 save_game(); 294 break; 295 default: 296 messagef(0, "%s", unknown_command); 297 break; 298 } 299 } 300 } 301