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