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