xref: /original-bsd/games/sail/pl_2.c (revision 42f60e33)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)pl_2.c	8.1 (Berkeley) 05/31/93";
10 #endif /* not lint */
11 
12 #include "player.h"
13 
14 play()
15 {
16 	register struct ship *sp;
17 
18 	for (;;) {
19 		switch (sgetch("~\b", (struct ship *)0, 0)) {
20 		case 'm':
21 			acceptmove();
22 			break;
23 		case 's':
24 			acceptsignal();
25 			break;
26 		case 'g':
27 			grapungrap();
28 			break;
29 		case 'u':
30 			unfoulplayer();
31 			break;
32 		case 'v':
33 			Signal("%s", (struct ship *)0, version);
34 			break;
35 		case 'b':
36 			acceptboard();
37 			break;
38 		case 'f':
39 			acceptcombat();
40 			break;
41 		case 'l':
42 			loadplayer();
43 			break;
44 		case 'c':
45 			changesail();
46 			break;
47 		case 'r':
48 			repair();
49 			break;
50 		case 'B':
51 			Signal("'Hands to stations!'", (struct ship *)0);
52 			unboard(ms, ms, 1);	/* cancel DBP's */
53 			unboard(ms, ms, 0);	/* cancel offense */
54 			break;
55 		case '\f':
56 			centerview();
57 			blockalarm();
58 			draw_board();
59 			draw_screen();
60 			unblockalarm();
61 			break;
62 		case 'L':
63 			mf->loadL = L_EMPTY;
64 			mf->loadR = L_EMPTY;
65 			mf->readyL = R_EMPTY;
66 			mf->readyR = R_EMPTY;
67 			Signal("Broadsides unloaded", (struct ship *)0);
68 			break;
69 		case 'q':
70 			Signal("Type 'Q' to quit", (struct ship *)0);
71 			break;
72 		case 'Q':
73 			leave(LEAVE_QUIT);
74 			break;
75 		case 'I':
76 			foreachship(sp)
77 				if (sp != ms)
78 					eyeball(sp);
79 			break;
80 		case 'i':
81 			if ((sp = closestenemy(ms, 0, 1)) == 0)
82 				Signal("No more ships left.");
83 			else
84 				eyeball(sp);
85 			break;
86 		case 'C':
87 			centerview();
88 			blockalarm();
89 			draw_view();
90 			unblockalarm();
91 			break;
92 		case 'U':
93 			upview();
94 			blockalarm();
95 			draw_view();
96 			unblockalarm();
97 			break;
98 		case 'D':
99 		case 'N':
100 			downview();
101 			blockalarm();
102 			draw_view();
103 			unblockalarm();
104 			break;
105 		case 'H':
106 			leftview();
107 			blockalarm();
108 			draw_view();
109 			unblockalarm();
110 			break;
111 		case 'J':
112 			rightview();
113 			blockalarm();
114 			draw_view();
115 			unblockalarm();
116 			break;
117 		case 'F':
118 			lookout();
119 			break;
120 		case 'S':
121 			dont_adjust = !dont_adjust;
122 			blockalarm();
123 			draw_turn();
124 			unblockalarm();
125 			break;
126 		}
127 	}
128 }
129