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

Method passes

code/src/java/plugin/pretokens/test/PreSkillTester.java:46–194  ·  view source on GitHub ↗
(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source)

Source from the content-addressed store, hash-verified

44{
45
46 @SuppressWarnings("unused")
47 @Override
48 public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source)
49 {
50 CharacterDisplay display = character.getDisplay();
51 final int requiredRanks = Integer.parseInt(prereq.getOperand());
52 // Compute the skill name from the Prerequisite
53 String requiredSkillKey = prereq.getKey().toUpperCase();
54 if (prereq.getSubKey() != null)
55 {
56 requiredSkillKey += " (" + prereq.getSubKey().toUpperCase() + ')'; //$NON-NLS-1$
57 }
58 final boolean isType =
59 (requiredSkillKey.startsWith("TYPE.")
60 || requiredSkillKey.startsWith("TYPE=")); //$NON-NLS-1$ //$NON-NLS-2$
61 if (isType)
62 {
63 requiredSkillKey = requiredSkillKey.substring(5);
64 }
65 final String skillKey = requiredSkillKey;
66 // Now locate all instances of this skillname and test them
67 final int percentageSignPosition = skillKey.lastIndexOf('%');
68 HashMap<Skill, Set<Skill>> serveAsSkills = new HashMap<>();
69 Set<Skill> imitators = new HashSet<>();
70 this.getImitators(serveAsSkills, imitators, display);
71 int runningTotal = 0;
72 boolean foundMatch = false;
73 boolean foundSkill = false;
74 for (Skill aSkill : display.getSkillSet())
75 {
76 final String aSkillKey = aSkill.getKeyName().toUpperCase();
77 if (isType)
78 {
79 if (percentageSignPosition >= 0)
80 {
81 foundMatch = matchesTypeWildCard(skillKey, percentageSignPosition, foundSkill, aSkill);
82 foundSkill = foundMatch;
83 runningTotal = getRunningTotal(aSkill, character, prereq, foundMatch, runningTotal, requiredRanks);
84 }
85 else if (aSkill.isType(skillKey))
86 {
87 foundMatch = true;
88 foundSkill = true;
89 runningTotal = getRunningTotal(aSkill, character, prereq, true, runningTotal, requiredRanks);
90 }
91 // If there wasn't a match, then check other skills of the type
92 if (runningTotal == 0)
93 {
94 foundMatch = false;
95 }
96 }
97 else if (aSkillKey.equals(skillKey) || ((percentageSignPosition >= 0)
98 && aSkillKey.startsWith(skillKey.substring(0, percentageSignPosition))))
99 {
100 foundMatch = true;
101 foundSkill = true;
102 runningTotal = getRunningTotal(aSkill, character, prereq, true, runningTotal, requiredRanks);
103 }

Callers

nothing calls this directly

Calls 15

getImitatorsMethod · 0.95
getSkillSetMethod · 0.95
matchesTypeWildCardMethod · 0.95
getRunningTotalMethod · 0.95
parseIntMethod · 0.80
getOperandMethod · 0.80
getSubKeyMethod · 0.80
isCountMultiplesMethod · 0.80
isTotalValuesMethod · 0.80
equalsIgnoreCaseMethod · 0.80
getTrueTypeListMethod · 0.80
countedTotalMethod · 0.80

Tested by

no test coverage detected