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