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

Method passes

code/src/java/pcgen/core/prereq/PrereqHandler.java:179–224  ·  view source on GitHub ↗

Returns true if the character passes the prereq. @param prereq The prerequisite to test. @param aPC The character to test against @param caller The CDOMObject that is calling this method @return true if the character passes the prereq

(final Prerequisite prereq, final PlayerCharacter aPC, final Object caller)

Source from the content-addressed store, hash-verified

177 * @return true if the character passes the prereq
178 */
179 public static boolean passes(final Prerequisite prereq, final PlayerCharacter aPC, final Object caller)
180 {
181 if (aPC == null && prereq.isCharacterRequired())
182 {
183 return true;
184 }
185 final PrerequisiteTestFactory factory = PrerequisiteTestFactory.getInstance();
186 final PrerequisiteTest test = factory.getTest(prereq.getKind());
187
188 if (test == null)
189 {
190 Logging.errorPrintLocalised("PrereqHandler.Unable_to_find_implementation", prereq.toString()); //$NON-NLS-1$
191 return false;
192 }
193
194 final boolean overrideQualify = prereq.isOverrideQualify();
195 boolean autoQualifies = false;
196 int total = 0;
197
198 if (caller instanceof CDOMObject && aPC != null && aPC.checkQualifyList((CDOMObject) caller)
199 && (!overrideQualify))
200 {
201 autoQualifies = true;
202 }
203 if (autoQualifies)
204 {
205 return true;
206 }
207 try
208 {
209 CDOMObject cdomCaller = (caller instanceof CDOMObject) ? (CDOMObject) caller : null;
210 total = test.passes(prereq, aPC, cdomCaller);
211 }
212 catch (PrerequisiteException pe)
213 {
214 Logging.errorPrintLocalised("PrereqHandler.Exception_in_test", pe); //$NON-NLS-1$
215 }
216 catch (Exception e)
217 {
218 final String callerString = (caller != null) ? " for " + String.valueOf(caller) : Constants.EMPTY_STRING;
219
220 Logging.errorPrint("Problem encountered when testing PREREQ " + String.valueOf(prereq) + callerString
221 + ". See following trace for details.", e);
222 }
223 return total > 0;
224 }
225
226 /**
227 *

Callers 15

testPassesMethod · 0.95
testFeatPassesMethod · 0.95
ruleDisabledMethod · 0.95
ruleEnabledMethod · 0.95
test990007_1Method · 0.95
test990007_2Method · 0.95
test990007_3Method · 0.95
test990007_4Method · 0.95
test990007_5Method · 0.95
testBadOperandMethod · 0.95
testBaseMethod · 0.95
testBonusMethod · 0.95

Calls 11

getInstanceMethod · 0.95
getTestMethod · 0.95
errorPrintLocalisedMethod · 0.95
passesMethod · 0.95
errorPrintMethod · 0.95
isCharacterRequiredMethod · 0.80
getKindMethod · 0.80
isOverrideQualifyMethod · 0.80
checkQualifyListMethod · 0.80
toStringMethod · 0.65
valueOfMethod · 0.45

Tested by 15

testPassesMethod · 0.76
testFeatPassesMethod · 0.76
ruleDisabledMethod · 0.76
ruleEnabledMethod · 0.76
test990007_1Method · 0.76
test990007_2Method · 0.76
test990007_3Method · 0.76
test990007_4Method · 0.76
test990007_5Method · 0.76
testBadOperandMethod · 0.76
testBaseMethod · 0.76
testBonusMethod · 0.76