MCPcopy Create free account
hub / github.com/PCGen/pcgen / randomize

Method randomize

code/src/java/pcgen/core/BioSet.java:154–203  ·  view source on GitHub ↗

Randomizes the values of the passed in attributes. @param randomizeStr .-delimited list of attributes to randomize. (AGE.HT.WT.EYES.HAIR.SKIN are the possible values.) @param pc The Player Character

(final String randomizeStr, final PlayerCharacter pc)

Source from the content-addressed store, hash-verified

152 * @param pc The Player Character
153 */
154 public void randomize(final String randomizeStr, final PlayerCharacter pc)
155 {
156 if ((pc == null) || (pc.getRace() == null))
157 {
158 return;
159 }
160
161 final List<String> ranList = new ArrayList<>();
162 final StringTokenizer lineTok = new StringTokenizer(randomizeStr, ".", false);
163
164 while (lineTok.hasMoreTokens())
165 {
166 final String aString = lineTok.nextToken();
167
168 if (aString.startsWith("AGECAT"))
169 {
170 generateAge(Integer.parseInt(aString.substring(6)), false, pc);
171 }
172 else
173 {
174 ranList.add(aString);
175 }
176 }
177
178 if (ranList.contains("AGE"))
179 {
180 generateAge(0, true, pc);
181 }
182
183 if (ranList.contains("HT") || ranList.contains("WT"))
184 {
185 generateHeightWeight(pc);
186 }
187
188 if (ranList.contains("EYES"))
189 {
190 pc.setEyeColor(generateBioValue("EYES", pc));
191 }
192
193 if (ranList.contains("HAIR"))
194 {
195 HairColorCompat.setCurrentHairColor(pc.getCharID(), generateBioValue("HAIR", pc));
196 }
197
198 if (ranList.contains("SKIN"))
199 {
200 ChannelUtilities.setControlledChannel(pc.getCharID(),
201 CControl.SKINCOLORINPUT, generateBioValue("SKINTONE", pc));
202 }
203 }
204
205 @Override
206 public String toString()

Callers 4

testRandomizeMethod · 0.95
setAgeCategoryMethod · 0.80
dataAddedMethod · 0.80
recalcSkillPointModMethod · 0.80

Calls 13

generateAgeMethod · 0.95
generateHeightWeightMethod · 0.95
generateBioValueMethod · 0.95
setCurrentHairColorMethod · 0.95
setControlledChannelMethod · 0.95
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
parseIntMethod · 0.80
addMethod · 0.65
containsMethod · 0.65
setEyeColorMethod · 0.65
getCharIDMethod · 0.65

Tested by 1

testRandomizeMethod · 0.76