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

Method passes

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

Source from the content-addressed store, hash-verified

36{
37
38 @Override
39 public int passes(final Prerequisite prereq, final PlayerCharacter character, 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("PreFeat.error", prereq.toString()), exceptn); //$NON-NLS-1$
53 }
54
55 CharacterDisplay display = character.getDisplay();
56 if (display.hasEquipment())
57 {
58
59 String targetEquip = prereq.getKey();
60 for (Equipment eq : display.getEquippedEquipmentSet())
61 {
62 if (targetEquip.startsWith("WIELDCATEGORY=") || targetEquip.startsWith("WIELDCATEGORY."))
63 {
64 final WieldCategory wCat = eq.getEffectiveWieldCategory(character);
65 if ((wCat != null) && wCat.getKeyName().equalsIgnoreCase(targetEquip.substring(14)))
66 {
67 ++runningTotal;
68 break;
69 }
70 }
71 else if (targetEquip.startsWith("TYPE=") || targetEquip.startsWith("TYPE.")) //$NON-NLS-1$ //$NON-NLS-2$
72 {
73 StringTokenizer tok = new StringTokenizer(targetEquip.substring(5).toUpperCase(), ".");
74 boolean match = false;
75 if (tok.hasMoreTokens())
76 {
77 match = true;
78 }
79 //
80 // Must match all listed types in order to qualify
81 //
82 while (tok.hasMoreTokens())
83 {
84 final String type = tok.nextToken();
85 if (!eq.isType(type))
86 {
87 match = false;
88 break;
89 }
90 }
91 if (match)
92 {
93 ++runningTotal;
94 break;
95 }

Callers

nothing calls this directly

Calls 15

getFormattedStringMethod · 0.95
hasEquipmentMethod · 0.95
getKeyNameMethod · 0.95
parseIntMethod · 0.80
getOperandMethod · 0.80
equalsIgnoreCaseMethod · 0.80
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
countedTotalMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected