Annotation of 43BSDTahoe/games/trek/score.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             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.
        !            16:  */
        !            17: 
        !            18: #ifndef lint
        !            19: static char sccsid[] = "@(#)score.c    5.3 (Berkeley) 6/18/88";
        !            20: #endif /* not lint */
        !            21: 
        !            22: # include      "trek.h"
        !            23: # include      "getpar.h"
        !            24: 
        !            25: /*
        !            26: **  PRINT OUT THE CURRENT SCORE
        !            27: */
        !            28: 
        !            29: long score()
        !            30: {
        !            31:        register int            u;
        !            32:        register int            t;
        !            33:        long                    s;
        !            34:        double                  r;
        !            35:        extern struct cvntab    Skitab[];
        !            36: 
        !            37:        printf("\n*** Your score:\n");
        !            38:        s = t = Param.klingpwr / 4 * (u = Game.killk);
        !            39:        if (t != 0)
        !            40:                printf("%d Klingons killed\t\t\t%6d\n", u, t);
        !            41:        r = Now.date - Param.date;
        !            42:        if (r < 1.0)
        !            43:                r = 1.0;
        !            44:        r = Game.killk / r;
        !            45:        s += (t = 400 * r);
        !            46:        if (t != 0)
        !            47:                printf("Kill rate %.2f Klingons/stardate  \t%6d\n", r, t);
        !            48:        r = Now.klings;
        !            49:        r /= Game.killk + 1;
        !            50:        s += (t = -400 * r);
        !            51:        if (t != 0)
        !            52:                printf("Penalty for %d klingons remaining\t%6d\n", Now.klings, t);
        !            53:        if (Move.endgame > 0)
        !            54:        {
        !            55:                s += (t = 100 * (u = Game.skill));
        !            56:                printf("Bonus for winning a %s%s game\t\t%6d\n", Skitab[u - 1].abrev, Skitab[u - 1].full, t);
        !            57:        }
        !            58:        if (Game.killed)
        !            59:        {
        !            60:                s -= 500;
        !            61:                printf("Penalty for getting killed\t\t  -500\n");
        !            62:        }
        !            63:        s += (t = -100 * (u = Game.killb));
        !            64:        if (t != 0)
        !            65:                printf("%d starbases killed\t\t\t%6d\n", u, t);
        !            66:        s += (t = -100 * (u = Game.helps));
        !            67:        if (t != 0)
        !            68:                printf("%d calls for help\t\t\t%6d\n", u, t);
        !            69:        s += (t = -5 * (u = Game.kills));
        !            70:        if (t != 0)
        !            71:                printf("%d stars destroyed\t\t\t%6d\n", u, t);
        !            72:        s += (t = -150 * (u = Game.killinhab));
        !            73:        if (t != 0)
        !            74:                printf("%d inhabited starsystems destroyed\t%6d\n", u, t);
        !            75:        if (Ship.ship != ENTERPRISE)
        !            76:        {
        !            77:                s -= 200;
        !            78:                printf("penalty for abandoning ship\t\t  -200\n");
        !            79:        }
        !            80:        s += (t = 3 * (u = Game.captives));
        !            81:        if (t != 0)
        !            82:                printf("%d Klingons captured\t\t\t%6d\n", u, t);
        !            83:        s += (t = -(u = Game.deaths));
        !            84:        if (t != 0)
        !            85:                printf("%d casualties\t\t\t\t%6d\n", u, t);
        !            86:        printf("\n***  TOTAL\t\t\t%14ld\n", s);
        !            87:        return (s);
        !            88: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.