|
@@ -12,6 +12,7 @@ import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
|
import org.leumasjaffe.charsheet.model.inventory.DDInventory;
|
|
import org.leumasjaffe.charsheet.model.inventory.DDInventory;
|
|
|
import org.leumasjaffe.charsheet.model.inventory.DDItem;
|
|
import org.leumasjaffe.charsheet.model.inventory.DDItem;
|
|
|
import org.leumasjaffe.charsheet.model.inventory.EquipmentSlot;
|
|
import org.leumasjaffe.charsheet.model.inventory.EquipmentSlot;
|
|
|
|
|
+import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
|
import org.leumasjaffe.format.StringHelper;
|
|
import org.leumasjaffe.format.StringHelper;
|
|
|
import org.leumasjaffe.observer.IndirectObservableListener;
|
|
import org.leumasjaffe.observer.IndirectObservableListener;
|
|
|
import org.leumasjaffe.observer.ObservableListener;
|
|
import org.leumasjaffe.observer.ObservableListener;
|
|
@@ -94,7 +95,7 @@ public class ArmorLine extends JPanel {
|
|
|
total.setColumns(3);
|
|
total.setColumns(3);
|
|
|
total.setBorder(new LineBorder(Color.BLACK));
|
|
total.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_total = new GridBagConstraints();
|
|
GridBagConstraints gbc_total = new GridBagConstraints();
|
|
|
- gbc_total.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_total.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_total.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_total.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_total.gridx = 1;
|
|
gbc_total.gridx = 1;
|
|
|
gbc_total.gridy = 0;
|
|
gbc_total.gridy = 0;
|
|
@@ -102,7 +103,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label = new JLabel("=");
|
|
JLabel label = new JLabel("=");
|
|
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
|
|
- gbc_label.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label.gridx = 2;
|
|
gbc_label.gridx = 2;
|
|
|
gbc_label.gridy = 0;
|
|
gbc_label.gridy = 0;
|
|
|
panel.add(label, gbc_label);
|
|
panel.add(label, gbc_label);
|
|
@@ -110,7 +111,7 @@ public class ArmorLine extends JPanel {
|
|
|
JLabel label_7 = new JLabel("10+");
|
|
JLabel label_7 = new JLabel("10+");
|
|
|
label_7.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
label_7.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
GridBagConstraints gbc_label_7 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_7 = new GridBagConstraints();
|
|
|
- gbc_label_7.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_7.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_7.anchor = GridBagConstraints.EAST;
|
|
gbc_label_7.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_7.gridx = 3;
|
|
gbc_label_7.gridx = 3;
|
|
|
gbc_label_7.gridy = 0;
|
|
gbc_label_7.gridy = 0;
|
|
@@ -126,7 +127,7 @@ public class ArmorLine extends JPanel {
|
|
|
armor.setColumns(3);
|
|
armor.setColumns(3);
|
|
|
armor.setBorder(new LineBorder(Color.BLACK));
|
|
armor.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_armor = new GridBagConstraints();
|
|
GridBagConstraints gbc_armor = new GridBagConstraints();
|
|
|
- gbc_armor.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_armor.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_armor.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_armor.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_armor.gridx = 4;
|
|
gbc_armor.gridx = 4;
|
|
|
gbc_armor.gridy = 0;
|
|
gbc_armor.gridy = 0;
|
|
@@ -134,7 +135,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label_1 = new JLabel("+");
|
|
JLabel label_1 = new JLabel("+");
|
|
|
GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
|
|
- gbc_label_1.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_1.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_1.anchor = GridBagConstraints.EAST;
|
|
gbc_label_1.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_1.gridx = 5;
|
|
gbc_label_1.gridx = 5;
|
|
|
gbc_label_1.gridy = 0;
|
|
gbc_label_1.gridy = 0;
|
|
@@ -150,7 +151,7 @@ public class ArmorLine extends JPanel {
|
|
|
shield.setColumns(3);
|
|
shield.setColumns(3);
|
|
|
shield.setBorder(new LineBorder(Color.BLACK));
|
|
shield.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_shield = new GridBagConstraints();
|
|
GridBagConstraints gbc_shield = new GridBagConstraints();
|
|
|
- gbc_shield.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_shield.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_shield.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_shield.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_shield.gridx = 6;
|
|
gbc_shield.gridx = 6;
|
|
|
gbc_shield.gridy = 0;
|
|
gbc_shield.gridy = 0;
|
|
@@ -158,7 +159,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label_2 = new JLabel("+");
|
|
JLabel label_2 = new JLabel("+");
|
|
|
GridBagConstraints gbc_label_2 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_2 = new GridBagConstraints();
|
|
|
- gbc_label_2.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_2.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_2.anchor = GridBagConstraints.EAST;
|
|
gbc_label_2.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_2.gridx = 7;
|
|
gbc_label_2.gridx = 7;
|
|
|
gbc_label_2.gridy = 0;
|
|
gbc_label_2.gridy = 0;
|
|
@@ -174,7 +175,7 @@ public class ArmorLine extends JPanel {
|
|
|
dexterity.setColumns(3);
|
|
dexterity.setColumns(3);
|
|
|
dexterity.setBorder(new LineBorder(Color.BLACK));
|
|
dexterity.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_dexterity = new GridBagConstraints();
|
|
GridBagConstraints gbc_dexterity = new GridBagConstraints();
|
|
|
- gbc_dexterity.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_dexterity.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_dexterity.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_dexterity.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_dexterity.gridx = 8;
|
|
gbc_dexterity.gridx = 8;
|
|
|
gbc_dexterity.gridy = 0;
|
|
gbc_dexterity.gridy = 0;
|
|
@@ -182,7 +183,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label_3 = new JLabel("+");
|
|
JLabel label_3 = new JLabel("+");
|
|
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
|
|
- gbc_label_3.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_3.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_3.anchor = GridBagConstraints.EAST;
|
|
gbc_label_3.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_3.gridx = 9;
|
|
gbc_label_3.gridx = 9;
|
|
|
gbc_label_3.gridy = 0;
|
|
gbc_label_3.gridy = 0;
|
|
@@ -198,7 +199,7 @@ public class ArmorLine extends JPanel {
|
|
|
size.setColumns(3);
|
|
size.setColumns(3);
|
|
|
size.setBorder(new LineBorder(Color.BLACK));
|
|
size.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_size = new GridBagConstraints();
|
|
GridBagConstraints gbc_size = new GridBagConstraints();
|
|
|
- gbc_size.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_size.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_size.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_size.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_size.gridx = 10;
|
|
gbc_size.gridx = 10;
|
|
|
gbc_size.gridy = 0;
|
|
gbc_size.gridy = 0;
|
|
@@ -206,7 +207,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label_4 = new JLabel("+");
|
|
JLabel label_4 = new JLabel("+");
|
|
|
GridBagConstraints gbc_label_4 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_4 = new GridBagConstraints();
|
|
|
- gbc_label_4.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_4.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_4.anchor = GridBagConstraints.EAST;
|
|
gbc_label_4.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_4.gridx = 11;
|
|
gbc_label_4.gridx = 11;
|
|
|
gbc_label_4.gridy = 0;
|
|
gbc_label_4.gridy = 0;
|
|
@@ -222,7 +223,7 @@ public class ArmorLine extends JPanel {
|
|
|
natural.setColumns(3);
|
|
natural.setColumns(3);
|
|
|
natural.setBorder(new LineBorder(Color.BLACK));
|
|
natural.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_natural = new GridBagConstraints();
|
|
GridBagConstraints gbc_natural = new GridBagConstraints();
|
|
|
- gbc_natural.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_natural.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_natural.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_natural.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_natural.gridx = 12;
|
|
gbc_natural.gridx = 12;
|
|
|
gbc_natural.gridy = 0;
|
|
gbc_natural.gridy = 0;
|
|
@@ -230,7 +231,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label_5 = new JLabel("+");
|
|
JLabel label_5 = new JLabel("+");
|
|
|
GridBagConstraints gbc_label_5 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_5 = new GridBagConstraints();
|
|
|
- gbc_label_5.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_5.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_5.anchor = GridBagConstraints.EAST;
|
|
gbc_label_5.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_5.gridx = 13;
|
|
gbc_label_5.gridx = 13;
|
|
|
gbc_label_5.gridy = 0;
|
|
gbc_label_5.gridy = 0;
|
|
@@ -246,7 +247,7 @@ public class ArmorLine extends JPanel {
|
|
|
deflection.setColumns(3);
|
|
deflection.setColumns(3);
|
|
|
deflection.setBorder(new LineBorder(Color.BLACK));
|
|
deflection.setBorder(new LineBorder(Color.BLACK));
|
|
|
GridBagConstraints gbc_deflection = new GridBagConstraints();
|
|
GridBagConstraints gbc_deflection = new GridBagConstraints();
|
|
|
- gbc_deflection.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_deflection.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_deflection.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_deflection.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_deflection.gridx = 14;
|
|
gbc_deflection.gridx = 14;
|
|
|
gbc_deflection.gridy = 0;
|
|
gbc_deflection.gridy = 0;
|
|
@@ -254,7 +255,7 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
JLabel label_6 = new JLabel("+");
|
|
JLabel label_6 = new JLabel("+");
|
|
|
GridBagConstraints gbc_label_6 = new GridBagConstraints();
|
|
GridBagConstraints gbc_label_6 = new GridBagConstraints();
|
|
|
- gbc_label_6.insets = new Insets(0, 0, 0, 4);
|
|
|
|
|
|
|
+ gbc_label_6.insets = new Insets(0, 0, 0, 3);
|
|
|
gbc_label_6.anchor = GridBagConstraints.EAST;
|
|
gbc_label_6.anchor = GridBagConstraints.EAST;
|
|
|
gbc_label_6.gridx = 15;
|
|
gbc_label_6.gridx = 15;
|
|
|
gbc_label_6.gridy = 0;
|
|
gbc_label_6.gridy = 0;
|
|
@@ -358,57 +359,39 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
|
|
armorTotalObserver = new IndirectObservableListener<>(total, (c, v) -> {
|
|
armorTotalObserver = new IndirectObservableListener<>(total, (c, v) -> {
|
|
|
final DDInventory inv = v.getInventory();
|
|
final DDInventory inv = v.getInventory();
|
|
|
- int iarmor = 0;
|
|
|
|
|
- int ishield = 0;
|
|
|
|
|
- int dex = v.getAbilities().getDex().modifier();
|
|
|
|
|
- int isize = v.getSize().value().modifier;
|
|
|
|
|
- int inatural = 0;
|
|
|
|
|
- int ideflect = 0;
|
|
|
|
|
- int imisc = 0;
|
|
|
|
|
- {
|
|
|
|
|
- final DDItem body = inv.getEquipment().get(EquipmentSlot.BODY);
|
|
|
|
|
- if ( body != null && body.isArmor() ) {
|
|
|
|
|
- iarmor = body.getArmor().getActualAcBonus();
|
|
|
|
|
- dex = Math.min(dex, body.getArmor().getMaxDex());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- final DDItem offHand = inv.getEquipment().get(EquipmentSlot.OFF_HAND);
|
|
|
|
|
- if ( offHand != null && offHand.isArmor() ) {
|
|
|
|
|
- ishield = offHand.getArmor().getActualAcBonus();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- c.setText(StringHelper.toString(10 + iarmor + ishield +
|
|
|
|
|
- dex + isize + inatural + ideflect + imisc));
|
|
|
|
|
|
|
+ IntValue iarmor = new IntValue(0), ishield = new IntValue(0);
|
|
|
|
|
+ IntValue dex = new IntValue(v.getAbilities().getDex().modifier());
|
|
|
|
|
+ int isize = v.getSize().value().modifier, inatural = 0, ideflect = 0, imisc = 0;
|
|
|
|
|
+
|
|
|
|
|
+ inv.getEquipment().get(EquipmentSlot.BODY).flatMap(DDItem::getArmor).ifPresent( a -> {
|
|
|
|
|
+ iarmor.value(a.getActualAcBonus());
|
|
|
|
|
+ dex.value(Math.min(dex.value(), a.getMaxDex()));
|
|
|
|
|
+ });
|
|
|
|
|
+ inv.getEquipment().get(EquipmentSlot.OFF_HAND).flatMap(DDItem::getArmor).ifPresent(
|
|
|
|
|
+ a -> ishield.value(a.getActualAcBonus()));
|
|
|
|
|
+ c.setText(StringHelper.toString(10 + iarmor.value() + ishield.value() +
|
|
|
|
|
+ dex.value() + isize + inatural + ideflect + imisc));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
armorArmorObserver = new ObservableListener<>(armor, (c, v) -> {
|
|
armorArmorObserver = new ObservableListener<>(armor, (c, v) -> {
|
|
|
- int iarmor = 0;
|
|
|
|
|
- final DDItem body = v.getEquipment().get(EquipmentSlot.BODY);
|
|
|
|
|
- if ( body != null && body.isArmor() ) {
|
|
|
|
|
- iarmor = body.getArmor().getActualAcBonus();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ IntValue iarmor = new IntValue(0);
|
|
|
|
|
+ v.getEquipment().get(EquipmentSlot.BODY).flatMap(DDItem::getArmor).ifPresent(
|
|
|
|
|
+ a -> iarmor.value(a.getActualAcBonus()));
|
|
|
c.setText(StringHelper.toString(iarmor));
|
|
c.setText(StringHelper.toString(iarmor));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
armorShieldObserver = new ObservableListener<>(shield, (c, v) -> {
|
|
armorShieldObserver = new ObservableListener<>(shield, (c, v) -> {
|
|
|
- int iarmor = 0;
|
|
|
|
|
- final DDItem offHand = v.getEquipment().get(EquipmentSlot.OFF_HAND);
|
|
|
|
|
- if ( offHand != null && offHand.isArmor() ) {
|
|
|
|
|
- iarmor = offHand.getArmor().getActualAcBonus();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ IntValue iarmor = new IntValue(0);
|
|
|
|
|
+ v.getEquipment().get(EquipmentSlot.OFF_HAND).flatMap(DDItem::getArmor).ifPresent(
|
|
|
|
|
+ a -> iarmor.value(a.getActualAcBonus()));
|
|
|
c.setText(StringHelper.toString(iarmor));
|
|
c.setText(StringHelper.toString(iarmor));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
armorDexObserver = new IndirectObservableListener<>(dexterity, (c, v) -> {
|
|
armorDexObserver = new IndirectObservableListener<>(dexterity, (c, v) -> {
|
|
|
final DDInventory inv = v.getInventory();
|
|
final DDInventory inv = v.getInventory();
|
|
|
- int dex = v.getAbilities().getDex().modifier();
|
|
|
|
|
- {
|
|
|
|
|
- final DDItem body = inv.getEquipment().get(EquipmentSlot.BODY);
|
|
|
|
|
- if ( body != null && body.isArmor() ) {
|
|
|
|
|
- dex = Math.min(dex, body.getArmor().getMaxDex());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ IntValue dex = new IntValue(v.getAbilities().getDex().modifier());
|
|
|
|
|
+ inv.getEquipment().get(EquipmentSlot.BODY).flatMap(DDItem::getArmor).ifPresent(
|
|
|
|
|
+ a -> dex.value(Math.min(dex.value(), a.getMaxDex())));
|
|
|
c.setText(StringHelper.toString(dex));
|
|
c.setText(StringHelper.toString(dex));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|