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

Function pick_align

src/role.c:1210–1232  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1208 If pickhow == PICK_RIGID an alignment is returned only if there is
1209 a single possibility. */
1210int
1211pick_align(int rolenum, int racenum, int gendnum, int pickhow)
1212{
1213 int i;
1214 int aligns_ok = 0;
1215
1216 for (i = 0; i < ROLE_ALIGNS; i++) {
1217 if (ok_align(rolenum, racenum, gendnum, i))
1218 aligns_ok++;
1219 }
1220 if (aligns_ok == 0 || (aligns_ok > 1 && pickhow == PICK_RIGID))
1221 return ROLE_NONE;
1222 aligns_ok = rn2(aligns_ok);
1223 for (i = 0; i < ROLE_ALIGNS; i++) {
1224 if (ok_align(rolenum, racenum, gendnum, i)) {
1225 if (aligns_ok == 0)
1226 return i;
1227 else
1228 aligns_ok--;
1229 }
1230 }
1231 return ROLE_NONE;
1232}
1233
1234void
1235rigid_role_checks(void)

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_alignFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected