132689Sbostic /*
2*60842Sbostic * Copyright (c) 1988, 1993
3*60842Sbostic * The Regents of the University of California. All rights reserved.
436704Sbostic *
536704Sbostic * This code is derived from software contributed to Berkeley by
636704Sbostic * Timothy C. Stoehr.
736704Sbostic *
842601Sbostic * %sccs.include.redist.c%
936704Sbostic */
1036704Sbostic
1136704Sbostic #ifndef lint
12*60842Sbostic static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 05/31/93";
1336704Sbostic #endif /* not lint */
1436704Sbostic
1536704Sbostic /*
1632689Sbostic * play.c
1732689Sbostic *
1832689Sbostic * This source herein may be modified and/or distributed by anybody who
1932689Sbostic * so desires, with the following restrictions:
2032689Sbostic * 1.) No portion of this notice shall be removed.
2132689Sbostic * 2.) Credit shall not be taken for the creation of this source.
2232689Sbostic * 3.) This code is not to be traded, sold, or used for personal
2332689Sbostic * gain or profit.
2432689Sbostic *
2532689Sbostic */
2632689Sbostic
2732689Sbostic #include "rogue.h"
2832689Sbostic
2932689Sbostic boolean interrupted = 0;
3032689Sbostic char *unknown_command = "unknown command";
3132689Sbostic
3232689Sbostic extern short party_room, bear_trap;
3332689Sbostic extern char hit_message[];
3432689Sbostic extern boolean wizard, trap_door;
3532689Sbostic
play_level()3632689Sbostic play_level()
3732689Sbostic {
3832689Sbostic short ch;
3932689Sbostic int count;
4032689Sbostic
4132689Sbostic for (;;) {
4232689Sbostic interrupted = 0;
4332689Sbostic if (hit_message[0]) {
4432689Sbostic message(hit_message, 1);
4532689Sbostic hit_message[0] = 0;
4632689Sbostic }
4732689Sbostic if (trap_door) {
4832689Sbostic trap_door = 0;
4932689Sbostic return;
5032689Sbostic }
5132689Sbostic move(rogue.row, rogue.col);
5232689Sbostic refresh();
5332689Sbostic
5432689Sbostic ch = rgetchar();
5532689Sbostic CMCH:
5632689Sbostic check_message();
5732689Sbostic count = 0;
5832689Sbostic CH:
5932689Sbostic switch(ch) {
6032689Sbostic case '.':
6132689Sbostic rest((count > 0) ? count : 1);
6232689Sbostic break;
6332689Sbostic case 's':
6432689Sbostic search(((count > 0) ? count : 1), 0);
6532689Sbostic break;
6632689Sbostic case 'i':
6732689Sbostic inventory(&rogue.pack, ALL_OBJECTS);
6832689Sbostic break;
6932689Sbostic case 'f':
7032689Sbostic fight(0);
7132689Sbostic break;
7232689Sbostic case 'F':
7332689Sbostic fight(1);
7432689Sbostic break;
7532689Sbostic case 'h':
7632689Sbostic case 'j':
7732689Sbostic case 'k':
7832689Sbostic case 'l':
7932689Sbostic case 'y':
8032689Sbostic case 'u':
8132689Sbostic case 'n':
8232689Sbostic case 'b':
8332689Sbostic (void) one_move_rogue(ch, 1);
8432689Sbostic break;
8532689Sbostic case 'H':
8632689Sbostic case 'J':
8732689Sbostic case 'K':
8832689Sbostic case 'L':
8932689Sbostic case 'B':
9032689Sbostic case 'Y':
9132689Sbostic case 'U':
9232689Sbostic case 'N':
9332689Sbostic case '\010':
9432689Sbostic case '\012':
9532689Sbostic case '\013':
9632689Sbostic case '\014':
9732689Sbostic case '\031':
9832689Sbostic case '\025':
9932689Sbostic case '\016':
10032689Sbostic case '\002':
10132689Sbostic multiple_move_rogue(ch);
10232689Sbostic break;
10332689Sbostic case 'e':
10432689Sbostic eat();
10532689Sbostic break;
10632689Sbostic case 'q':
10732689Sbostic quaff();
10832689Sbostic break;
10932689Sbostic case 'r':
11032689Sbostic read_scroll();
11132689Sbostic break;
11232689Sbostic case 'm':
11332689Sbostic move_onto();
11432689Sbostic break;
11532689Sbostic case ',':
11632689Sbostic kick_into_pack();
11732689Sbostic break;
11832689Sbostic case 'd':
11932689Sbostic drop();
12032689Sbostic break;
12132689Sbostic case 'P':
12232689Sbostic put_on_ring();
12332689Sbostic break;
12432689Sbostic case 'R':
12532689Sbostic remove_ring();
12632689Sbostic break;
12732689Sbostic case '\020':
12832689Sbostic do {
12932689Sbostic remessage(count++);
13032689Sbostic ch = rgetchar();
13132689Sbostic } while (ch == '\020');
13232689Sbostic goto CMCH;
13332689Sbostic break;
13432689Sbostic case '\027':
13532689Sbostic wizardize();
13632689Sbostic break;
13732689Sbostic case '>':
13832689Sbostic if (drop_check()) {
13932689Sbostic return;
14032689Sbostic }
14132689Sbostic break;
14232689Sbostic case '<':
14332689Sbostic if (check_up()) {
14432689Sbostic return;
14532689Sbostic }
14632689Sbostic break;
14732689Sbostic case ')':
14832689Sbostic case ']':
14932689Sbostic inv_armor_weapon(ch == ')');
15032689Sbostic break;
15132689Sbostic case '=':
15232689Sbostic inv_rings();
15332689Sbostic break;
15432689Sbostic case '^':
15532689Sbostic id_trap();
15632689Sbostic break;
15732689Sbostic case '/':
15832689Sbostic id_type();
15932689Sbostic break;
16032689Sbostic case '?':
16132689Sbostic id_com();
16232689Sbostic break;
16332689Sbostic case '!':
16432689Sbostic do_shell();
16532689Sbostic break;
16632689Sbostic case 'o':
16732689Sbostic edit_opts();
16832689Sbostic break;
16932689Sbostic case 'I':
17032689Sbostic single_inv(0);
17132689Sbostic break;
17232689Sbostic case 'T':
17332689Sbostic take_off();
17432689Sbostic break;
17532689Sbostic case 'W':
17632689Sbostic wear();
17732689Sbostic break;
17832689Sbostic case 'w':
17932689Sbostic wield();
18032689Sbostic break;
18132689Sbostic case 'c':
18232689Sbostic call_it();
18332689Sbostic break;
18432689Sbostic case 'z':
18532689Sbostic zapp();
18632689Sbostic break;
18732689Sbostic case 't':
18832689Sbostic throw();
18932689Sbostic break;
19032689Sbostic case 'v':
19132689Sbostic message("rogue-clone: Version III. (Tim Stoehr was here), tektronix!zeus!tims", 0);
19232689Sbostic break;
19332689Sbostic case 'Q':
19432689Sbostic quit(0);
19532689Sbostic case '0':
19632689Sbostic case '1':
19732689Sbostic case '2':
19832689Sbostic case '3':
19932689Sbostic case '4':
20032689Sbostic case '5':
20132689Sbostic case '6':
20232689Sbostic case '7':
20332689Sbostic case '8':
20432689Sbostic case '9':
20532689Sbostic move(rogue.row, rogue.col);
20632689Sbostic refresh();
20732689Sbostic do {
20832689Sbostic if (count < 100) {
20932689Sbostic count = (10 * count) + (ch - '0');
21032689Sbostic }
21132689Sbostic ch = rgetchar();
21232689Sbostic } while (is_digit(ch));
21332689Sbostic if (ch != CANCEL) {
21432689Sbostic goto CH;
21532689Sbostic }
21632689Sbostic break;
21732689Sbostic case ' ':
21832689Sbostic break;
21932689Sbostic case '\011':
22032689Sbostic if (wizard) {
22132689Sbostic inventory(&level_objects, ALL_OBJECTS);
22232689Sbostic } else {
22332689Sbostic message(unknown_command, 0);
22432689Sbostic }
22532689Sbostic break;
22632689Sbostic case '\023':
22732689Sbostic if (wizard) {
22832689Sbostic draw_magic_map();
22932689Sbostic } else {
23032689Sbostic message(unknown_command, 0);
23132689Sbostic }
23232689Sbostic break;
23332689Sbostic case '\024':
23432689Sbostic if (wizard) {
23532689Sbostic show_traps();
23632689Sbostic } else {
23732689Sbostic message(unknown_command, 0);
23832689Sbostic }
23932689Sbostic break;
24032689Sbostic case '\017':
24132689Sbostic if (wizard) {
24232689Sbostic show_objects();
24332689Sbostic } else {
24432689Sbostic message(unknown_command, 0);
24532689Sbostic }
24632689Sbostic break;
24732689Sbostic case '\001':
24832689Sbostic show_average_hp();
24932689Sbostic break;
25032689Sbostic case '\003':
25132689Sbostic if (wizard) {
25232689Sbostic c_object_for_wizard();
25332689Sbostic } else {
25432689Sbostic message(unknown_command, 0);
25532689Sbostic }
25632689Sbostic break;
25732689Sbostic case '\015':
25832689Sbostic if (wizard) {
25932689Sbostic show_monsters();
26032689Sbostic } else {
26132689Sbostic message(unknown_command, 0);
26232689Sbostic }
26332689Sbostic break;
26432689Sbostic case 'S':
26532689Sbostic save_game();
26632689Sbostic break;
26732689Sbostic default:
26832689Sbostic message(unknown_command, 0);
26932689Sbostic break;
27032689Sbostic }
27132689Sbostic }
27232689Sbostic }
273