📄 english.c
字号:
switch (CLASS(word)) { case MOTION: case ACTION: case MISC: words[wdx--] = 0; break; case NOUN: case ADJACTIVE: break; case PREPOSITION: case CONJUNCTION: rspeak(confuz()); return (FALSE); default: bug(33); } break; default: bug(33); } word = words[++wdx]; if (word < 0) { if (pct(50)) printf("I don't understand the word %s?\n", txt[wdx]); else printf("Mumble ? %s\n", txt[wdx]); words[wdx+1] = 0; return (FALSE); } type = CLASS(word); if (type == NOUN) { /* It's not the first: Make sure he included a comma or 'and'. Differenctiate between direct & indirect objects. Check for special case of multiple ofjects: 'feed bear honey' or 'throw troll nugget'. */ if ((pflag ? iobx : objx) && CLASS(words[wdx - 1]) != CONJUNCTION) { val = VAL(verbs[vrbx]); if (!living(objs[objx]) || (val != THROW && val != FEED)) { rspeak(confuz()); return (FALSE); } iobx++; iobjs[iobx] = objs[objx]; objs[objx] = 0; objx++; } } } while (word); if (verbs[1] == 0) { if (objs[1] == 0) { rspeak(confuz()); clrlin(); } else if (objs[2]) printf("What do you want to do with them?\n"); else printf("What do you want to do with %s?\n", otxt[1]); return (FALSE); } else if (objx > 1 && iobx > 1) { rspeak(confuz()); return (FALSE); } return (TRUE);}/* retrieve input line (max INPUTBUFLEN chars), convert to lower case & rescan for first two words (max. WORDSIZE-1 chars).*/static void getwords(){ static int wdx = 0; int i, term_loc; char terminator; if (*cindex == '\0') { while (!*ask("\n> ", buffer, sizeof(buffer))) ; for (cindex = buffer; *cindex; cindex++) if (isupper(*cindex)) *cindex = tolower(*cindex); cindex = buffer; } wdx = 0; buffer[sizeof(buffer)-1] = '\0'; for (i = 0; i < MAXWORDS; i++) { txt[i] = &buffer[sizeof(buffer)-1]; words[i] = 0; } do { while (*cindex == ' ') cindex++; txt[wdx] = cindex; term_loc = strcspn(cindex, " ,.;\n"); cindex += term_loc; terminator = *cindex; *cindex++ = '\0'; if ((strcmp(txt[wdx], "a") != 0) && (strcmp(txt[wdx], "the") != 0) && (strcmp(txt[wdx], "an") != 0)) { words[wdx] = vocab(txt[wdx], 0); wdx++; } if (terminator == ',') { txt[wdx] = "and"; words[wdx] = vocab(txt[wdx], 0); wdx++; } } while ((terminator != ';') && (terminator != '.') && (terminator != '\0') && (terminator != '\n')); if (terminator == '\0') cindex--; return;}/* CLRIN, clears out all surrent syntax args in preparation for * new input line */static void clrlin(){ int i; for (i = 0; i < MAXWORDS; i++) { verbs[i] = 0; vtxt[i] = &buffer[sizeof(buffer)-1]; } for (i = 0; i < MAXITEMS; i++) { objs[i] = 0; otxt[i] = &buffer[sizeof(buffer)-1]; iobjs[i] = 0; iotxt[i] = &buffer[sizeof(buffer)-1]; } vrbx = 0; objx = 0; iobx = 0; prep = 0;}/* Routine to process an object.*/static void doobj(object)int *object;{ int msg; if (holding(*object)) return; if (blind()) { printf("I see no %s here.\n", txt[wdx]); *object = 0; return; } /* Is object here? if so, transitive */ if (g.fixed[*object] == g.loc || athand(*object)) return; else if (here(*object)) { msg = plural(*object) ? 373 : 335; *object = 0; rspeak(msg); } /* Did he give grate as destination? */ else if (*object == GRATE) { if (g.loc == 1 || g.loc == 4 || g.loc == 7) { verbs[1] = DEPRESSION; vrbx = 1; return; } else if (g.loc > 9 && g.loc < 15) { verbs[1] = ENTRANCE; vrbx = 1; return; } } /* Is it a dwarf he is after? */ else if (dcheck() && g.dflag >= 2) { *object = DWARF; } /* Is he trying to get/use a liquid? */ else if (liqloc(g.loc) == *object || (liq(BOTTLE) == *object && athand(BOTTLE)) || (liq(CASK) == *object && athand(CASK))); else if (*object == PLANT && at(PLANT2) && g.prop[PLANT2] == 0) { *object = PLANT2; } else if (*object == ROCKS && at(CARVNG)) { *object = CARVNG; } /* Is he trying to grab a knife? */ else if (*object == KNIFE && g.knfloc == g.loc) { rspeak(116); g.knfloc = -1; } /* Is he trying to get at dynamite? */ else if (*object == ROD && athand(ROD2)) { *object = ROD2; } else if (*object == DOOR && (at(SAFE) || at(TDOOR) || at(TDOOR2) || at(PDOOR))) { if (at(TDOOR2)) *object = TDOOR2; else if (at(PDOOR)) *object = PDOOR; else if (at(SAFE)) *object = SAFE; else *object = TDOOR; } else if (*object == BOOK && athand(BOOK2)) { *object = BOOK2; } else if (!(verbs[vrbx] == FIND || verbs[vrbx] == INVENTORY)) { *object = 0; printf("I see no %s here.\n", txt[wdx]); } return;}static boolean doiobj(){ char dk[INPUTBUFLEN], dkk[INPUTBUFLEN]; int kk; boolean ok; /* checks object is valid for this preposition */ ok = TRUE; word = VAL(word); if (word != ALL) { doobj(&word); if (word > 0) { iobjs[++iobx] = word; iotxt[iobx] = txt[wdx]; } else ok = FALSE; } kk = abs(ptab[vrbkey]) / 1000; if (kk == prep) { /* preprosition is valid with this verb now check object of preprosition */ if (word == 0 || CLASS(word) == CONJUNCTION) { /* no object following prepresition: check special cases */ pflag = FALSE; strcpy(dk, txt[--wdx]); strcpy(dkk, vtxt[vrbx]); ok = FALSE; if ((strcmp(dk, "on") == 0 || strcmp(dk, "off") == 0) && (strcmp(dkk, "turn") == 0 || objs[objx] == LAMP)) ok = TRUE; if (strcmp(dkk, "take") == 0 || strcmp(dkk, "put") == 0) ok = TRUE; if (strcmp(dk, "up") == 0 && strcmp(dkk, "pick") == 0) ok = TRUE; if (strcmp(dk, "down") == 0 && (strcmp(dkk, "put") == 0 || verbs[vrbx] == THROW) ) ok = TRUE; } else { /* object follows preposition See if it's plausible. */ kk = abs(ptab[vrbkey]) % 1000; if (kk == word && kk == ALL) { if (!do_scoop_up()) return (FALSE); } else if (!(kk == word || kk == 999)) { vrbkey++; ok = ptab[vrbkey - 1] < 0 ? FALSE : TRUE; } } } return (ok);}static boolean do_scoop_up(){ int i, val; val = VAL(verbs[vrbx]); if (val == DROP || val == PUT || val == LEAVE) { for (i = 1; i < MAXOBJ; i++) { if (!athand(i) || g.fixed[i]) continue; if (i > WATER && i <= WINE + 1) continue; if (toting(i)) { objs[++objx] = i; otxt[objx] = "BUG???"; if (objx >= 44) break; } } } if (val == TAKE || val == PICK || val == GET) { if (blind()) { rspeak(357); return (FALSE); } else { for (i = 1; i < MAXOBJ; i++) { if (!athand(i) || g.fixed[i]) continue; if (i > WATER && i <= WINE + 1) continue; if (!toting(i)) { objs[++objx] = i; otxt[objx] = "BUG???"; if (objx >= 44) break; } } } } return (TRUE);}static boolean check_next(){ word = words[wdx + 1]; if (word > 0) return (TRUE); else if (word == 0) rspeak(confuz()); else { if (pct(50)) printf("I don't understand the word %s?\n", txt[wdx]); else printf("Mumble ? %s\n", txt[wdx]); words[wdx+1] = 0; } return (FALSE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -