MCPcopy Create free account
hub / github.com/NetHack/NetHack / do_class_genocide

Function do_class_genocide

src/read.c:2637–2820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2635}
2636
2637staticfn void
2638do_class_genocide(void)
2639{
2640 int i, j, immunecnt, gonecnt, goodcnt, class, feel_dead = 0;
2641 int ll_done = 0;
2642 char buf[BUFSZ], promptbuf[QBUFSZ];
2643 boolean gameover = FALSE; /* true iff killed self */
2644
2645 buf[0] = '\0'; /* for EDIT_GETLIN */
2646 for (j = 0; ; j++) {
2647 if (j >= 5) {
2648 pline1(thats_enough_tries);
2649 return;
2650 }
2651 Strcpy(promptbuf, "What class of monsters do you want to genocide?");
2652 if (j > 0)
2653 Snprintf(eos(promptbuf), sizeof promptbuf - strlen(promptbuf),
2654 " [enter %s]",
2655 iflags.cmdassist
2656 ? "the symbol or name representing a class, or '?'"
2657 : "'?' to see previous genocides");
2658 getlin(promptbuf, buf);
2659 (void) mungspaces(buf);
2660 /* avoid 'that does not represent any monster' for empty input */
2661 if (!*buf) {
2662 pline("%s.", (j + 1 < 5)
2663 ? "Type letter (or punctuation)"
2664 " or name used for a class of monsters or 'none'"
2665 /* next iteration gives "that's enough tries"
2666 so don't suggest typing anything this time */
2667 : "No class of monsters specified");
2668 continue; /* try again */
2669 }
2670 /* choosing "none" preserves genocideless conduct */
2671 if (*buf == '\033' || !strcmpi(buf, "none")
2672 || !strcmpi(buf, "'none'") || !strcmpi(buf, "nothing")) {
2673 livelog_printf(LL_GENOCIDE,
2674 "declined to perform class genocide");
2675 return;
2676 }
2677 /* "?" runs #genocided to show existing genocides, then re-prompts;
2678 accept "'?'" too because the prompt's hint shows it that way */
2679 if (!strcmp(buf, "?") || !strcmp(buf, "'?'")) {
2680 list_genocided('g', FALSE);
2681 --j; /* don't count this iteration as one of the tries */
2682 continue;
2683 }
2684
2685 class = name_to_monclass(buf, (int *) 0);
2686 if (class == 0 && (i = name_to_mon(buf, (int *) 0)) != NON_PM)
2687 class = mons[i].mlet;
2688 immunecnt = gonecnt = goodcnt = 0;
2689 for (i = LOW_PM; i < NUMMONS; i++) {
2690 if (mons[i].mlet == class) {
2691 if (!(mons[i].geno & G_GENO))
2692 immunecnt++;
2693 else if (svm.mvitals[i].mvflags & G_GENOD)
2694 gonecnt++;

Callers 1

seffect_genocideFunction · 0.85

Calls 15

eosFunction · 0.85
getlinFunction · 0.85
mungspacesFunction · 0.85
livelog_printfFunction · 0.85
list_genocidedFunction · 0.85
name_to_monclassFunction · 0.85
name_to_monFunction · 0.85
YouFunction · 0.85
mongoneFunction · 0.85
makepluralFunction · 0.85
num_genocidesFunction · 0.85
kill_genocided_monstersFunction · 0.85

Tested by

no test coverage detected