(Kit aKit, PlayerCharacter aPC, List<String> warnings)
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public boolean testApply(Kit aKit, PlayerCharacter aPC, List<String> warnings) |
| 115 | { |
| 116 | theSpells = null; |
| 117 | |
| 118 | PCClass aClass = findDefaultSpellClass(castingClass, aPC); |
| 119 | if (aClass == null) |
| 120 | { |
| 121 | warnings.add("SPELLS: Character does not have " + castingClass + " spellcasting class."); |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | String workingBook = spellBook == null ? Globals.getDefaultSpellBook() : spellBook; |
| 126 | List<KitSpellBookEntry> aSpellList = new ArrayList<>(); |
| 127 | if (!aClass.getSafe(ObjectKey.MEMORIZE_SPELLS) && !workingBook.equals(Globals.getDefaultSpellBook())) |
| 128 | { |
| 129 | warnings.add("SPELLS: " + aClass.getDisplayName() + " can only add to " + Globals.getDefaultSpellBook()); |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | for (KnownSpellIdentifier ksi : spells.getKeySet()) |
| 134 | { |
| 135 | Collection<Spell> allSpells = |
| 136 | ksi.getContainedSpells(aPC, Collections.singletonList(aClass.get(ObjectKey.CLASS_SPELLLIST))); |
| 137 | Set<List<CDOMSingleRef<Ability>>> feats = spells.getSecondaryKeySet(ksi); |
| 138 | for (Spell sp : allSpells) |
| 139 | { |
| 140 | for (List<CDOMSingleRef<Ability>> list : feats) |
| 141 | { |
| 142 | Integer count = spells.get(ksi, list); |
| 143 | aSpellList.add(new KitSpellBookEntry(spellBook, sp, list, count)); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | final Formula choiceFormula = getCount(); |
| 149 | int numberOfChoices; |
| 150 | |
| 151 | if (choiceFormula == null) |
| 152 | { |
| 153 | numberOfChoices = aSpellList.size(); |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | numberOfChoices = choiceFormula.resolve(aPC, "").intValue(); |
| 158 | } |
| 159 | |
| 160 | // |
| 161 | // Can't choose more entries than there are... |
| 162 | // |
| 163 | if (numberOfChoices > aSpellList.size()) |
| 164 | { |
| 165 | numberOfChoices = aSpellList.size(); |
| 166 | } |
| 167 | |
| 168 | if (numberOfChoices == 0) |
| 169 | { |
| 170 | return false; |
nothing calls this directly
no test coverage detected