1*47851Sbostic /*- 2*47851Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*47851Sbostic * All rights reserved. 4*47851Sbostic * 5*47851Sbostic * The game adventure was original written Fortran by Will Crowther 6*47851Sbostic * and Don Woods. It was later translated to C and enhanced by 7*47851Sbostic * Jim Gillogly. 8*47851Sbostic * 9*47851Sbostic * %sccs.include.redist.c% 10*47851Sbostic */ 116734Srrh 12*47851Sbostic #ifndef lint 13*47851Sbostic static char sccsid[] = "@(#)done.c 5.1 (Berkeley) 04/08/91"; 14*47851Sbostic #endif /* not lint */ 156734Srrh 16*47851Sbostic /* Re-coding of advent in C: termination routines */ 176734Srrh 18*47851Sbostic #include "hdr.h" 196734Srrh 206734Srrh score() /* sort of like 20000 */ 216734Srrh { register int scor,i; 226734Srrh mxscor=scor=0; 236734Srrh for (i=50; i<=maxtrs; i++) 246734Srrh { if (ptext[i].txtlen==0) continue; 256734Srrh k=12; 266734Srrh if (i==chest) k=14; 276734Srrh if (i>chest) k=16; 286734Srrh if (prop[i]>=0) scor += 2; 296734Srrh if (place[i]==3&&prop[i]==0) scor += k-2; 306734Srrh mxscor += k; 316734Srrh } 326734Srrh scor += (maxdie-numdie)*10; 336734Srrh mxscor += maxdie*10; 346734Srrh if (!(scorng||gaveup)) scor += 4; 356734Srrh mxscor += 4; 366734Srrh if (dflag!=0) scor += 25; 376734Srrh mxscor += 25; 386734Srrh if (closng) scor += 25; 396734Srrh mxscor += 25; 406734Srrh if (closed) 416734Srrh { if (bonus==0) scor += 10; 426734Srrh if (bonus==135) scor += 25; 436734Srrh if (bonus==134) scor += 30; 446734Srrh if (bonus==133) scor += 45; 456734Srrh } 466734Srrh mxscor += 45; 476734Srrh if (place[magzin]==108) scor++; 486734Srrh mxscor++; 496734Srrh scor += 2; 506734Srrh mxscor += 2; 516734Srrh for (i=1; i<=hntmax; i++) 526734Srrh if (hinted[i]) scor -= hints[i][2]; 536734Srrh return(scor); 546734Srrh } 556734Srrh 566734Srrh done(entry) /* entry=1 means goto 13000 */ /* game is over */ 576734Srrh int entry; /* entry=2 means goto 20000 */ /* 3=19000 */ 586734Srrh { register int i,sc; 596734Srrh if (entry==1) mspeak(1); 606734Srrh if (entry==3) rspeak(136); 616734Srrh printf("\n\n\nYou scored %d out of a ",(sc=score())); 626734Srrh printf("possible %d using %d turns.\n",mxscor,turns); 636734Srrh for (i=1; i<=clsses; i++) 646734Srrh if (cval[i]>=sc) 656734Srrh { speak(&ctext[i]); 666734Srrh if (i==clsses-1) 676734Srrh { printf("To achieve the next higher rating"); 686734Srrh printf(" would be a neat trick!\n\n"); 696734Srrh printf("Congratulations!!\n"); 706734Srrh exit(0); 716734Srrh } 726734Srrh k=cval[i]+1-sc; 736734Srrh printf("To achieve the next higher rating, you need"); 746734Srrh printf(" %d more point",k); 756734Srrh if (k==1) printf(".\n"); 766734Srrh else printf("s.\n"); 776734Srrh exit(0); 786734Srrh } 796734Srrh printf("You just went off my scale!!!\n"); 806734Srrh exit(0); 816734Srrh } 826734Srrh 836734Srrh 846734Srrh die(entry) /* label 90 */ 856734Srrh int entry; 866734Srrh { register int i; 876734Srrh if (entry != 99) 886734Srrh { rspeak(23); 896734Srrh oldlc2=loc; 906734Srrh } 916734Srrh if (closng) /* 99 */ 926734Srrh { rspeak(131); 936734Srrh numdie++; 946734Srrh done(2); 956734Srrh } 966734Srrh yea=yes(81+numdie*2,82+numdie*2,54); 976734Srrh numdie++; 986734Srrh if (numdie==maxdie || !yea) done(2); 996734Srrh place[water]=0; 1006734Srrh place[oil]=0; 1016734Srrh if (toting(lamp)) prop[lamp]=0; 1026734Srrh for (i=100; i>=1; i--) 1036734Srrh { if (!toting(i)) continue; 1046734Srrh k=oldlc2; 1056734Srrh if (i==lamp) k=1; 1066734Srrh drop(i,k); 1076734Srrh } 1086734Srrh loc=3; 1096734Srrh oldloc=loc; 1106734Srrh return(2000); 1116734Srrh } 1126734Srrh 113