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