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