|
|
@@ -4,12 +4,16 @@ import javax.swing.JPanel;
|
|
|
import java.awt.GridBagLayout;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.Insets;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
import java.util.Set;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
import javax.swing.JTextArea;
|
|
|
|
|
|
+import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
|
import org.leumasjaffe.charsheet.model.DDCharacterClass;
|
|
|
import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
|
import org.leumasjaffe.charsheet.model.magic.DDSpell.Component;
|
|
|
@@ -32,8 +36,10 @@ class SpellInfoPanel extends JPanel {
|
|
|
*/
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
- public SpellInfoPanel(DDCharacterClass dclass, final DDSpell spell) {
|
|
|
+ public SpellInfoPanel(DDCharacter chara, DDCharacterClass dclass, final DDSpell spell) {
|
|
|
final IntValue classLevel = dclass.getLevel();
|
|
|
+ Map<String, Object> props = new HashMap<>();
|
|
|
+ chara.getFeatureBonuses(spell).forEach(p -> p.accumulate(props));
|
|
|
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0};
|
|
|
@@ -214,7 +220,7 @@ class SpellInfoPanel extends JPanel {
|
|
|
gbc_lblTarget.gridy = 4;
|
|
|
panel.add(lblTarget, gbc_lblTarget);
|
|
|
|
|
|
- JTextField target = new JTextField(asString(spell.getTarget()));
|
|
|
+ JTextField target = new JTextField(asString(spell.getTarget().getResolved(classLevel.value())));
|
|
|
target.setEditable(false);
|
|
|
target.setColumns(10);
|
|
|
GridBagConstraints gbc_target = new GridBagConstraints();
|
|
|
@@ -233,7 +239,8 @@ class SpellInfoPanel extends JPanel {
|
|
|
gbc_lblEffect.gridy = 4;
|
|
|
panel.add(lblEffect, gbc_lblEffect);
|
|
|
|
|
|
- JTextField effect = new JTextField(asString(spell.getEffect(), e -> e.getResolved(classLevel.value())));
|
|
|
+ JTextField effect = new JTextField(asString(spell.getEffect(),
|
|
|
+ e -> e.getResolved(classLevel.value(), getSpellBonus("effect", props))));
|
|
|
effect.setToolTipText(asString(spell.getEffect()));
|
|
|
effect.setEditable(false);
|
|
|
effect.setColumns(10);
|
|
|
@@ -337,6 +344,11 @@ class SpellInfoPanel extends JPanel {
|
|
|
description.setLineWrap(true);
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private Map<String, Integer> getSpellBonus(String key, Map<String, Object> props) {
|
|
|
+ return (Map<String, Integer>) props.getOrDefault(key, Collections.emptyMap());
|
|
|
+ }
|
|
|
+
|
|
|
private <T> String asString(Optional<T> obj, Function<? super T, String> ts) {
|
|
|
return (!obj.isPresent()) ? "" : ts.apply(obj.get());
|
|
|
}
|