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