pl_2.c revision 1.8 1 /* $NetBSD: pl_2.c,v 1.8 2001/01/04 04:41:41 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.8 2001/01/04 04:41:41 jwise Exp $");
42 #endif
43 #endif /* not lint */
44
45 #include <signal.h>
46 #include "extern.h"
47 #include "player.h"
48
49 void play(void);
50
51 void
52 play(void)
53 {
54 struct ship *sp;
55
56 for (;;) {
57 switch (sgetch("~\b", (struct ship *)0, 0)) {
58 case 'm':
59 acceptmove();
60 break;
61 case 's':
62 acceptsignal();
63 break;
64 case 'g':
65 grapungrap();
66 break;
67 case 'u':
68 unfoulplayer();
69 break;
70 case 'v':
71 Msg("%s", version);
72 break;
73 case 'b':
74 acceptboard();
75 break;
76 case 'f':
77 acceptcombat();
78 break;
79 case 'l':
80 loadplayer();
81 break;
82 case 'c':
83 changesail();
84 break;
85 case 'r':
86 repair();
87 break;
88 case 'B':
89 Msg("'Hands to stations!'");
90 unboard(ms, ms, 1); /* cancel DBP's */
91 unboard(ms, ms, 0); /* cancel offense */
92 break;
93 case '\f':
94 centerview();
95 blockalarm();
96 draw_board();
97 draw_screen();
98 unblockalarm();
99 break;
100 case 'L':
101 mf->loadL = L_EMPTY;
102 mf->loadR = L_EMPTY;
103 mf->readyL = R_EMPTY;
104 mf->readyR = R_EMPTY;
105 Msg("Broadsides unloaded");
106 break;
107 case 'q':
108 Msg("Type 'Q' to quit");
109 break;
110 case 'Q':
111 leave(LEAVE_QUIT);
112 break;
113 case 'I':
114 foreachship(sp)
115 if (sp != ms)
116 eyeball(sp);
117 break;
118 case 'i':
119 if ((sp = closestenemy(ms, 0, 1)) == 0)
120 Msg("No more ships left.");
121 else
122 eyeball(sp);
123 break;
124 case 'C':
125 centerview();
126 blockalarm();
127 draw_view();
128 unblockalarm();
129 break;
130 case 'U':
131 upview();
132 blockalarm();
133 draw_view();
134 unblockalarm();
135 break;
136 case 'D':
137 case 'N':
138 downview();
139 blockalarm();
140 draw_view();
141 unblockalarm();
142 break;
143 case 'H':
144 leftview();
145 blockalarm();
146 draw_view();
147 unblockalarm();
148 break;
149 case 'J':
150 rightview();
151 blockalarm();
152 draw_view();
153 unblockalarm();
154 break;
155 case 'F':
156 lookout();
157 break;
158 case 'S':
159 dont_adjust = !dont_adjust;
160 blockalarm();
161 draw_turn();
162 unblockalarm();
163 break;
164 }
165 }
166 }
167