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

Function pick_gend

src/role.c:1145–1167  ·  view source on GitHub ↗

pick a random gender subject to any rolenum/racenum/alignnum constraints */ gender and alignment are not comparable (and also not constrainable) */ If pickhow == PICK_RIGID a gender is returned only if there is */ a single possibility */

Source from the content-addressed store, hash-verified

1143/* If pickhow == PICK_RIGID a gender is returned only if there is */
1144/* a single possibility */
1145int
1146pick_gend(int rolenum, int racenum, int alignnum, int pickhow)
1147{
1148 int i;
1149 int gends_ok = 0;
1150
1151 for (i = 0; i < ROLE_GENDERS; i++) {
1152 if (ok_gend(rolenum, racenum, i, alignnum))
1153 gends_ok++;
1154 }
1155 if (gends_ok == 0 || (gends_ok > 1 && pickhow == PICK_RIGID))
1156 return ROLE_NONE;
1157 gends_ok = rn2(gends_ok);
1158 for (i = 0; i < ROLE_GENDERS; i++) {
1159 if (ok_gend(rolenum, racenum, i, alignnum)) {
1160 if (gends_ok == 0)
1161 return i;
1162 else
1163 gends_ok--;
1164 }
1165 }
1166 return ROLE_NONE;
1167}
1168
1169/* is alignnum compatible with any rolenum/racenum/gendnum constraints? */
1170/* alignment and gender are not comparable (and also not constrainable) */

Callers 13

plselAdjustSelectionsFunction · 0.85
mswin_player_selectionFunction · 0.85
curses_choose_characterFunction · 0.85
winmisc.cFile · 0.85
amii_player_selectionFunction · 0.85
rigid_role_checksFunction · 0.85
genl_player_setupFunction · 0.85
gnome_player_selectionFunction · 0.85
Gem_player_selectionFunction · 0.85
plselFinalSelectionFunction · 0.85
mswin_player_selectionFunction · 0.85

Calls 2

ok_gendFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected