Annotation of 43BSDReno/games/battlestar/com6.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 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: (1) source distributions retain this entire copyright
                      7:  * notice and comment, and (2) distributions including binaries display
                      8:  * the following acknowledgement:  ``This product includes software
                      9:  * developed by the University of California, Berkeley and its contributors''
                     10:  * in the documentation or other materials provided with the distribution
                     11:  * and in all advertising materials mentioning features or use of this
                     12:  * software. Neither the name of the University nor the names of its
                     13:  * contributors may be used to endorse or promote products derived
                     14:  * from this software without specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: static char sccsid[] = "@(#)com6.c     5.5 (Berkeley) 6/1/90";
                     22: #endif /* not lint */
                     23: 
                     24: #include "externs.h"
                     25: #include "pathnames.h"
                     26: 
                     27: launch()
                     28: {
                     29:        if (testbit(location[position].objects,VIPER) && !notes[CANTLAUNCH]){
                     30:                if (fuel > 4){
                     31:                        clearbit(location[position].objects,VIPER);
                     32:                        position = location[position].up;
                     33:                        notes[LAUNCHED] = 1;
                     34:                        time++;
                     35:                        fuel -= 4;
                     36:                        puts("You climb into the viper and prepare for launch.");
                     37:                        puts("With a touch of your thumb the turbo engines ignite, thrusting you back into\nyour seat.");
                     38:                        return(1);
                     39:                }
                     40:                else
                     41:                        puts("Not enough fuel to launch.");
                     42:         }
                     43:         else
                     44:                puts("Can't launch.");
                     45:         return(0);
                     46: }
                     47: 
                     48: land()
                     49: {
                     50:        if (notes[LAUNCHED] && testbit(location[position].objects,LAND) && location[position].down){
                     51:                notes[LAUNCHED] = 0;
                     52:                position = location[position].down;
                     53:                setbit(location[position].objects,VIPER);
                     54:                fuel -= 2;
                     55:                time++;
                     56:                puts("You are down.");
                     57:                return(1);
                     58:        }
                     59:        else
                     60:                puts("You can't land here.");
                     61:        return(0);
                     62: }
                     63: 
                     64: die()          /* endgame */
                     65: {
                     66:        printf("bye.\nYour rating was %s.\n", rate());
                     67:        post(' ');
                     68:        exit(0);
                     69: }
                     70: 
                     71: live()
                     72: {
                     73:        puts("\nYou win!");
                     74:        post('!');
                     75:        exit(0);
                     76: }
                     77: 
                     78: /*
                     79:  * sigh -- this program thinks "time" is an int.  It's easier to not load
                     80:  * <time.h> than try and fix it.
                     81:  */
                     82: #define KERNEL
                     83: #include <sys/time.h>
                     84: #undef KERNEL
                     85: 
                     86: post(ch)
                     87: char ch;
                     88: {
                     89:        FILE *fp;
                     90:        struct timeval tv;
                     91:        char *date, *ctime();
                     92:        int s = sigblock(sigmask(SIGINT));
                     93: 
                     94:        gettimeofday(&tv, (struct timezone *)0);        /* can't call time */
                     95:        date = ctime(&tv.tv_sec);
                     96:        date[24] = '\0';
                     97:        if (fp = fopen(_PATH_SCORE,"a")) {
                     98:                fprintf(fp, "%s  %8s  %c%20s", date, uname, ch, rate());
                     99:                if (wiz)
                    100:                        fprintf(fp, "   wizard\n");
                    101:                else if (tempwiz)
                    102:                        fprintf(fp, "   WIZARD!\n");
                    103:                else
                    104:                        fprintf(fp, "\n");
                    105:        } else
                    106:                perror(_PATH_SCORE);
                    107:        sigsetmask(s);
                    108: }
                    109: 
                    110: char *
                    111: rate()
                    112: {
                    113:        int score;
                    114: 
                    115:        score = max(max(pleasure,power),ego);
                    116:        if (score == pleasure){
                    117:                if (score < 5)
                    118:                        return("novice");
                    119:                else if (score < 20)
                    120:                        return("junior voyeur");
                    121:                else if (score < 35)
                    122:                        return("Don Juan");
                    123:                else return("Marquis De Sade");
                    124:        }
                    125:        else if (score == power){
                    126:                if (score < 5)
                    127:                        return("serf");
                    128:                else if (score < 8)
                    129:                        return("Samurai");
                    130:                else if (score < 13)
                    131:                        return("Klingon");
                    132:                else if (score < 22)
                    133:                        return("Darth Vader");
                    134:                else return("Sauron the Great");
                    135:        }
                    136:        else{
                    137:                if (score < 5)
                    138:                        return("Polyanna");
                    139:                else if (score < 10)
                    140:                        return("philanthropist");
                    141:                else if (score < 20)
                    142:                        return("Tattoo");
                    143:                else return("Mr. Roarke");
                    144:        }
                    145: }
                    146: 
                    147: drive()
                    148: {
                    149:        if (testbit(location[position].objects,CAR)){
                    150:                puts("You hop in the car and turn the key.  There is a perceptible grating noise,");
                    151:                puts("and an explosion knocks you unconscious...");
                    152:                clearbit(location[position].objects,CAR);
                    153:                setbit(location[position].objects,CRASH);
                    154:                injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1;
                    155:                time += 15;
                    156:                zzz();
                    157:                return(0);
                    158:        }
                    159:        else
                    160:                puts("There is nothing to drive here.");
                    161:        return(-1);
                    162: }
                    163: 
                    164: ride()
                    165: {
                    166:        if (testbit(location[position].objects,HORSE)){
                    167:                puts("You climb onto the stallion and kick it in the guts.  The stupid steed launches");
                    168:                puts("forward through bush and fern.  You are thrown and the horse gallups off.");
                    169:                clearbit(location[position].objects,HORSE);
                    170:                while (!(position = rnd(NUMOFROOMS+1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere);
                    171:                setbit(location[position].objects,HORSE);
                    172:                if (location[position].north)
                    173:                        position = location[position].north;
                    174:                else if (location[position].south)
                    175:                        position = location[position].south;
                    176:                else if (location[position].east)
                    177:                        position = location[position].east;
                    178:                else
                    179:                        position = location[position].west;
                    180:                return(0);
                    181:        }
                    182:        else puts("There is no horse here.");
                    183:        return(-1);
                    184: }
                    185: 
                    186: light()                /* synonyms = {strike, smoke} */
                    187: {              /* for matches, cigars */
                    188:        if (testbit(inven,MATCHES) && matchcount){
                    189:                puts("Your match splutters to life.");
                    190:                time++;
                    191:                matchlight = 1;
                    192:                matchcount--;
                    193:                if (position == 217){
                    194:                        puts("The whole bungalow explodes with an intense blast.");
                    195:                        die();
                    196:                }
                    197:        }
                    198:        else puts("You're out of matches.");
                    199: }

unix.superglobalmegacorp.com

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