/* fountain.c */
#include "header.h"
static char copyright[]="Larn is copyrighted 1986 by Noah Morgan.\n";
extern short lastnum,playerx,playery;
extern char level;
extern int c[];
extern char item[MAXX][MAXY],know[MAXX][MAXY];
/*
	*********
	OFOUNTAIN
	*********
 */

ofountain()
	{
	register int x;
	cursor(1,21);
	lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
	while (1) switch(getchar())
		{
		case 'd':	lprcat("drink");
					if (rnd(1501)<2)
						{
						lprcat("\n\7Oops!  You seem to have caught the dreadful sleep!");
						lflush();  sleep(3);  died(280);
						}
					x = rnd(100);
					if (x<7)
						{
						c[HALFDAM] += 200+rnd(200);
						lprcat("\nYou feel a sickness coming on");
						}
					else if (x<13) quaffpotion(23); /* see invisible */
					else if (x < 45)
						lprcat("\nnothing seems to have happened");
					else if (rnd(3) != 2)
						fntchange(1);	/*	change char levels upward	*/
					else
						fntchange(-1);	/*	change char levels downward	*/
					if (rnd(12)<3)
						{
						lprcat("\nThe fountains bubbling slowly quiets");
						item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */
						know[playerx][playery]=0;
						}
					return;

		case '\33':
		case 'i':	ignore();  return;

		case 'w':	lprcat("wash yourself");
					if (rnd(100) < 11)
						{
						x=rnd((level<<2)+2);
						lprintf("\nOh no!  The water was foul!  You suffer %d hit points!",x);
						lastnum=273; loosehp(x); bottomline();  cursor(1,21);
						}
					else
					if (rnd(100) < 29)
						lprcat("\nYou got the dirt off!");
					else
					if (rnd(100) < 31)
						lprcat("\nThis water seems to be hard water!  The dirt didn't come off!");
					else
					if (rnd(100) < 34)
						createmonster(WATERLORD); /*	make water lord		*/
					else
					lprcat("\nnothing seems to have happened");
					return;
		}
	}

/*
	a subroutine to raise or lower character levels
	if x > 0 they are raised   if x < 0 they are lowered
 */
fntchange(how)
	int how;
	{
	register int j;
	lprc('\n');
	switch(rnd(9))
		{
		case 1:	lprcat("Your strength");		fch(how,&c[0]);		break;
		case 2:	lprcat("Your intelligence");	fch(how,&c[1]);		break;
		case 3:	lprcat("Your wisdom");			fch(how,&c[2]);		break;
		case 4:	lprcat("Your constitution");	fch(how,&c[3]);		break;
		case 5:	lprcat("Your dexterity");		fch(how,&c[4]);		break;
		case 6:	lprcat("Your charm");			fch(how,&c[5]);		break;
		case 7:	j=rnd(level+1);
				if (how < 0)
					{ lprintf("You loose %d hit point",j);  if (j>1) lprcat("s!"); else lprc('!'); loosemhp(j); }
				else
					{ lprintf("You gain %d hit point",j);  if (j>1) lprcat("s!"); else lprc('!'); raisemhp(j); }
				bottomline();		break;

		case 8:	j=rnd(level+1);
				if (how > 0)
					{
					lprintf("You just gained %d spell",j);  raisemspells(j);
					if (j>1) lprcat("s!"); else lprc('!');
					}
				else
					{
					lprintf("You just lost %d spell",j);	loosemspells(j);
					if (j>1) lprcat("s!"); else lprc('!');
					}
				bottomline();		break;

		case 9:	j = 5*rnd((level+1)*(level+1));
				if (how < 0)
					{
					lprintf("You just lost %d experience point",j);
					if (j>1) lprcat("s!"); else lprc('!'); looseexperience(j);
					}
				else
					{
					lprintf("You just gained %d experience point",j);
					if (j>1) lprcat("s!"); else lprc('!'); raiseexperience(j);
					}
				break;
		}
	cursor(1,21);
	}

/*
	***
	FCH
	***

	subroutine to process an up/down of a character attribute for ofountain
 */
fch(how,x)
	int how,*x;
	{
	if (how < 0)	 { lprcat(" went down by one!");	--(*x); }
		else		 { lprcat(" went up by one!");	(*x)++; }
	bottomline();
	}
