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

Method passes

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

Source from the content-addressed store, hash-verified

39{
40
41 @Override
42 public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source)
43 {
44 CharacterDisplay display = character.getDisplay();
45 int requiredNumber = 0;
46 try
47 {
48 requiredNumber = Integer.parseInt(prereq.getOperand());
49 } catch (NumberFormatException e)
50 {
51 Logging.errorPrint(
52 LanguageBundle.getString("PreSpell.error.badly_formed_attribute") + prereq.toString()); //$NON-NLS-1$
53 }
54
55 // Build a list of all possible spells
56 final List<Spell> aArrayList =
57 character.aggregateSpellList("", "", "", 0, 20); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
58
59 //Needs to add domain spells as well
60 for (Domain d : display.getDomainSet())
61 {
62 aArrayList
63 .addAll(character.getAllSpellsInLists(Collections.singletonList(d.get(ObjectKey.DOMAIN_SPELLLIST))));
64 }
65
66 //Are there Innate Spell-like abilities?
67 if (character.getAutoSpells())
68 {
69 Collection<CDOMReference<Spell>> mods = display.getRace().getListMods(Spell.SPELLS);
70 if (mods != null)
71 {
72 for (CDOMReference<Spell> ref : mods)
73 {
74 aArrayList.addAll(ref.getContainedObjects());
75 }
76 }
77 }
78
79 final String spellName = prereq.getKey();
80 int runningTotal = 0;
81
82 for (Spell aSpell : aArrayList)
83 {
84 if (aSpell != null && aSpell.getKeyName() != null && aSpell.getKeyName().equalsIgnoreCase(spellName))
85 {
86 runningTotal++;
87 }
88 }
89 runningTotal = prereq.getOperator().compare(runningTotal, requiredNumber);
90 return countedTotal(prereq, runningTotal);
91 }
92
93 /**
94 * Get the type of prerequisite handled by this token.

Callers

nothing calls this directly

Calls 15

errorPrintMethod · 0.95
getStringMethod · 0.95
getDomainSetMethod · 0.95
getRaceMethod · 0.95
parseIntMethod · 0.80
getOperandMethod · 0.80
aggregateSpellListMethod · 0.80
getAllSpellsInListsMethod · 0.80
getAutoSpellsMethod · 0.80
getListModsMethod · 0.80
equalsIgnoreCaseMethod · 0.80
countedTotalMethod · 0.80

Tested by

no test coverage detected