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