BSD 4_3_Tahoe release
[unix-history] / usr / src / games / trek / win.c
CommitLineData
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
d99e6414
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
bb0cfa24
DF
16 */
17
4e84ca61 18#ifndef lint
ca67e7b4 19static char sccsid[] = "@(#)win.c 5.3 (Berkeley) 6/18/88";
e9fb6bea 20#endif /* not lint */
4e84ca61
KM
21
22# include "trek.h"
23# include "getpar.h"
24
25/*
26** Signal game won
27**
28** This routine prints out the win message, arranges to print out
29** your score, tells you if you have a promotion coming to you,
30** cleans up the current input line, and arranges to have you
31** asked whether or not you want another game (via the reset()
32** call).
33**
34** Pretty straightforward, although the promotion algorithm is
35** pretty off the wall.
36*/
37
38win()
39{
40 long s;
41 extern long score();
42 extern struct cvntab Skitab[];
43 register struct cvntab *p;
44
45 sleep(1);
46 printf("\nCongratulations, you have saved the Federation\n");
47 Move.endgame = 1;
48
49 /* print and return the score */
50 s = score();
51
52 /* decide if she gets a promotion */
53 if (Game.helps == 0 && Game.killb == 0 && Game.killinhab == 0 && 5 * Game.kills + Game.deaths < 100 &&
54 s >= 1000 && Ship.ship == ENTERPRISE)
55 {
56 printf("In fact, you are promoted one step in rank,\n");
57 if (Game.skill >= 6)
58 printf("to the exalted rank of Commodore Emeritus\n");
59 else
60 {
61 p = &Skitab[Game.skill - 1];
62 printf("from %s%s ", p->abrev, p->full);
63 p++;
64 printf("to %s%s\n", p->abrev, p->full);
65 }
66 }
67
68 /* clean out input, and request new game */
69 skiptonl(0);
70 reset();
71}