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