pl_2.c revision 1.7 1 /* $NetBSD: pl_2.c,v 1.7 2001/01/04 03:51:24 jwise Exp $ */
2
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37 #ifndef lint
38 #if 0
39 static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93";
40 #else
41 __RCSID("$NetBSD: pl_2.c,v 1.7 2001/01/04 03:51:24 jwise Exp $");
42 #endif
43 #endif /* not lint */
44
45 #include <signal.h>
46 #include "player.h"
47
48 void play(void);
49
50 void
51 play(void)
52 {
53 struct ship *sp;
54
55 for (;;) {
56 switch (sgetch("~\b", (struct ship *)0, 0)) {
57 case 'm':
58 acceptmove();
59 break;
60 case 's':
61 acceptsignal();
62 break;
63 case 'g':
64 grapungrap();
65 break;
66 case 'u':
67 unfoulplayer();
68 break;
69 case 'v':
70 Msg("%s", version);
71 break;
72 case 'b':
73 acceptboard();
74 break;
75 case 'f':
76 acceptcombat();
77 break;
78 case 'l':
79 loadplayer();
80 break;
81 case 'c':
82 changesail();
83 break;
84 case 'r':
85 repair();
86 break;
87 case 'B':
88 Msg("'Hands to stations!'");
89 unboard(ms, ms, 1); /* cancel DBP's */
90 unboard(ms, ms, 0); /* cancel offense */
91 break;
92 case '\f':
93 centerview();
94 blockalarm();
95 draw_board();
96 draw_screen();
97 unblockalarm();
98 break;
99 case 'L':
100 mf->loadL = L_EMPTY;
101 mf->loadR = L_EMPTY;
102 mf->readyL = R_EMPTY;
103 mf->readyR = R_EMPTY;
104 Msg("Broadsides unloaded");
105 break;
106 case 'q':
107 Msg("Type 'Q' to quit");
108 break;
109 case 'Q':
110 leave(LEAVE_QUIT);
111 break;
112 case 'I':
113 foreachship(sp)
114 if (sp != ms)
115 eyeball(sp);
116 break;
117 case 'i':
118 if ((sp = closestenemy(ms, 0, 1)) == 0)
119 Msg("No more ships left.");
120 else
121 eyeball(sp);
122 break;
123 case 'C':
124 centerview();
125 blockalarm();
126 draw_view();
127 unblockalarm();
128 break;
129 case 'U':
130 upview();
131 blockalarm();
132 draw_view();
133 unblockalarm();
134 break;
135 case 'D':
136 case 'N':
137 downview();
138 blockalarm();
139 draw_view();
140 unblockalarm();
141 break;
142 case 'H':
143 leftview();
144 blockalarm();
145 draw_view();
146 unblockalarm();
147 break;
148 case 'J':
149 rightview();
150 blockalarm();
151 draw_view();
152 unblockalarm();
153 break;
154 case 'F':
155 lookout();
156 break;
157 case 'S':
158 dont_adjust = !dont_adjust;
159 blockalarm();
160 draw_turn();
161 unblockalarm();
162 break;
163 }
164 }
165 }
166