/* altar.c */
#include "header.h"
static char copyright[]="Larn is copyrighted 1986 by Noah Morgan.\n";
extern short playerx,playery;
extern char level;
extern int c[];
/*
	******
	OALTAR
	******

	subroutine to process an altar object
 */
oaltar()
	{
	register int j;
	int k;

	lprcat("\nDo you (p) pray  (d) desicrate"); iopts();
	while (1)
	  {
	  while (1) switch(getchar())
		{
		case 'p':	lprcat(" pray\nDo you (m) give money or (j) just pray? ");
					while (1) switch(getchar())
					  {
					  case 'j':	if (rnd(100)<75) 
									lprcat("\nnothing happens");
								else if (rnd(13)<4) ohear();
								else if (rnd(53) == 10)
									{
									if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
									enchantarmor(); return;
									}
								else if (rnd(53) == 10)
									{
									if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
									enchweapon(); return;
									}
								else createmonster(makemonst(level+1));
								return;

					  case 'm':	lprcat("\nhow much do you donate? ");
								k = readnum(c[GOLD]);
								if (c[GOLD]<k)
									{
									lprcat("\nYou dont have that much!");
									return;
									}
								c[GOLD] -= k;
								if (k < c[GOLD]/10 || k<rnd(50))
									{ createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; }
								else if (rnd(101) > 50)	{ ohear(); return; }
								else if (rnd(53) == 5)
									{
									if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
									enchantarmor(); return;
									}
								else if (rnd(53) == 8)
									{
									if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
									enchweapon(); return;
									}
								else	lprcat("\nThank You.");
								bottomline();	return;

					  case '\33':	return;
					  };

		case 'd': lprcat(" desicrate");
				  if (rnd(100)<60)
						{ createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; }
					else
					if (rnd(101)<30)
						{
						lprcat("\nThe altar crumbles into a pile of dust before your eyes");
						forget();	/*	remember to destroy the altar	*/
						}
					else
						lprcat("\nnothing happens");
					return;

		case 'i':
		case '\33': ignore();
				  if (rnd(100)<30)	{ createmonster(makemonst(level+1)); c[AGGRAVATE] += rnd(450); }
					else	lprcat("\nnothing happens");
					return;
		};
	  }
	}

/*
	function to cast a +3 protection on the player
 */
static ohear()
	{
	lprcat("\nYou have been heard!");
	if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
	c[ALTPRO] += 500;	/* protection field */
	bottomline();
	}

