date and time created 88/06/01 18:39:47 by bostic
[unix-history] / usr / src / games / sail / game.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 1983 Regents of the University of California.
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.
11 */
12
13#ifndef lint
14static char sccsid[] = "@(#)game.c 5.2 (Berkeley) %G%";
15#endif /* not lint */
16
17#include "externs.h"
18
19maxturns(ship, af)
20register struct ship *ship;
21char *af;
22{
23 register int turns;
24
25 turns = ship->specs->ta;
26 if (*af = (ship->file->drift > 1 && turns)) {
27 turns--;
28 if (ship->file->FS == 1)
29 turns = 0;
30 }
31 return turns;
32}
33
34maxmove(ship, dir, fs)
35register struct ship *ship;
36int dir, fs;
37{
38 register int riggone = 0, Move, flank = 0;
39
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) {
50 flank = 1;
51 Move = ship->specs->fs;
52 }
53 if (dir == winddir)
54 Move -= 1 + WET[windspeed][ship->specs->class-1].B;
55 else if (dir == winddir + 2 || dir == winddir - 2 || dir == winddir - 6 || dir == winddir + 6)
56 Move -= 1 + WET[windspeed][ship->specs->class-1].C;
57 else if (dir == winddir + 3 || dir == winddir - 3 || dir == winddir - 5 || dir == winddir + 5)
58 Move = (flank ? 2 : 1) - WET[windspeed][ship->specs->class-1].D;
59 else if (dir == winddir + 4 || dir == winddir - 4)
60 Move = 0;
61 else
62 Move -= WET[windspeed][ship->specs->class-1].A;
63 Move -= riggone;
64 Move = Move < 0 ? 0 : Move;
65 return(Move);
66}