Skip to content

Commit

Permalink
fix weight calculation fr patchwork armor on status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Sep 16, 2024
1 parent 803a80a commit 90334c6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
5 changes: 0 additions & 5 deletions megamek/src/megamek/common/BattleArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1487,11 +1487,6 @@ public boolean isHardenedArmorDamaged(HitData hit) {
return false;
}

@Override
public boolean hasPatchworkArmor() {
return false;
}

public void setIsExoskeleton(boolean exoskeleton) {
this.exoskeleton = exoskeleton;
}
Expand Down
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/Infantry.java
Original file line number Diff line number Diff line change
Expand Up @@ -1926,4 +1926,9 @@ public int getSpriteDrawPriority() {
public int getGenericBattleValue() {
return (int) Math.round(Math.exp(3.586 + 0.336 * Math.log(getWeight())));
}

@Override
public boolean hasPatchworkArmor() {
return false;
}
}
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/Jumpship.java
Original file line number Diff line number Diff line change
Expand Up @@ -1437,4 +1437,9 @@ public boolean isJumpShip() {
public int getGenericBattleValue() {
return (int) Math.round(Math.exp(0.0619 + 0.5607 * Math.log(getWeight())));
}

@Override
public boolean hasPatchworkArmor() {
return false;
}
}
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/ProtoMek.java
Original file line number Diff line number Diff line change
Expand Up @@ -1628,4 +1628,9 @@ protected Mounted<?> getEquipmentForWeaponQuirk(QuirkEntry quirkEntry) {
protected Map<Integer, List<Integer>> getBlockedFiringLocations() {
return BLOCKED_FIRING_LOCATIONS;
}

@Override
public boolean hasPatchworkArmor() {
return false;
}
}
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/SmallCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -921,4 +921,9 @@ public void autoSetMaxBombPoints() {
public int getGenericBattleValue() {
return (int) Math.round(Math.exp(-0.068 + 1.421 * Math.log(getWeight())));
}

@Override
public boolean hasPatchworkArmor() {
return false;
}
}
6 changes: 5 additions & 1 deletion megamek/src/megamek/common/verifier/TestAero.java
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,11 @@ public double calculateWeightExact() {
weight += getWeightControls();
weight += getWeightFuel();
weight += getWeightHeatSinks();
weight += getWeightArmor();
if (getEntity().hasPatchworkArmor()) {
weight += getWeightAllocatedArmor();
} else {
weight += getWeightArmor();
}
weight += getWeightMisc();

weight += getWeightMiscEquip();
Expand Down
12 changes: 7 additions & 5 deletions megamek/src/megamek/common/verifier/TestEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,8 @@ public double calculateWeight() {
}

/**
* According to TM p.22, unit weights are to be rounded up to the nearest half
* ton or kilo, but in MML
* for construction at least we should be able to show the exact weight. This
* method returns the unrounded
* According to TM p.22, unit weights are to be rounded up to the nearest half ton or kilo, but in MML
* for construction at least we should be able to show the exact weight. This method returns the unrounded
* weight.
*
* @return The unrounded weight of the unit.
Expand All @@ -967,7 +965,11 @@ public double calculateWeightExact() {
weight += getWeightStructure();
weight += getWeightControls();
weight += getWeightHeatSinks();
weight += getWeightArmor();
if (getEntity().hasPatchworkArmor()) {
weight += getWeightAllocatedArmor();
} else {
weight += getWeightArmor();
}
weight += getWeightMisc();

weight += getWeightMiscEquip();
Expand Down

0 comments on commit 90334c6

Please sign in to comment.