예제 #1
0
/*
	subroutine to process a throne object
 */
void
othrone(int arg)
{

	lprcat("\nDo you (p) pry off jewels, (s) sit down");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 'p':
				lprcat(" pry off");
				act_remove_gems(arg);
				return;

			case 's':
				lprcat(" sit down");
				act_sit_throne(arg);
				return;

			case 'i':
			case '\33':
				ignore();
				return;
			};
	}
}
예제 #2
0
void
odeadthrone(void)
{
	int    k;

	lprcat("\nDo you (s) sit down");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 's':
				lprcat(" sit down");
				k = rnd(101);
				if (k < 35) {
					lprcat("\nZaaaappp!  You've been teleported!\n");
					beep();
					oteleport(0);
				} else
					lprcat("\nnothing happens");
				return;

			case 'i':
			case '\33':
				ignore();
				return;
			};
	}
}
예제 #3
0
/*
	process a fountain object
 */
void
ofountain(void)
{

	cursors();
	lprcat("\nDo you (d) drink, (w) wash yourself");
	iopts();
	while (1)
		switch (ttgetch()) {
		case 'd':
			lprcat("drink");
			act_drink_fountain();
			return;

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

		case 'w':
			lprcat("wash yourself");
			act_wash_fountain();
			return;
		}
}
예제 #4
0
/*
	subroutine to process a throne object
 */
void
ochest(void)
{

	lprcat("\nDo you (t) take it, (o) try to open it");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 'o':
				lprcat(" open it");
				act_open_chest(playerx, playery);
				return;

			case 't':
				lprcat(" take");
				if (take(OCHEST, iarg[playerx][playery]) == 0)
					item[playerx][playery] = know[playerx][playery] = 0;
				return;

			case 'i':
			case '\33':
				ignore();
				return;
			};
	}
}
예제 #5
0
파일: main.c 프로젝트: HunterZ/larn
/*
    function to ask what player wants to do
 */
static int whatitem(char *str)
{
    int i=0;

    cursors();  lprintf("\nWhat do you want to %s [* for all] ? ",str);
    while (i>'z' || (i<'a' && i!='-' && i!='*' && i!='\33' && i!='.'))
        i=ttgetch();
    if (i=='\33')
        lprcat(" aborted");
    
    return(i);
}
예제 #6
0
파일: main.c 프로젝트: ajinkya93/netbsd-src
/*
	subroutine to get a number from the player
	and allow * to mean return amt, else return the number entered
 */
unsigned long 
readnum(long mx)
{
	int    i;
	unsigned long amt = 0;
	sncbr();
	if ((i = ttgetch()) == '*')
		amt = mx;	/* allow him to say * for all gold */
	else
		while (i != '\n') {
			if (i == '\033') {
				scbr();
				lprcat(" aborted");
				return (0);
			}
			if ((i <= '9') && (i >= '0') && (amt < 99999999))
				amt = amt * 10 + i - '0';
			i = ttgetch();
		}
	scbr();
	return (amt);
}
예제 #7
0
/*
 *	subroutine to process an altar object
 */
void
oaltar(void)
{

	lprcat("\nDo you (p) pray  (d) desecrate");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 'p':
				lprcat(" pray\nDo you (m) give money or (j) just pray? ");
				while (1)
					switch (ttgetch()) {
					case 'j':
						act_just_pray();
						return;

					case 'm':
						act_donation_pray();
						return;

					case '\33':
						return;
					};

			case 'd':
				lprcat(" desecrate");
				act_desecrate_altar();
				return;

			case 'i':
			case '\33':
				ignore();
				act_ignore_altar();
				return;
			};
	}
}
예제 #8
0
파일: main.c 프로젝트: HunterZ/larn
/*
    subroutine to get a number from the player
    and allow * to mean return amt, else return the number entered
 */
unsigned long readnum(long mx)
{
    int i;
    unsigned long amt=0;

    sncbr();
    /* allow him to say * for all gold 
    */
    if ((i=ttgetch()) == '*')
        amt = mx;
    else
        /* read chars into buffer, deleting when requested */
    while (i != '\n')
        {
        if (i=='\033') { scbr(); lprcat(" aborted"); return(0); }
        if ((i <= '9') && (i >= '0') && (amt<999999999))
            amt = amt*10+i-'0';
        if ((i=='\010') || (i=='\177'))
            amt = (long)(amt / 10) ;
        i = ttgetch();
        }
    scbr();
    return(amt);
}
예제 #9
0
/*
* lexical analyzer for larn
*/
int yylex(void)
{
	char cc;
	char firsttime = TRUE;

	if (hit2flag)
	{
		hit2flag=0;
		yrepcount=0;
		return(' ');
	}
	if (yrepcount>0)
	{
		--yrepcount;
		return(lastok);
	}
	else
		yrepcount=0;
	if (yrepcount==0) 
	{ 
		bottomdo(); 
		showplayer();               /* show where the player is */
		move_no_pickup = FALSE;     /* clear 'm' flag */
	}

	lflush();
	for (;;)
	{
		cdesc[BYTESIN]++;

		cc = ttgetch();

		/* get repeat count, showing to player
		*/
		if ((cc <= '9') && (cc >= '0'))
		{
			yrepcount = yrepcount*10 + cc - '0';

			/* show count to player for feedback
			*/
			if ( yrepcount >= 10 )
			{
				cursors();
				if (firsttime)
					lprcat("\n");
				lprintf("count: %d", (int)yrepcount );
				firsttime=FALSE;
				lflush();  /* show count */
			}
		}
		else
		{
			/* check for multi-character commands and handle.
			*/
			if ( cc == 'm')
			{
				move_no_pickup = TRUE ;
				cc = ttgetch();
			}
			if ( yrepcount > 0 )
				--yrepcount;
			return(lastok = cc);
		}
	}
}
예제 #10
0
파일: scores.c 프로젝트: JamesWR/Larn
void
died (int x)
{
  int f, win;
  /*char ch, *mod;
     time_t zzz; */

  if (cdesc[LIFEPROT] > 0)	/* if life protection */
    {
      switch ((x > 0) ? x : -x)
	{
	case 256:
	case 257:
	case 262:
	case 263:
	case 265:
	case 266:
	case 267:
	case 268:
	case 269:
	case 271:
	case 282:
	case 284:
	case 285:
	case 300:
	  goto invalid;		/* can't be saved */
	};
      --cdesc[LIFEPROT];
      cdesc[HP] = 1;
      --cdesc[CONSTITUTION];
      cursors ();
      lprcat ("\nYou feel wiiieeeeerrrrrd all over! ");
      lflush ();
      nap (NAPTIME);
      return;			/* only case where died() returns */
    }

  cursors ();
  lprcat ("\nPress any key to continue. ");
  ttgetch ();

invalid:
  /*clearvt100(); */
  lflush ();
  f = 0;

  /* if we are not to display the scores */
  if (x < 0)
    {
      f++;
      x = -x;
    }

  /* for quick exit or saved game */
  if ((x == 300) || (x == 257))
    {
      clearvt100 ();
      exit (EXIT_SUCCESS);
    }

  if (x == 263)
    win = 1;
  else
    win = 0;

  cdesc[GOLD] += cdesc[BANKACCOUNT];
  cdesc[BANKACCOUNT] = 0;

  /*  now enter the player at the end of the scoreboard */
  newscore (cdesc[GOLD], logname, x, win);
  diedsub (x);			/* print out the score line */
  lflush ();

  set_score_output ();
  if ((wizard == 0) && (cdesc[GOLD] > 0))	/*  wizards can't score     */
    {
      /*if (lappend(logfile)<0)
         {
         if (lcreat(logfile)<0) {
         lcreat((char*)0);
         lprcat("\nCan't open record file:  I can't post your score.\n");
         sncbr();
         resetscroll();
         lflush();
         clearvt100();
         exit(EXIT_SUCCESS);
         }
         _chmod(logfile,0666);
         }
         strcpy(logg.who,logname);
         logg.score = cdesc[GOLD];  
         logg.diff = cdesc[HARDGAME];
         if (x < 256) {
         ch = *monster[x].name;
         if (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
         mod="an";
         else
         mod="a";
         sprintf(logg.what,"killed by %s %s",mod,monster[x].name);
         }
         else sprintf(logg.what,"%s",whydead[x - 256]);
         logg.cavelev=level;
         time(&zzz);
         logg.diedtime=zzz;
         #ifdef EXTRA
         logg.lev=cdesc[LEVEL];          logg.ac=cdesc[AC];
         logg.hpmax=cdesc[HPMAX];        logg.hp=cdesc[HP];
         logg.elapsedtime=(zzz-initialtime+59)/60;
         logg.usage=(10000*i)/(zzz-initialtime);
         logg.bytin=cdesc[BYTESIN];      logg.bytout=cdesc[BYTESOUT];
         logg.moves=cdesc[MOVESMADE];    logg.spused=cdesc[SPELLSCAST];
         logg.killed=cdesc[MONSTKILLED];
         #endif
         lwrite((char*)&logg,sizeof(struct log_fmt));
         lwclose(); */

      /*  now for the scoreboard maintenance -- not for a suspended game  */
      if (x != 257)
	{
	  if (sortboard ())
	    scorerror = writeboard ();
	}
    }
  if ((x == 256) || (x == 257) || (f != 0))
    {
      clearvt100 ();
      exit (EXIT_SUCCESS);
    }
  if (scorerror == 0)
    {
      lflush ();
      clear ();
      resetscroll ();
      showscores ();		/* if we updated the scoreboard */
      cursors ();
      lprcat ("\nPress any key to exit. ");
      scbr ();
      ttgetch ();
    }
  clearvt100 ();
  exit (EXIT_SUCCESS);
}
예제 #11
0
파일: main.c 프로젝트: iarna/joe-editor
int edloop(int flg)
{
	int term = 0;
	int ret = 0;

	if (flg) {
		if (maint->curwin->watom->what == TYPETW)
			return 0;
		else
			maint->curwin->notify = &term;
	}
	while (!leave && (!flg || !term)) {
		W *w;
		MACRO *m;
		BW *bw;
		int c;
		int auto_off = 0;
		int word_off = 0;
		int spaces_off = 0;

		if (exmsg && !flg) {
			vsrm(exmsg);
			exmsg = NULL;
		}
		edupd(1);
		if (!ahead && !have)
			ahead = 1;
		if (ungot) {
			c = ungotc;
			ungot = 0;
		} else
			c = ttgetch();

		/* Clear temporary messages */
		w = maint->curwin;
		do {
			if (w->y != -1) {
				msgclr(w);
			}
			w = (W *) (w->link.next);
		} while (w != maint->curwin);

		if (!ahead && c == 10)
			c = 13;

		more_no_auto:

		/* Use special kbd if we're handing data to a shell window */
		bw = (BW *)maint->curwin->object;
		if (shell_kbd && (maint->curwin->watom->what & TYPETW) && bw->b->pid && !bw->b->vt && piseof(bw->cursor))
			m = dokey(shell_kbd, c);
		else if ((maint->curwin->watom->what & TYPETW) && bw->b->pid && bw->b->vt && bw->cursor->byte == bw->b->vt->vtcur->byte)
			m = dokey(bw->b->vt->kbd, c);
		else
			m = dokey(maint->curwin->kbd, c);

		/* leading part of backtick hack... */
		/* should only do this if backtick is uquote, but you're not likely to get quick typeahead with ESC ' as uquote */
		if (pastehack && m && m->cmd && m->cmd->func == uquote && ttcheck()) {
			m = type_backtick;
		}

		/* disable autoindent if it looks like a mouse paste... */
		if (pastehack && m && m->cmd && (m->cmd->func == utype || m->cmd->func == urtn) && (maint->curwin->watom->what & TYPETW) &&
		    (bw->o.autoindent || bw->o.wordwrap || bw->o.spaces) && ttcheck()) {
			auto_off = bw->o.autoindent;
			bw->o.autoindent = 0;
			word_off = bw->o.wordwrap;
			bw->o.wordwrap = 0;
			spaces_off = bw->o.spaces;
			bw->o.spaces = 0;
		}

		if (maint->curwin->main && maint->curwin->main != maint->curwin) {
			ptrdiff_t x = maint->curwin->kbd->x;

			maint->curwin->main->kbd->x = x;
			if (x)
				maint->curwin->main->kbd->seq[x - 1] = maint->curwin->kbd->seq[x - 1];
		}
		if (!m) {
			m = timer_play();
			c = NO_MORE_DATA;
		}
		if (m)
			ret = exemac(m, c);

		/* trailing part of backtick hack... */
		/* for case where ` is very last character of pasted block */
		while (pastehack && !leave && (!flg || !term) && m && (m == type_backtick || (m->cmd && (m->cmd->func == utype || m->cmd->func == urtn))) && ttcheck() && havec == '`') {
			ttgetch();
			ret = exemac(type_backtick, NO_MORE_DATA);
		}

		/* trailing part of disabled autoindent */
		if (pastehack && !leave && (!flg || !term) && m && (m == type_backtick || (m->cmd && (m->cmd->func == utype || m->cmd->func == urtn))) && ttcheck()) {
			if (ungot) {
				c = ungotc;
				ungot = 0;
			} else
				c = ttgetch();
			goto more_no_auto;
		}

		/* Restore modes */
		if (!leave && maint->curwin->watom->what & TYPETW) {
			bw = (BW *)maint->curwin->object;

			if (auto_off) {
				auto_off = 0;
				bw->o.autoindent = 1;
			}

			if (word_off) {
				word_off = 0;
				bw->o.wordwrap = 1;
			}

			if (spaces_off) {
				spaces_off = 0;
				bw->o.spaces = 1;
			}
		}

	}

	if (term == -1)
		return -1;
	else
		return ret;
}