|
|
@@ -4,7 +4,6 @@ import javax.swing.JPanel;
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
-import java.util.List;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
import javax.swing.JTabbedPane;
|
|
|
@@ -30,11 +29,9 @@ public class SpellPanel extends JPanel {
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
DDCharacterClass dclass;
|
|
|
VoidVoidFunction _reload;
|
|
|
- int highestSpellLevel;
|
|
|
|
|
|
public SpellPanel(DDCharacter chara, final DDCharacterClass cclass) {
|
|
|
dclass = cclass;
|
|
|
- highestSpellLevel = calcHighestSpellLevel(cclass);
|
|
|
final DDSpellbook model = cclass.getSpellBook().get();
|
|
|
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
@@ -71,18 +68,11 @@ public class SpellPanel extends JPanel {
|
|
|
_reload.apply();
|
|
|
}
|
|
|
|
|
|
- private static int calcHighestSpellLevel(final DDCharacterClass cclass) {
|
|
|
- // TODO: Bonus levels to spellsKnown/spellsPerDay?
|
|
|
- final List<Integer> list = cclass.getProto().getSpells().get().getPerDay().get(cclass.getLevel()-1);
|
|
|
- final int level = list.size() - 1;
|
|
|
- return list.get(level) == 0 ? level : level + 1;
|
|
|
- }
|
|
|
-
|
|
|
private void generateSpellTree(final Function<Integer, JPanel> getPanel, final JScrollPane preparedPane) {
|
|
|
JPanel root = new JPanel();
|
|
|
root.setLayout(new VerticalLayout());
|
|
|
|
|
|
- for (int i = 0; i < highestSpellLevel; ++i) {
|
|
|
+ for (int i = 0; i < dclass.getHighestSpellLevel(); ++i) {
|
|
|
if (dclass.getSpellBook().get().numSpellsKnownAtLevel(i) == 0) continue;
|
|
|
root.add(getPanel.apply(i));
|
|
|
}
|