[net.sources] Small ``feature'' fix for phantasia

ralph@uf-csg.UUCP (Ralph Kuntz) (09/27/84)

[This line intentionally left blank]


Someone recently posted the sources to the game ``phantasia''  in
net.sources  and  it  has  become the biggest thing on our system
since we got the source to rogue 3.6.  Unfortunately there is one
small  ``feature''  that we corrected.  When the game asks a yes-
or-no question it checks only for the letter ``y''.  This  causes
problems when one is fighting a flock of Morons, for example, and
he holds down the ``6'' key to take advantage  of  the  automatic
repeat.  When he finally kills the last one and the program tells
him about  the  treasure  they  were  carrying,  he  has  already
answered  ``6''  to  the  ``Do you want to see it?''.  Below is a
``diff -c'' of some  minor  changes  I  made  to  the  source  to
overcome  this problem.  It looks like a large amount of code but
it take only ten minutes to install.  It changes the  program  to
accept  only  "y",  "Y",  "n", or "N" as answers to the yes-or-no
questions.  Hope it makes your game more enjoyable.

------------------------------------------------------------------------------

diff -r -c phant/fight.c /usr/src/games/phant/fight.c
*** phant/fight.c	Thu Sep 27 09:58:47 1984
--- /usr/src/games/phant/fight.c	Thu Sep 27 09:29:25 1984
***************
*** 151,157
  					if (stat->rng.type && stat->rng.type < 10)
  						{
  						mvaddstr(lines++,0,"Will you relinguish your ring ? ");
! 						ch = rgetch();
  						if (toupper(ch) == 'Y')
  							{
  							stat->rng.type = NONE;

--- 151,157 -----
  					if (stat->rng.type && stat->rng.type < 10)
  						{
  						mvaddstr(lines++,0,"Will you relinguish your ring ? ");
! 						ch = getyorn();
  						if (toupper(ch) == 'Y')
  							{
  							stat->rng.type = NONE;
diff -r -c phant/func0.c /usr/src/games/phant/func0.c
*** phant/func0.c	Thu Sep 27 09:58:35 1984
--- /usr/src/games/phant/func0.c	Thu Sep 27 09:31:48 1984
***************
*** 24,30
  			{
  			temp = roll(1,(treastyp - 7)*(treastyp - 7)*(size - 1)/4);
  			printw("You have discovered %.0f gems!  Will you pick them up ? ",temp);
! 			ch = rgetch();
  			addch('\n');
  			if (toupper(ch) == 'Y')
  				if (rnd() < treastyp/40 + 0.05)	/* cursed */

--- 24,30 -----
  			{
  			temp = roll(1,(treastyp - 7)*(treastyp - 7)*(size - 1)/4);
  			printw("You have discovered %.0f gems!  Will you pick them up ? ",temp);
! 			ch = getyorn();
  			addch('\n');
  			if (toupper(ch) == 'Y')
  				if (rnd() < treastyp/40 + 0.05)	/* cursed */
***************
*** 40,46
  			{
  			temp = roll(treastyp*10,treastyp*treastyp*10*(size - 1));
  			printw("You have found %.0f gold pieces.  Do you want to pick them up ? ",temp);
! 			ch = rgetch();
  			addch('\n');
  			if (toupper(ch) == 'Y')
  				if (rnd() < treastyp/35 + 0.04)	/* cursed */

--- 40,46 -----
  			{
  			temp = roll(treastyp*10,treastyp*treastyp*10*(size - 1));
  			printw("You have found %.0f gold pieces.  Do you want to pick them up ? ",temp);
! 			ch = getyorn();
  			addch('\n');
  			if (toupper(ch) == 'Y')
  				if (rnd() < treastyp/35 + 0.04)	/* cursed */
***************
*** 64,70
  	else	/* other treasures */
  		{
  		addstr("You have found some treasure.  Do you want to inspect it ? ");
! 		ch = rgetch();
  		addch('\n');
  		if (toupper(ch) != 'Y')
  			return;

--- 64,70 -----
  	else	/* other treasures */
  		{
  		addstr("You have found some treasure.  Do you want to inspect it ? ");
! 		ch = getyorn();
  		addch('\n');
  		if (toupper(ch) != 'Y')
  			return;
***************
*** 125,131
  								break;
  							case 2:
  								addstr("You have rescued a virgin.  Will you be honorable ? ");
! 								ch = rgetch();
  								if (toupper(ch) == 'Y')
  									stat->vrg = TRUE;
  								else

--- 125,131 -----
  								break;
  							case 2:
  								addstr("You have rescued a virgin.  Will you be honorable ? ");
! 								ch = getyorn();
  								if (toupper(ch) == 'Y')
  									stat->vrg = TRUE;
  								else
***************
*** 142,148
  						break;
  					case 4:
  						addstr("You've found a scroll.  Will you read it ? ");
! 						ch = rgetch();
  						addch('\n');
  						if (toupper(ch) == 'Y')
  							switch ((int) roll(1,6))

--- 142,148 -----
  						break;
  					case 4:
  						addstr("You've found a scroll.  Will you read it ? ");
! 						ch = getyorn();
  						addch('\n');
  						if (toupper(ch) == 'Y')
  							switch ((int) roll(1,6))
***************
*** 263,269
  								break;
  							case 2:
  								addstr("You have discovered a transporter.  Do you wish to go anywhere ? ");
! 								ch = rgetch();
  								addch('\n');
  								if (toupper(ch) == 'Y')
  									{

--- 263,269 -----
  								break;
  							case 2:
  								addstr("You have discovered a transporter.  Do you wish to go anywhere ? ");
! 								ch = getyorn();
  								addch('\n');
  								if (toupper(ch) == 'Y')
  									{
***************
*** 327,333
  										temp = 15 + rngcalc(stat->typ) + roll(0,5);
  										}
  									addstr("You've discovered a ring.  Will you pick it up ? ");
! 									ch = rgetch();
  									addch('\n');
  									if (toupper(ch) == 'Y')
  										{

--- 327,333 -----
  										temp = 15 + rngcalc(stat->typ) + roll(0,5);
  										}
  									addstr("You've discovered a ring.  Will you pick it up ? ");
! 									ch = getyorn();
  									addch('\n');
  									if (toupper(ch) == 'Y')
  										{
***************
*** 752,758
  						break;
  					case '7':
  						printw("A blessing requires a %d gp donation.  Still want one ? ",menu[6].cost);
! 						ch = rgetch();
  						if (toupper(ch) == 'Y')
  							if (stat->gld < menu[6].cost)
  								goto CHEAT;

--- 752,758 -----
  						break;
  					case '7':
  						printw("A blessing requires a %d gp donation.  Still want one ? ",menu[6].cost);
! 						ch = getyorn();
  						if (toupper(ch) == 'Y')
  							if (stat->gld < menu[6].cost)
  								goto CHEAT;
***************
*** 946,952
  			temp = roll(6,50);
  			mvprintw(5,0,"You've found %.0f gold pieces, want them ? ",temp);
  			clrtoeol();
! 			ch = rgetch();
  			if (toupper(ch) == 'Y')
  				stat->gld += temp;
  			break;

--- 946,952 -----
  			temp = roll(6,50);
  			mvprintw(5,0,"You've found %.0f gold pieces, want them ? ",temp);
  			clrtoeol();
! 			ch = getyorn();
  			if (toupper(ch) == 'Y')
  				stat->gld += temp;
  			break;
diff -r -c phant/func1.c /usr/src/games/phant/func1.c
*** phant/func1.c	Thu Sep 27 09:58:39 1984
--- /usr/src/games/phant/func1.c	Thu Sep 27 09:32:26 1984
***************
*** 206,212
  			addstr("You're a complete failure -- you've died!!\n");
  		}
  	addstr("Care to give it another try ? ");
! 	ch = rgetch();
  	if (toupper(ch) == 'Y')
  		{
  		endwin();

--- 206,212 -----
  			addstr("You're a complete failure -- you've died!!\n");
  		}
  	addstr("Care to give it another try ? ");
! 	ch = getyorn();
  	if (toupper(ch) == 'Y')
  		{
  		endwin();
diff -r -c phant/func2.c /usr/src/games/phant/func2.c
*** phant/func2.c	Thu Sep 27 09:58:42 1984
--- /usr/src/games/phant/func2.c	Thu Sep 27 09:33:38 1984
***************
*** 771,777
  		move(4,0);
  		clrtoeol();
  		addstr("Quitting now will automatically kill your character.  Still want to ? ");
! 		ch = rgetch();
  		if (toupper(ch) == 'Y')
  			longjmp(mainenv,DIE);
  		}

--- 771,777 -----
  		move(4,0);
  		clrtoeol();
  		addstr("Quitting now will automatically kill your character.  Still want to ? ");
! 		ch = getyorn();
  		if (toupper(ch) == 'Y')
  			longjmp(mainenv,DIE);
  		}
***************
*** 780,786
  		move(4,0);
  		clrtoeol();
  		addstr("Do you really want to quit ? ");
! 		ch = rgetch();
  		if (toupper(ch) == 'Y')
  			longjmp(mainenv,QUIT);
  		}

--- 780,786 -----
  		move(4,0);
  		clrtoeol();
  		addstr("Do you really want to quit ? ");
! 		ch = getyorn();
  		if (toupper(ch) == 'Y')
  			longjmp(mainenv,QUIT);
  		}
***************
*** 799,804
  {
  	refresh();
  	return (getch());
  }
  
  void	purge() 	/* remove old players */

--- 799,814 -----
  {
  	refresh();
  	return (getch());
+ }
+ 
+ int	getyorn()		/* return yes or no answer */
+ {
+ 	int ch;
+ 
+ 	do {
+ 		ch = rgetch();
+ 	} while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N');
+ 	return (ch);
  }
  
  void	purge() 	/* remove old players */
diff -r -c phant/main.c /usr/src/games/phant/main.c
*** phant/main.c	Thu Sep 27 09:58:44 1984
--- /usr/src/games/phant/main.c	Thu Sep 27 09:34:29 1984
***************
*** 163,169
  		}
  #endif
  	mvaddstr(23,24,"Do you have a character to run? ");
! 	ch = rgetch();
  	if (toupper(ch) == 'Y')
  		fileloc = findchar(&charac);
  	else

--- 163,169 -----
  		}
  #endif
  	mvaddstr(23,24,"Do you have a character to run? ");
! 	ch = getyorn();
  	if (toupper(ch) == 'Y')
  		fileloc = findchar(&charac);
  	else
***************
*** 225,231
  		addstr("If you think you have good cause to have you character saved,\n");
  		printw("you may quit and mail your reason to '%s'.\n",WIZARD);
  		addstr("Do you want to quit ? ");
! 		ch = rgetch();
  		if (toupper(ch) == 'Y')
  			{
  			charac.quk = -100;

--- 225,231 -----
  		addstr("If you think you have good cause to have you character saved,\n");
  		printw("you may quit and mail your reason to '%s'.\n",WIZARD);
  		addstr("Do you want to quit ? ");
! 		ch = getyorn();
  		if (toupper(ch) == 'Y')
  			{
  			charac.quk = -100;
diff -r -c phant/phant.h /usr/src/games/phant/phant.h
*** phant/phant.h	Thu Sep 27 09:58:26 1984
--- /usr/src/games/phant/phant.h	Thu Sep 27 09:24:34 1984
***************
*** 3,9
   */
  
  #include <setjmp.h>
! #include <curses.h>
  #include <time.h>
  #include <pwd.h>
  #include <signal.h>

--- 3,9 -----
   */
  
  #include <setjmp.h>
! #include <vaxcurses.h>
  #include <time.h>
  #include <pwd.h>
  #include <signal.h>
***************
*** 157,163
  	paws(), printhelp(), printmonster(), printplayers(), printstats(), purge(),
  	showall(), showusers(), statread(), talk(), tampered(), titlestuff(),
  	trade(), treasure(), trunc(), update(), voidupdate();
! int	allocvoid(), findchar(), findspace(), gch(), interrupt(), rgetch(), rngcalc();
  unsigned level();
  double	inflt();
  char	*printloc();

--- 157,164 -----
  	paws(), printhelp(), printmonster(), printplayers(), printstats(), purge(),
  	showall(), showusers(), statread(), talk(), tampered(), titlestuff(),
  	trade(), treasure(), trunc(), update(), voidupdate();
! int	allocvoid(), findchar(), findspace(), gch(), interrupt(), getyorn(),
! 	rgetch(), rngcalc();
  unsigned level();
  double	inflt();
  char	*printloc();
Only in /usr/src/games/phant: phant.help
Only in /usr/src/games/phant: phant.p1
Only in /usr/src/games/phant: phant.p2
Only in /usr/src/games/phant: phant.p3
Only in /usr/src/games/phant: phantasia
Only in /usr/src/games/phant: setfiles
Only in /usr/src/games/phant: tags
-- 

	From the dungeon at the University of Florida

	oooo            VOICE:  Ralph Kuntz
       /    \           UUCP:   ..!akgua!uf-csv{!uf-csg}!ralph
     O| o  o |O         USNAIL: 512 Weil Hall, CIS
      |  ..  |                  University of Florida
      | \__/ |                  Gainesville, FL. 32611
       \____/           AT&T:   (904) 392-2371

[The preceding does not necessarily represent the opinion of anyone.]