removed support for -r, -h, and rmail
[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 *
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.
b6f0a7e4
DF
11 */
12
6f84b93e 13#ifndef lint
e9fb6bea
KB
14static char sccsid[] = "@(#)checkcond.c 5.2 (Berkeley) %G%";
15#endif /* not lint */
6f84b93e
KM
16
17# include "trek.h"
18
19/*
20** Check for Condition After a Move
21**
22** Various ship conditions are checked. First we check
23** to see if we have already lost the game, due to running
24** out of life support reserves, running out of energy,
25** or running out of crew members. The check for running
26** out of time is in events().
27**
28** If we are in automatic override mode (Etc.nkling < 0), we
29** don't want to do anything else, lest we call autover
30** recursively.
31**
32** In the normal case, if there is a supernova, we call
33** autover() to help us escape. If after calling autover()
34** we are still in the grips of a supernova, we get burnt
35** up.
36**
37** If there are no Klingons in this quadrant, we nullify any
38** distress calls which might exist.
39**
40** We then set the condition code, based on the energy level
41** and battle conditions.
42*/
43
44checkcond()
45{
46 register int i, j;
47
48 /* see if we are still alive and well */
49 if (Ship.reserves < 0.0)
50 lose(L_NOLIFE);
51 if (Ship.energy <= 0)
52 lose(L_NOENGY);
53 if (Ship.crew <= 0)
54 lose(L_NOCREW);
55 /* if in auto override mode, ignore the rest */
56 if (Etc.nkling < 0)
57 return;
58 /* call in automatic override if appropriate */
59 if (Quad[Ship.quadx][Ship.quady].stars < 0)
60 autover();
61 if (Quad[Ship.quadx][Ship.quady].stars < 0)
62 lose(L_SNOVA);
63 /* nullify distress call if appropriate */
64 if (Etc.nkling <= 0)
65 killd(Ship.quadx, Ship.quady, 1);
66
67 /* set condition code */
68 if (Ship.cond == DOCKED)
69 return;
70
71 if (Etc.nkling > 0)
72 {
73 Ship.cond = RED;
74 return;
75 }
76 if (Ship.energy < Param.energylow)
77 {
78 Ship.cond = YELLOW;
79 return;
80 }
81 Ship.cond = GREEN;
82 return;
83}