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

Function randalign

src/role.c:915–940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915int
916randalign(int rolenum, int racenum)
917{
918 int i, n = 0;
919
920 /* Count the number of valid alignments */
921 for (i = 0; i < ROLE_ALIGNS; i++)
922 if (roles[rolenum].allow & races[racenum].allow & aligns[i].allow
923 & ROLE_ALIGNMASK)
924 n++;
925
926 /* Pick a random alignment */
927 if (n)
928 n = rn2(n);
929 for (i = 0; i < ROLE_ALIGNS; i++)
930 if (roles[rolenum].allow & races[racenum].allow & aligns[i].allow
931 & ROLE_ALIGNMASK) {
932 if (n)
933 n--;
934 else
935 return i;
936 }
937
938 /* This role/race has no permitted alignments? */
939 return rn2(ROLE_ALIGNS);
940}
941
942int
943str2align(const char *str)

Callers 11

mswin_player_selectionFunction · 0.85
curses_choose_characterFunction · 0.85
amii_player_selectionFunction · 0.85
role_initFunction · 0.85
genl_player_setupFunction · 0.85
gnome_player_selectionFunction · 0.85
Gem_player_selectionFunction · 0.85
mswin_player_selectionFunction · 0.85
mac_asknameFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected