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