Skip to content

Commit

Permalink
TestTank: Adapt some tests for GunEmplacements
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Oct 1, 2023
1 parent e685195 commit e8fa434
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions megamek/src/megamek/common/verifier/TestTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,19 @@ public static boolean legalForMotiveType(EquipmentType eq, EntityMovementMode mo

@Override
public boolean correctWeight(StringBuffer buff, boolean showO, boolean showU) {
boolean correct = super.correctWeight(buff, showO, showU);
double max = maxTonnage(getEntity().getMovementMode(), getEntity().isSuperHeavy());
if (getEntity().getWeight() > max) {
correct = false;
buff.append("Exceeds maximum tonnage of ").append(max).append(" for ")
.append(getEntity().getMovementModeAsString())
.append(" combat vehicle.\n");
if (!(getEntity() instanceof GunEmplacement)) {
boolean correct = super.correctWeight(buff, showO, showU);
double max = maxTonnage(getEntity().getMovementMode(), getEntity().isSuperHeavy());
if (getEntity().getWeight() > max) {
correct = false;
buff.append("Exceeds maximum tonnage of ").append(max).append(" for ")
.append(getEntity().getMovementModeAsString())
.append(" combat vehicle.\n");
}
return correct;
} else {
return true;
}
return correct;
}

public boolean correctCriticals(StringBuffer buff) {
Expand Down Expand Up @@ -891,7 +895,7 @@ public boolean hasIllegalEquipmentCombinations(StringBuffer buff) {
*/
public static boolean isValidTankLocation(Tank tank, EquipmentType eq, int location,
@Nullable StringBuffer buffer) {
if (isBodyEquipment(eq) && (location != Tank.LOC_BODY)) {
if ((isBodyEquipment(eq) || (tank instanceof GunEmplacement)) && (location != Tank.LOC_BODY)) {
if (buffer != null) {
buffer.append(eq.getName()).append(" must be mounted in the body.\n");
}
Expand Down Expand Up @@ -993,7 +997,8 @@ public static boolean isValidTankLocation(Tank tank, EquipmentType eq, int locat
return false;
}
if (!eq.hasFlag(WeaponType.F_C3M) && !eq.hasFlag(WeaponType.F_C3MBS)
&& !eq.hasFlag(WeaponType.F_TAG) && (location == Tank.LOC_BODY)) {
&& !eq.hasFlag(WeaponType.F_TAG) && (location == Tank.LOC_BODY)
&& !(tank instanceof GunEmplacement)) {
if (buffer != null) {
buffer.append(eq.getName()).append(" cannot be mounted in the body.\n");
}
Expand Down

0 comments on commit e8fa434

Please sign in to comment.