| 913 | } |
| 914 | |
| 915 | int |
| 916 | randalign(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 | |
| 942 | int |
| 943 | str2align(const char *str) |
no test coverage detected