Commit | Line | Data |
---|---|---|
bb0cfa24 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. | |
bb0cfa24 DF |
11 | */ |
12 | ||
4e84ca61 | 13 | #ifndef lint |
e9fb6bea KB |
14 | static char sccsid[] = "@(#)win.c 5.2 (Berkeley) %G%"; |
15 | #endif /* not lint */ | |
4e84ca61 KM |
16 | |
17 | # include "trek.h" | |
18 | # include "getpar.h" | |
19 | ||
20 | /* | |
21 | ** Signal game won | |
22 | ** | |
23 | ** This routine prints out the win message, arranges to print out | |
24 | ** your score, tells you if you have a promotion coming to you, | |
25 | ** cleans up the current input line, and arranges to have you | |
26 | ** asked whether or not you want another game (via the reset() | |
27 | ** call). | |
28 | ** | |
29 | ** Pretty straightforward, although the promotion algorithm is | |
30 | ** pretty off the wall. | |
31 | */ | |
32 | ||
33 | win() | |
34 | { | |
35 | long s; | |
36 | extern long score(); | |
37 | extern struct cvntab Skitab[]; | |
38 | register struct cvntab *p; | |
39 | ||
40 | sleep(1); | |
41 | printf("\nCongratulations, you have saved the Federation\n"); | |
42 | Move.endgame = 1; | |
43 | ||
44 | /* print and return the score */ | |
45 | s = score(); | |
46 | ||
47 | /* decide if she gets a promotion */ | |
48 | if (Game.helps == 0 && Game.killb == 0 && Game.killinhab == 0 && 5 * Game.kills + Game.deaths < 100 && | |
49 | s >= 1000 && Ship.ship == ENTERPRISE) | |
50 | { | |
51 | printf("In fact, you are promoted one step in rank,\n"); | |
52 | if (Game.skill >= 6) | |
53 | printf("to the exalted rank of Commodore Emeritus\n"); | |
54 | else | |
55 | { | |
56 | p = &Skitab[Game.skill - 1]; | |
57 | printf("from %s%s ", p->abrev, p->full); | |
58 | p++; | |
59 | printf("to %s%s\n", p->abrev, p->full); | |
60 | } | |
61 | } | |
62 | ||
63 | /* clean out input, and request new game */ | |
64 | skiptonl(0); | |
65 | reset(); | |
66 | } |