|
|
@@ -12,6 +12,7 @@ import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
|
import org.leumasjaffe.charsheet.model.inventory.DDInventory;
|
|
|
import org.leumasjaffe.charsheet.model.inventory.DDItem;
|
|
|
import org.leumasjaffe.charsheet.model.inventory.EquipmentSlot;
|
|
|
+import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
|
import org.leumasjaffe.format.StringHelper;
|
|
|
import org.leumasjaffe.observer.IndirectObservableListener;
|
|
|
import org.leumasjaffe.observer.ObservableListener;
|
|
|
@@ -358,55 +359,58 @@ public class ArmorLine extends JPanel {
|
|
|
|
|
|
armorTotalObserver = new IndirectObservableListener<>(total, (c, v) -> {
|
|
|
final DDInventory inv = v.getInventory();
|
|
|
- int iarmor = 0;
|
|
|
- int ishield = 0;
|
|
|
- int dex = v.getAbilities().getDex().modifier();
|
|
|
+ IntValue iarmor = new IntValue(0);
|
|
|
+ IntValue ishield = new IntValue(0);
|
|
|
+ IntValue dex = new IntValue(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());
|
|
|
+ if ( body != null ) {
|
|
|
+ body.getArmor().ifPresent( a -> {
|
|
|
+ iarmor.value(a.getActualAcBonus());
|
|
|
+ dex.value(Math.min(dex.value(), a.getMaxDex()));
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
{
|
|
|
final DDItem offHand = inv.getEquipment().get(EquipmentSlot.OFF_HAND);
|
|
|
- if ( offHand != null && offHand.isArmor() ) {
|
|
|
- ishield = offHand.getArmor().getActualAcBonus();
|
|
|
+ if ( offHand != null ) {
|
|
|
+ offHand.getArmor().ifPresent(a -> ishield.value(a.getActualAcBonus()));
|
|
|
}
|
|
|
}
|
|
|
- c.setText(StringHelper.toString(10 + iarmor + ishield +
|
|
|
- dex + isize + inatural + ideflect + imisc));
|
|
|
+ c.setText(StringHelper.toString(10 + iarmor.value() + ishield.value() +
|
|
|
+ dex.value() + isize + inatural + ideflect + imisc));
|
|
|
});
|
|
|
|
|
|
armorArmorObserver = new ObservableListener<>(armor, (c, v) -> {
|
|
|
- int iarmor = 0;
|
|
|
+ IntValue iarmor = new IntValue(0);
|
|
|
final DDItem body = v.getEquipment().get(EquipmentSlot.BODY);
|
|
|
- if ( body != null && body.isArmor() ) {
|
|
|
- iarmor = body.getArmor().getActualAcBonus();
|
|
|
+ if ( body != null ) {
|
|
|
+ body.getArmor().ifPresent(a -> iarmor.value(a.getActualAcBonus()));
|
|
|
}
|
|
|
c.setText(StringHelper.toString(iarmor));
|
|
|
});
|
|
|
|
|
|
armorShieldObserver = new ObservableListener<>(shield, (c, v) -> {
|
|
|
- int iarmor = 0;
|
|
|
+ IntValue iarmor = new IntValue(0);
|
|
|
final DDItem offHand = v.getEquipment().get(EquipmentSlot.OFF_HAND);
|
|
|
- if ( offHand != null && offHand.isArmor() ) {
|
|
|
- iarmor = offHand.getArmor().getActualAcBonus();
|
|
|
+ if ( offHand != null ) {
|
|
|
+ offHand.getArmor().ifPresent(a -> iarmor.value(a.getActualAcBonus()));
|
|
|
}
|
|
|
c.setText(StringHelper.toString(iarmor));
|
|
|
});
|
|
|
|
|
|
armorDexObserver = new IndirectObservableListener<>(dexterity, (c, v) -> {
|
|
|
final DDInventory inv = v.getInventory();
|
|
|
- int dex = v.getAbilities().getDex().modifier();
|
|
|
+ IntValue dex = new IntValue(v.getAbilities().getDex().modifier());
|
|
|
{
|
|
|
final DDItem body = inv.getEquipment().get(EquipmentSlot.BODY);
|
|
|
- if ( body != null && body.isArmor() ) {
|
|
|
- dex = Math.min(dex, body.getArmor().getMaxDex());
|
|
|
+ if ( body != null ) {
|
|
|
+ body.getArmor().ifPresent(a -> dex.value(Math.min(dex.value(), a.getMaxDex())));
|
|
|
}
|
|
|
}
|
|
|
c.setText(StringHelper.toString(dex));
|