Pick a random race subject to any rolenum/gendnum/alignnum constraints. If pickhow == PICK_RIGID a race is returned only if there is a single possibility. */
| 1078 | If pickhow == PICK_RIGID a race is returned only if there is |
| 1079 | a single possibility. */ |
| 1080 | int |
| 1081 | pick_race(int rolenum, int gendnum, int alignnum, int pickhow) |
| 1082 | { |
| 1083 | int i; |
| 1084 | int races_ok = 0; |
| 1085 | |
| 1086 | for (i = 0; i < SIZE(races) - 1; i++) { |
| 1087 | if (ok_race(rolenum, i, gendnum, alignnum)) |
| 1088 | races_ok++; |
| 1089 | } |
| 1090 | if (races_ok == 0 || (races_ok > 1 && pickhow == PICK_RIGID)) |
| 1091 | return ROLE_NONE; |
| 1092 | races_ok = rn2(races_ok); |
| 1093 | for (i = 0; i < SIZE(races) - 1; i++) { |
| 1094 | if (ok_race(rolenum, i, gendnum, alignnum)) { |
| 1095 | if (races_ok == 0) |
| 1096 | return i; |
| 1097 | else |
| 1098 | races_ok--; |
| 1099 | } |
| 1100 | } |
| 1101 | return ROLE_NONE; |
| 1102 | } |
| 1103 | |
| 1104 | /* is gendnum compatible with any rolenum/racenum/alignnum constraints? */ |
| 1105 | /* gender and alignment are not comparable (and also not constrainable) */ |
no test coverage detected