pl_2.c revision 1.3
1/* $OpenBSD: pl_2.c,v 1.3 2003/06/03 03:01:41 millert 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#ifndef lint 34#if 0 35static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93"; 36#else 37static char rcsid[] = "$OpenBSD: pl_2.c,v 1.3 2003/06/03 03:01:41 millert Exp $"; 38#endif 39#endif /* not lint */ 40 41#include "player.h" 42 43void 44play() 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 Msg("%s", 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 Msg("'Hands to stations!'"); 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 Msg("Broadsides unloaded"); 98 break; 99 case 'q': 100 Msg("Type 'Q' to quit"); 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 Msg("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