xref: /original-bsd/games/sail/parties.c (revision 91043db2)
1 #ifndef lint
2 static	char *sccsid = "@(#)parties.c	1.1 83/03/17";
3 #endif
4 #include "externs.h"
5 
6 meleeing(from, to)
7 int from, to;
8 {
9     register int n;
10 
11     for (n = 0; n < 3; n++)
12 	{
13 	if (scene[game].ship[from].file -> OBP[n].turnsent && scene[game].ship[from].file -> OBP[n].toship == to)
14 	    return(1);
15 	}
16     return(0);
17 }
18 
19 Fouled(shipnum, offset)
20 int shipnum, offset;
21 {
22     register int n, Fouls = 0;
23     struct snag *ptr;
24 
25     ptr = offset == 342 ? scene[game].ship[shipnum].file -> fouls : scene[game].ship[shipnum].file -> grapples ;
26     for (n=0; n < 10; n++){
27 	if (ptr[n].turnfoul)
28 	    Fouls++;
29     }
30     return(Fouls);
31 }
32 
33 
34 Grapple(shipnum, toship, offset)
35 int shipnum, toship, offset;
36 {
37     int test = 0;
38     register int n, Fouls = 0;
39     struct snag *ptr;
40 
41     if (shipnum >= 100)
42 	{
43 	shipnum -= 100;
44 	test = 1;
45 	}
46     ptr = offset == 342 ? scene[game].ship[shipnum].file -> fouls : scene[game].ship[shipnum].file -> grapples ;
47     for (n=0; n < 10; n++)
48 	{
49 	if (ptr[n].turnfoul && ptr[n].toship == toship && (!test || (ptr[n].turnfoul < turn - 1 && (loadwith[shipnum] = GRAPE))))
50 	    Fouls++;
51 	}
52     return(Fouls);
53 }
54 
55 unboard(shipnum, toship, defense)
56 int shipnum, toship, defense;
57 {
58     register int n;
59     struct BP *ptr;
60 
61     ptr = defense ? scene[game].ship[shipnum].file -> DBP : scene[game].ship[shipnum].file -> OBP ;
62     for (n=0; n < 3; n++)
63 	if (ptr[n].turnsent && (ptr[n].toship == toship || defense || shipnum == toship))
64 	    Write(FILES + shipnum, 0, 30 + 18*defense + 6*n, 0);
65 }
66