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