BSD 4_3_Reno release
[unix-history] / usr / src / games / trek / checkcond.c
CommitLineData
b6f0a7e4
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
e9fb6bea
KB
3 * All rights reserved.
4 *
1c15e888
C
5 * Redistribution and use in source and binary forms are permitted provided
6 * that: (1) source distributions retain this entire copyright notice and
7 * comment, and (2) distributions including binaries display the following
8 * acknowledgement: ``This product includes software developed by the
9 * University of California, Berkeley and its contributors'' in the
10 * documentation or other materials provided with the distribution and in
11 * all advertising materials mentioning features or use of this software.
12 * Neither the name of the University nor the names of its contributors may
13 * be used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
b6f0a7e4
DF
18 */
19
6f84b93e 20#ifndef lint
1c15e888 21static char sccsid[] = "@(#)checkcond.c 5.4 (Berkeley) 6/1/90";
e9fb6bea 22#endif /* not lint */
6f84b93e
KM
23
24# include "trek.h"
25
26/*
27** Check for Condition After a Move
28**
29** Various ship conditions are checked. First we check
30** to see if we have already lost the game, due to running
31** out of life support reserves, running out of energy,
32** or running out of crew members. The check for running
33** out of time is in events().
34**
35** If we are in automatic override mode (Etc.nkling < 0), we
36** don't want to do anything else, lest we call autover
37** recursively.
38**
39** In the normal case, if there is a supernova, we call
40** autover() to help us escape. If after calling autover()
41** we are still in the grips of a supernova, we get burnt
42** up.
43**
44** If there are no Klingons in this quadrant, we nullify any
45** distress calls which might exist.
46**
47** We then set the condition code, based on the energy level
48** and battle conditions.
49*/
50
51checkcond()
52{
53 register int i, j;
54
55 /* see if we are still alive and well */
56 if (Ship.reserves < 0.0)
57 lose(L_NOLIFE);
58 if (Ship.energy <= 0)
59 lose(L_NOENGY);
60 if (Ship.crew <= 0)
61 lose(L_NOCREW);
62 /* if in auto override mode, ignore the rest */
63 if (Etc.nkling < 0)
64 return;
65 /* call in automatic override if appropriate */
66 if (Quad[Ship.quadx][Ship.quady].stars < 0)
67 autover();
68 if (Quad[Ship.quadx][Ship.quady].stars < 0)
69 lose(L_SNOVA);
70 /* nullify distress call if appropriate */
71 if (Etc.nkling <= 0)
72 killd(Ship.quadx, Ship.quady, 1);
73
74 /* set condition code */
75 if (Ship.cond == DOCKED)
76 return;
77
78 if (Etc.nkling > 0)
79 {
80 Ship.cond = RED;
81 return;
82 }
83 if (Ship.energy < Param.energylow)
84 {
85 Ship.cond = YELLOW;
86 return;
87 }
88 Ship.cond = GREEN;
89 return;
90}