| 2823 | #define PLAYER 2 |
| 2824 | #define ONTHRONE 4 |
| 2825 | void |
| 2826 | do_genocide( |
| 2827 | int how) /* 0 = no genocide; create monsters (cursed scroll) |
| 2828 | * 1 = normal genocide |
| 2829 | * 3 = forced genocide of player |
| 2830 | * 5 (4 | 1) = normal genocide from throne */ |
| 2831 | { |
| 2832 | char buf[BUFSZ], realbuf[BUFSZ], promptbuf[QBUFSZ]; |
| 2833 | int i, killplayer = 0; |
| 2834 | int mndx; |
| 2835 | struct permonst *ptr; |
| 2836 | const char *which; |
| 2837 | |
| 2838 | if (how & PLAYER) { |
| 2839 | mndx = u.umonster; /* non-polymorphed mon num */ |
| 2840 | ptr = &mons[mndx]; |
| 2841 | Strcpy(buf, pmname(ptr, Ugender)); |
| 2842 | killplayer++; |
| 2843 | } else { |
| 2844 | buf[0] = '\0'; /* init for EDIT_GETLIN */ |
| 2845 | for (i = 0; ; i++) { |
| 2846 | if (i >= 5) { |
| 2847 | /* cursed effect => no free pass (unless rndmonst() fails) */ |
| 2848 | if (!(how & REALLY) && (ptr = rndmonst()) != 0) |
| 2849 | break; |
| 2850 | |
| 2851 | pline1(thats_enough_tries); |
| 2852 | return; |
| 2853 | } |
| 2854 | Strcpy(promptbuf, |
| 2855 | "What type of monster do you want to genocide?"); |
| 2856 | if (i > 0) |
| 2857 | Snprintf(eos(promptbuf), sizeof promptbuf - strlen(promptbuf), |
| 2858 | " [enter %s]", |
| 2859 | iflags.cmdassist |
| 2860 | ? "the name of a type of monster, or '?'" |
| 2861 | : "'?' to see previous genocides"); |
| 2862 | getlin(promptbuf, buf); |
| 2863 | (void) mungspaces(buf); |
| 2864 | /* avoid 'such creatures do not exist' for empty input */ |
| 2865 | if (!*buf) { |
| 2866 | pline("%s.", (i + 1 < 5) |
| 2867 | ? "Type the name of a type of monster or 'none'" |
| 2868 | /* next iteration gives "that's enough tries" |
| 2869 | so don't suggest typing anything this time */ |
| 2870 | : "No type of monster specified"); |
| 2871 | continue; /* try again */ |
| 2872 | } |
| 2873 | /* choosing "none" preserves genocideless conduct */ |
| 2874 | if (*buf == '\033' || !strcmpi(buf, "none") |
| 2875 | || !strcmpi(buf, "'none'") || !strcmpi(buf, "nothing")) { |
| 2876 | /* ... but no free pass if cursed */ |
| 2877 | if (!(how & REALLY) && (ptr = rndmonst()) != 0) |
| 2878 | break; /* remaining checks don't apply */ |
| 2879 | |
| 2880 | livelog_printf(LL_GENOCIDE, "declined to perform genocide"); |
| 2881 | return; |
| 2882 | } |
no test coverage detected