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