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

Method passes

code/src/java/plugin/pretokens/test/PreFactTester.java:39–78  ·  view source on GitHub ↗
(final Prerequisite prereq, final PlayerCharacter aPC, CDOMObject source)

Source from the content-addressed store, hash-verified

37{
38
39 @Override
40 public int passes(final Prerequisite prereq, final PlayerCharacter aPC, CDOMObject source)
41 throws PrerequisiteException
42 {
43 final int number;
44 try
45 {
46 number = Integer.parseInt(prereq.getOperand());
47 }
48 catch (NumberFormatException exceptn)
49 {
50 throw new PrerequisiteException(
51 LanguageBundle.getFormattedString("PreFact.error", prereq.toString()), exceptn); //$NON-NLS-1$
52 }
53
54 String location = prereq.getCategoryName();
55 String[] locationElements = location.split("\\.");
56 Iterable<Reducible> objModel = (Iterable<Reducible>) OutputDB.getIterable(aPC.getCharID(), locationElements);
57 if (objModel == null)
58 {
59 throw new PrerequisiteException("Output System does not have model for: " + location);
60 }
61
62 String[] factinfo = prereq.getKey().split("=");
63 FactKey<?> fk = FactKey.valueOf(factinfo[0]);
64 Object targetVal = fk.getFormatManager().convertIndirect(factinfo[1]);
65
66 int runningTotal = 0;
67 for (Reducible r : objModel)
68 {
69 Indirect<?> cdoVal = r.getCDOMObject().get(fk);
70 if (targetVal.equals(cdoVal))
71 {
72 runningTotal++;
73 }
74 }
75
76 runningTotal = prereq.getOperator().compare(runningTotal, number);
77 return countedTotal(prereq, runningTotal);
78 }
79
80 /**
81 * Get the type of prerequisite handled by this token.

Callers

nothing calls this directly

Calls 15

getFormattedStringMethod · 0.95
getIterableMethod · 0.95
valueOfMethod · 0.95
parseIntMethod · 0.80
getOperandMethod · 0.80
getCategoryNameMethod · 0.80
countedTotalMethod · 0.80
toStringMethod · 0.65
getCharIDMethod · 0.65
getKeyMethod · 0.65
convertIndirectMethod · 0.65
getFormatManagerMethod · 0.65

Tested by

no test coverage detected