pl_2.c revision 1.4
1/*	$OpenBSD: pl_2.c,v 1.4 2009/10/27 23:59:27 deraadt 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. Neither the name of the University nor the names of its contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include "player.h"
34
35void
36play()
37{
38	struct ship *sp;
39
40	for (;;) {
41		switch (sgetch("~\b", (struct ship *)0, 0)) {
42		case 'm':
43			acceptmove();
44			break;
45		case 's':
46			acceptsignal();
47			break;
48		case 'g':
49			grapungrap();
50			break;
51		case 'u':
52			unfoulplayer();
53			break;
54		case 'v':
55			Msg("%s", version);
56			break;
57		case 'b':
58			acceptboard();
59			break;
60		case 'f':
61			acceptcombat();
62			break;
63		case 'l':
64			loadplayer();
65			break;
66		case 'c':
67			changesail();
68			break;
69		case 'r':
70			repair();
71			break;
72		case 'B':
73			Msg("'Hands to stations!'");
74			unboard(ms, ms, 1);	/* cancel DBP's */
75			unboard(ms, ms, 0);	/* cancel offense */
76			break;
77		case '\f':
78			centerview();
79			blockalarm();
80			draw_board();
81			draw_screen();
82			unblockalarm();
83			break;
84		case 'L':
85			mf->loadL = L_EMPTY;
86			mf->loadR = L_EMPTY;
87			mf->readyL = R_EMPTY;
88			mf->readyR = R_EMPTY;
89			Msg("Broadsides unloaded");
90			break;
91		case 'q':
92			Msg("Type 'Q' to quit");
93			break;
94		case 'Q':
95			leave(LEAVE_QUIT);
96			break;
97		case 'I':
98			foreachship(sp)
99				if (sp != ms)
100					eyeball(sp);
101			break;
102		case 'i':
103			if ((sp = closestenemy(ms, 0, 1)) == 0)
104				Msg("No more ships left.");
105			else
106				eyeball(sp);
107			break;
108		case 'C':
109			centerview();
110			blockalarm();
111			draw_view();
112			unblockalarm();
113			break;
114		case 'U':
115			upview();
116			blockalarm();
117			draw_view();
118			unblockalarm();
119			break;
120		case 'D':
121		case 'N':
122			downview();
123			blockalarm();
124			draw_view();
125			unblockalarm();
126			break;
127		case 'H':
128			leftview();
129			blockalarm();
130			draw_view();
131			unblockalarm();
132			break;
133		case 'J':
134			rightview();
135			blockalarm();
136			draw_view();
137			unblockalarm();
138			break;
139		case 'F':
140			lookout();
141			break;
142		case 'S':
143			dont_adjust = !dont_adjust;
144			blockalarm();
145			draw_turn();
146			unblockalarm();
147			break;
148		}
149	}
150}
151