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

Method passes

code/src/java/plugin/pretokens/test/PreKitTester.java:38–79  ·  view source on GitHub ↗
(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source)

Source from the content-addressed store, hash-verified

36 private static final Class<Kit> KIT_CLASS = Kit.class;
37
38 @Override
39 public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source)
40 throws PrerequisiteException
41 {
42 int runningTotal = 0;
43
44 final int number;
45 try
46 {
47 number = Integer.parseInt(prereq.getOperand());
48 }
49 catch (NumberFormatException exceptn)
50 {
51 throw new PrerequisiteException(
52 LanguageBundle.getFormattedString("PreKit.error", prereq.toString()), exceptn); //$NON-NLS-1$
53 }
54
55 String kitKey = prereq.getKey().toUpperCase();
56 final int wildCard = kitKey.indexOf('%');
57 //handle wildcards (always assume they end the line)
58 if (wildCard >= 0)
59 {
60 kitKey = kitKey.substring(0, wildCard);
61 for (Kit kit : display.getKitInfo())
62 {
63 if (kit.getKeyName().toUpperCase().startsWith(kitKey))
64 {
65 runningTotal++;
66 }
67 }
68 }
69 else
70 {
71 Kit kit = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(KIT_CLASS, kitKey);
72 if (display.hasKit(kit))
73 {
74 runningTotal++;
75 }
76 }
77 runningTotal = prereq.getOperator().compare(runningTotal, number);
78 return countedTotal(prereq, runningTotal);
79 }
80
81 /**
82 * Get the type of prerequisite handled by this token.

Callers

nothing calls this directly

Calls 15

getFormattedStringMethod · 0.95
getContextMethod · 0.95
parseIntMethod · 0.80
getOperandMethod · 0.80
hasKitMethod · 0.80
countedTotalMethod · 0.80
toStringMethod · 0.65
getKeyMethod · 0.65
indexOfMethod · 0.65
getKeyNameMethod · 0.65
getReferenceContextMethod · 0.65

Tested by

no test coverage detected