(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source)
| 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. |
nothing calls this directly
no test coverage detected