]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com6.c
specify man pages the new way.
[bsdgames-darwin.git] / battlestar / com6.c
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
35 /*static char sccsid[] = "from: @(#)com6.c 5.5 (Berkeley) 6/1/90";*/
36 static char rcsid[] = "$Id: com6.c,v 1.2 1993/08/01 18:56:07 mycroft Exp $";
37 #endif /* not lint */
38
39 #include "externs.h"
40 #include "pathnames.h"
41
42 launch()
43 {
44 if (testbit(location[position].objects,VIPER) && !notes[CANTLAUNCH]){
45 if (fuel > 4){
46 clearbit(location[position].objects,VIPER);
47 position = location[position].up;
48 notes[LAUNCHED] = 1;
49 time++;
50 fuel -= 4;
51 puts("You climb into the viper and prepare for launch.");
52 puts("With a touch of your thumb the turbo engines ignite, thrusting you back into\nyour seat.");
53 return(1);
54 }
55 else
56 puts("Not enough fuel to launch.");
57 }
58 else
59 puts("Can't launch.");
60 return(0);
61 }
62
63 land()
64 {
65 if (notes[LAUNCHED] && testbit(location[position].objects,LAND) && location[position].down){
66 notes[LAUNCHED] = 0;
67 position = location[position].down;
68 setbit(location[position].objects,VIPER);
69 fuel -= 2;
70 time++;
71 puts("You are down.");
72 return(1);
73 }
74 else
75 puts("You can't land here.");
76 return(0);
77 }
78
79 die() /* endgame */
80 {
81 printf("bye.\nYour rating was %s.\n", rate());
82 post(' ');
83 exit(0);
84 }
85
86 live()
87 {
88 puts("\nYou win!");
89 post('!');
90 exit(0);
91 }
92
93 /*
94 * sigh -- this program thinks "time" is an int. It's easier to not load
95 * <time.h> than try and fix it.
96 */
97 #define KERNEL
98 #include <sys/time.h>
99 #undef KERNEL
100
101 post(ch)
102 char ch;
103 {
104 FILE *fp;
105 struct timeval tv;
106 char *date, *ctime();
107 int s = sigblock(sigmask(SIGINT));
108
109 gettimeofday(&tv, (struct timezone *)0); /* can't call time */
110 date = ctime(&tv.tv_sec);
111 date[24] = '\0';
112 if (fp = fopen(_PATH_SCORE,"a")) {
113 fprintf(fp, "%s %8s %c%20s", date, uname, ch, rate());
114 if (wiz)
115 fprintf(fp, " wizard\n");
116 else if (tempwiz)
117 fprintf(fp, " WIZARD!\n");
118 else
119 fprintf(fp, "\n");
120 } else
121 perror(_PATH_SCORE);
122 sigsetmask(s);
123 }
124
125 char *
126 rate()
127 {
128 int score;
129
130 score = max(max(pleasure,power),ego);
131 if (score == pleasure){
132 if (score < 5)
133 return("novice");
134 else if (score < 20)
135 return("junior voyeur");
136 else if (score < 35)
137 return("Don Juan");
138 else return("Marquis De Sade");
139 }
140 else if (score == power){
141 if (score < 5)
142 return("serf");
143 else if (score < 8)
144 return("Samurai");
145 else if (score < 13)
146 return("Klingon");
147 else if (score < 22)
148 return("Darth Vader");
149 else return("Sauron the Great");
150 }
151 else{
152 if (score < 5)
153 return("Polyanna");
154 else if (score < 10)
155 return("philanthropist");
156 else if (score < 20)
157 return("Tattoo");
158 else return("Mr. Roarke");
159 }
160 }
161
162 drive()
163 {
164 if (testbit(location[position].objects,CAR)){
165 puts("You hop in the car and turn the key. There is a perceptible grating noise,");
166 puts("and an explosion knocks you unconscious...");
167 clearbit(location[position].objects,CAR);
168 setbit(location[position].objects,CRASH);
169 injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1;
170 time += 15;
171 zzz();
172 return(0);
173 }
174 else
175 puts("There is nothing to drive here.");
176 return(-1);
177 }
178
179 ride()
180 {
181 if (testbit(location[position].objects,HORSE)){
182 puts("You climb onto the stallion and kick it in the guts. The stupid steed launches");
183 puts("forward through bush and fern. You are thrown and the horse gallups off.");
184 clearbit(location[position].objects,HORSE);
185 while (!(position = rnd(NUMOFROOMS+1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere);
186 setbit(location[position].objects,HORSE);
187 if (location[position].north)
188 position = location[position].north;
189 else if (location[position].south)
190 position = location[position].south;
191 else if (location[position].east)
192 position = location[position].east;
193 else
194 position = location[position].west;
195 return(0);
196 }
197 else puts("There is no horse here.");
198 return(-1);
199 }
200
201 light() /* synonyms = {strike, smoke} */
202 { /* for matches, cigars */
203 if (testbit(inven,MATCHES) && matchcount){
204 puts("Your match splutters to life.");
205 time++;
206 matchlight = 1;
207 matchcount--;
208 if (position == 217){
209 puts("The whole bungalow explodes with an intense blast.");
210 die();
211 }
212 }
213 else puts("You're out of matches.");
214 }