modern syntax for inits. When ANSI cpp comes will need more work.
[unix-history] / usr / src / games / trek / score.c
CommitLineData
bb0cfa24
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
86f0906d 7#ifndef lint
bb0cfa24 8static char sccsid[] = "@(#)score.c 5.1 (Berkeley) %G%";
86f0906d
KM
9#endif not lint
10
11# include "trek.h"
12# include "getpar.h"
13
14/*
15** PRINT OUT THE CURRENT SCORE
16*/
17
18long score()
19{
20 register int u;
21 register int t;
22 long s;
23 double r;
24 extern struct cvntab Skitab[];
25
26 printf("\n*** Your score:\n");
27 s = t = Param.klingpwr / 4 * (u = Game.killk);
28 if (t != 0)
29 printf("%d Klingons killed\t\t\t%6d\n", u, t);
30 r = Now.date - Param.date;
31 if (r < 1.0)
32 r = 1.0;
33 r = Game.killk / r;
35b95499 34 s += (t = 400 * r);
86f0906d
KM
35 if (t != 0)
36 printf("Kill rate %.2f Klingons/stardate \t%6d\n", r, t);
37 r = Now.klings;
35b95499
KL
38 r /= Game.killk + 1;
39 s += (t = -400 * r);
86f0906d
KM
40 if (t != 0)
41 printf("Penalty for %d klingons remaining\t%6d\n", Now.klings, t);
42 if (Move.endgame > 0)
43 {
35b95499 44 s += (t = 100 * (u = Game.skill));
86f0906d
KM
45 printf("Bonus for winning a %s%s game\t\t%6d\n", Skitab[u - 1].abrev, Skitab[u - 1].full, t);
46 }
47 if (Game.killed)
48 {
35b95499 49 s -= 500;
86f0906d
KM
50 printf("Penalty for getting killed\t\t -500\n");
51 }
35b95499 52 s += (t = -100 * (u = Game.killb));
86f0906d
KM
53 if (t != 0)
54 printf("%d starbases killed\t\t\t%6d\n", u, t);
35b95499 55 s += (t = -100 * (u = Game.helps));
86f0906d
KM
56 if (t != 0)
57 printf("%d calls for help\t\t\t%6d\n", u, t);
35b95499 58 s += (t = -5 * (u = Game.kills));
86f0906d
KM
59 if (t != 0)
60 printf("%d stars destroyed\t\t\t%6d\n", u, t);
35b95499 61 s += (t = -150 * (u = Game.killinhab));
86f0906d
KM
62 if (t != 0)
63 printf("%d inhabited starsystems destroyed\t%6d\n", u, t);
64 if (Ship.ship != ENTERPRISE)
65 {
35b95499 66 s -= 200;
86f0906d
KM
67 printf("penalty for abandoning ship\t\t -200\n");
68 }
35b95499 69 s += (t = 3 * (u = Game.captives));
86f0906d
KM
70 if (t != 0)
71 printf("%d Klingons captured\t\t\t%6d\n", u, t);
35b95499 72 s += (t = -(u = Game.deaths));
86f0906d
KM
73 if (t != 0)
74 printf("%d casualties\t\t\t\t%6d\n", u, t);
75 printf("\n*** TOTAL\t\t\t%14ld\n", s);
76 return (s);
77}