Beispiel #1
0
int main(int argc, char *argv[]) {
  int rflag; /* user restore request option	*/

  rflag = 0;
  dbugflg = 0;
  while (--argc > 0) {
    ++argv;
    if (**argv != '-') break;
    switch (tolower(argv[0][1])) {
      case 'r':
        ++rflag;
        continue;
      case 'd':
        ++dbugflg;
        continue;
      default:
        printf("unknown flag: %c\n", argv[0][1]);
        continue;
    }                           /* switch	*/
  }                             /* while	*/
  if (dbugflg < 2) dbugflg = 0; /* must request three times	*/
  opentxt();
  initplay();
  if (rflag)
    restore();
  else if (yes(65, 1, 0))
    limit = 1000;
  else
    limit = 330;
  saveflg = 0;
  srand(511); /* seed random	*/
  while (!saveflg) turn();
  if (saveflg) saveadv();
#ifndef EMBED
  fclose(fd1);
  fclose(fd2);
  fclose(fd3);
  fclose(fd4);
#endif
  return (0); /* exit = ok	*/
}
/*
  Routines to process intransitive verbs
*/
void itverb()
{
    int i;

    newtravel = FALSE;
    switch (verb) {
    case DROP:
    case SAY:
    case WAVE:
    case CALM:
    case RUB:
    case THROW:
    case FIND:
    case FEED:
    case BREAK:
    case WAKE:
    case WEAR:
    case HIT:
    case DIAL:
    case PLAY:
    case PICK:
    case PUT:
    case TURN:		needobj();	break;
    case TAKE:
    case YANK:
    case GET:
    case INSRT:
    case REMOVE:
    case BURN:		ivtake();	break;
    case OPEN:
    case CLOSE:
    case LOCK:
    case UNLOCK:	ivopen();	break;
    case NOTHING:	rspeak(54);	break;
    case ON:
    case OFF:		trverb();	break;
    case WALK:		actspk(verb);	break;
    case KILL:		ivkill();	break;
    case POUR:		ivpour();	break;
    case EAT:		iveat();	break;
    case DRINK:		ivdrink();	break;
    case QUIT:		ivquit();	break;
    case INVENTORY:	inventory();	break;
    case FILL:		ivfill();	break;
    case BLAST:		ivblast();	break;
    case SCORE:		score(TRUE);	break;
    case FOO:		ivfoo();	break;
    case BRIEF:		ivbrief();	break;
    case READ:		ivread();	break;
    case SUSPEND:
	if (g.closing)
	    rspeak(378);
	else
	    saveadv("advent.sav");
	break;
    case RESTORE:	restore("advent.sav");	break;
    case ANSWER:
	if ((g.loc != 189) || (g.prop[PHONE] != 0))
	    needobj();
	else {
	    object = PHONE;
	    itverb();
	}
	break;
    case BLOW:		rspeak(268);	break;
	/* Action verb 'LEAVE' has no object */
    case LEAVE:		bug(29);	break;
	/* Call if no phone is handy, yell. */
    case YELL:
	if (!here(PHONE))
	    needobj();
	else if (!g.closed)
	    rspeak(271);
	else {
	    rspeak(283);
	    normend();
	}
	break;
	/* Health. give him a diagnosis. */
    case HEALTH:
	if (g.numdie)
	    fprintf(stdout, "You have been killed %d times otherwise\n",
		    g.numdie);
	if (g.health >= 95) {
	    if (pct(50))
		rspeak(348);
	    else
		rspeak(349);
	} else {
	    fprintf(stdout,
	       "Your health rating is %2d out of a possible 100.\n",
		    g.health);
	    rspeak(381 + (100 - g.health) / 20);
	}
	break;
    case LOOK:		ivlook();	break;
    case COMBO:
	if (at(SAFE))
	    ivcombo();
	break;
    case SWEEP:
	/* Dust/sweep */
	if (!at(CARVNG) || !athand(BRUSH) || (g.prop[CARVNG] == 1))
	    rspeak(342);
	else {
	    g.prop[CARVNG] = 1;
	    rspeak(363);
	    rspeak(372);
	}
	break;
    case TERSE:
	/* Terse/unterse. supress all long_form descriptions. */
	g.terse = !g.terse;
	g.detail = 3;
	rspeak(54);
	break;
    case WIZ:
	is_wiz = !is_wiz;
    case MAP:
	rspeak(54);
	break;
    case GATE:
	if (is_wiz) {
	    static char buf[INPUTBUFLEN];
	    sscanf(ask("Location ? ", buf, sizeof(buf)), "%d", &g.loc);
	}
	rspeak(54);
	break;
    case PIRLOC:
	if (is_wiz) {
	    fprintf(stdout, "The dwarfs are at locations:\n");
	    for (i = 1; i < DWARFMAX; i++)
		fprintf(stdout, "  %4d", g.dloc[i]);
	    fprintf(stdout, "\nThe pirate is at location %4d\n",
		    g.dloc[DWARFMAX]);
	}
	rspeak(54);
	break;
    default:
	printf("This intransitive not implemented yet\n");
    }
    return;
}