Changed ERR to CURSES_ERR.
[unix-history] / usr / src / games / sail / game.c
CommitLineData
b5f0675e 1/*
1e008c14 2 * Copyright (c) 1983 Regents of the University of California.
c0ca48ec
KB
3 * All rights reserved.
4 *
b2e7427f 5 * %sccs.include.redist.c%
b5f0675e
EW
6 */
7
cd818f56 8#ifndef lint
b2e7427f 9static char sccsid[] = "@(#)game.c 5.4 (Berkeley) %G%";
c0ca48ec 10#endif /* not lint */
cd818f56 11
7fc06086 12#include "externs.h"
cd818f56 13
6c17b19a 14maxturns(ship, af)
b3a57661 15register struct ship *ship;
6c17b19a 16char *af;
cd818f56 17{
7fc06086 18 register int turns;
cd818f56 19
b3a57661 20 turns = ship->specs->ta;
6c17b19a 21 if (*af = (ship->file->drift > 1 && turns)) {
cd818f56 22 turns--;
b3a57661 23 if (ship->file->FS == 1)
cd818f56 24 turns = 0;
cd818f56 25 }
b3a57661 26 return turns;
cd818f56
CL
27}
28
b3a57661
EW
29maxmove(ship, dir, fs)
30register struct ship *ship;
31int dir, fs;
cd818f56 32{
b3a57661 33 register int riggone = 0, Move, flank = 0;
cd818f56 34
b3a57661
EW
35 Move = ship->specs->bs;
36 if (!ship->specs->rig1)
37 riggone++;
38 if (!ship->specs->rig2)
39 riggone++;
40 if (!ship->specs->rig3)
41 riggone++;
42 if (!ship->specs->rig4)
43 riggone++;
44 if ((ship->file->FS || fs) && fs != -1) {
cd818f56 45 flank = 1;
b3a57661 46 Move = ship->specs->fs;
cd818f56
CL
47 }
48 if (dir == winddir)
b3a57661 49 Move -= 1 + WET[windspeed][ship->specs->class-1].B;
cd818f56 50 else if (dir == winddir + 2 || dir == winddir - 2 || dir == winddir - 6 || dir == winddir + 6)
b3a57661 51 Move -= 1 + WET[windspeed][ship->specs->class-1].C;
cd818f56 52 else if (dir == winddir + 3 || dir == winddir - 3 || dir == winddir - 5 || dir == winddir + 5)
b3a57661 53 Move = (flank ? 2 : 1) - WET[windspeed][ship->specs->class-1].D;
cd818f56
CL
54 else if (dir == winddir + 4 || dir == winddir - 4)
55 Move = 0;
56 else
b3a57661 57 Move -= WET[windspeed][ship->specs->class-1].A;
cd818f56
CL
58 Move -= riggone;
59 Move = Move < 0 ? 0 : Move;
60 return(Move);
61}