|
|
@@ -6,12 +6,14 @@ import java.awt.Component;
|
|
|
import javax.swing.Box;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.Insets;
|
|
|
-import java.util.List;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.function.BiFunction;
|
|
|
|
|
|
import org.jdesktop.swingx.VerticalLayout;
|
|
|
import org.leumasjaffe.charsheet.model.Ability;
|
|
|
import org.leumasjaffe.charsheet.model.DDCharacterClass;
|
|
|
import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
|
+import org.leumasjaffe.charsheet.model.magic.DDSpellbook;
|
|
|
import org.leumasjaffe.observer.IndirectObservableListener;
|
|
|
import org.leumasjaffe.observer.ObserverDispatch;
|
|
|
|
|
|
@@ -27,8 +29,9 @@ class SpellLevelPanel extends JPanel {
|
|
|
|
|
|
IndirectObservableListener<JPanel, DDCharacterClass> listener;
|
|
|
|
|
|
- protected SpellLevelPanel(JPanel header, DDCharacterClass dclass, int level) {
|
|
|
- final List<DDSpell> spells = dclass.getSpellBook().get().spellsPreparedAtLevel(level);
|
|
|
+ protected SpellLevelPanel(JPanel header, DDCharacterClass dclass, int level,
|
|
|
+ BiFunction<DDSpellbook, Integer, Collection<DDSpell>> getSpells) {
|
|
|
+ final Collection<DDSpell> spells = getSpells.apply(dclass.getSpellBook().get(), level);
|
|
|
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
|
@@ -69,7 +72,7 @@ class SpellLevelPanel extends JPanel {
|
|
|
}
|
|
|
|
|
|
public SpellLevelPanel(DDCharacterClass dclass, int level, Ability.Scores ability) {
|
|
|
- this(new SpellsKnownHeader(level, dclass.getSpellBook().get(), ability), dclass, level);
|
|
|
+ this(new SpellsKnownHeader(level, dclass.getSpellBook().get(), ability), dclass, level, DDSpellbook::spellsKnownAtLevel);
|
|
|
}
|
|
|
|
|
|
public boolean isCastableFromHere() { return false; }
|