1 /*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * The game adventure was original written Fortran by Will Crowther 6 * and Don Woods. It was later translated to C and enhanced by 7 * Jim Gillogly. 8 * 9 * %sccs.include.redist.c% 10 */ 11 12 #ifndef lint 13 static char sccsid[] = "@(#)done.c 5.1 (Berkeley) 04/08/91"; 14 #endif /* not lint */ 15 16 /* Re-coding of advent in C: termination routines */ 17 18 #include "hdr.h" 19 20 score() /* sort of like 20000 */ 21 { register int scor,i; 22 mxscor=scor=0; 23 for (i=50; i<=maxtrs; i++) 24 { if (ptext[i].txtlen==0) continue; 25 k=12; 26 if (i==chest) k=14; 27 if (i>chest) k=16; 28 if (prop[i]>=0) scor += 2; 29 if (place[i]==3&&prop[i]==0) scor += k-2; 30 mxscor += k; 31 } 32 scor += (maxdie-numdie)*10; 33 mxscor += maxdie*10; 34 if (!(scorng||gaveup)) scor += 4; 35 mxscor += 4; 36 if (dflag!=0) scor += 25; 37 mxscor += 25; 38 if (closng) scor += 25; 39 mxscor += 25; 40 if (closed) 41 { if (bonus==0) scor += 10; 42 if (bonus==135) scor += 25; 43 if (bonus==134) scor += 30; 44 if (bonus==133) scor += 45; 45 } 46 mxscor += 45; 47 if (place[magzin]==108) scor++; 48 mxscor++; 49 scor += 2; 50 mxscor += 2; 51 for (i=1; i<=hntmax; i++) 52 if (hinted[i]) scor -= hints[i][2]; 53 return(scor); 54 } 55 56 done(entry) /* entry=1 means goto 13000 */ /* game is over */ 57 int entry; /* entry=2 means goto 20000 */ /* 3=19000 */ 58 { register int i,sc; 59 if (entry==1) mspeak(1); 60 if (entry==3) rspeak(136); 61 printf("\n\n\nYou scored %d out of a ",(sc=score())); 62 printf("possible %d using %d turns.\n",mxscor,turns); 63 for (i=1; i<=clsses; i++) 64 if (cval[i]>=sc) 65 { speak(&ctext[i]); 66 if (i==clsses-1) 67 { printf("To achieve the next higher rating"); 68 printf(" would be a neat trick!\n\n"); 69 printf("Congratulations!!\n"); 70 exit(0); 71 } 72 k=cval[i]+1-sc; 73 printf("To achieve the next higher rating, you need"); 74 printf(" %d more point",k); 75 if (k==1) printf(".\n"); 76 else printf("s.\n"); 77 exit(0); 78 } 79 printf("You just went off my scale!!!\n"); 80 exit(0); 81 } 82 83 84 die(entry) /* label 90 */ 85 int entry; 86 { register int i; 87 if (entry != 99) 88 { rspeak(23); 89 oldlc2=loc; 90 } 91 if (closng) /* 99 */ 92 { rspeak(131); 93 numdie++; 94 done(2); 95 } 96 yea=yes(81+numdie*2,82+numdie*2,54); 97 numdie++; 98 if (numdie==maxdie || !yea) done(2); 99 place[water]=0; 100 place[oil]=0; 101 if (toting(lamp)) prop[lamp]=0; 102 for (i=100; i>=1; i--) 103 { if (!toting(i)) continue; 104 k=oldlc2; 105 if (i==lamp) k=1; 106 drop(i,k); 107 } 108 loc=3; 109 oldloc=loc; 110 return(2000); 111 } 112 113