date and time created 88/06/01 18:39:47 by bostic
[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 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
b5f0675e
EW
11 */
12
cd818f56 13#ifndef lint
c0ca48ec
KB
14static char sccsid[] = "@(#)game.c 5.2 (Berkeley) %G%";
15#endif /* not lint */
cd818f56 16
7fc06086 17#include "externs.h"
cd818f56 18
6c17b19a 19maxturns(ship, af)
b3a57661 20register struct ship *ship;
6c17b19a 21char *af;
cd818f56 22{
7fc06086 23 register int turns;
cd818f56 24
b3a57661 25 turns = ship->specs->ta;
6c17b19a 26 if (*af = (ship->file->drift > 1 && turns)) {
cd818f56 27 turns--;
b3a57661 28 if (ship->file->FS == 1)
cd818f56 29 turns = 0;
cd818f56 30 }
b3a57661 31 return turns;
cd818f56
CL
32}
33
b3a57661
EW
34maxmove(ship, dir, fs)
35register struct ship *ship;
36int dir, fs;
cd818f56 37{
b3a57661 38 register int riggone = 0, Move, flank = 0;
cd818f56 39
b3a57661
EW
40 Move = ship->specs->bs;
41 if (!ship->specs->rig1)
42 riggone++;
43 if (!ship->specs->rig2)
44 riggone++;
45 if (!ship->specs->rig3)
46 riggone++;
47 if (!ship->specs->rig4)
48 riggone++;
49 if ((ship->file->FS || fs) && fs != -1) {
cd818f56 50 flank = 1;
b3a57661 51 Move = ship->specs->fs;
cd818f56
CL
52 }
53 if (dir == winddir)
b3a57661 54 Move -= 1 + WET[windspeed][ship->specs->class-1].B;
cd818f56 55 else if (dir == winddir + 2 || dir == winddir - 2 || dir == winddir - 6 || dir == winddir + 6)
b3a57661 56 Move -= 1 + WET[windspeed][ship->specs->class-1].C;
cd818f56 57 else if (dir == winddir + 3 || dir == winddir - 3 || dir == winddir - 5 || dir == winddir + 5)
b3a57661 58 Move = (flank ? 2 : 1) - WET[windspeed][ship->specs->class-1].D;
cd818f56
CL
59 else if (dir == winddir + 4 || dir == winddir - 4)
60 Move = 0;
61 else
b3a57661 62 Move -= WET[windspeed][ship->specs->class-1].A;
cd818f56
CL
63 Move -= riggone;
64 Move = Move < 0 ? 0 : Move;
65 return(Move);
66}