Skip to content

Commit

Permalink
Merge pull request #2503 from MegaMek/superheavy_talons
Browse files Browse the repository at this point in the history
Two talon bugs
  • Loading branch information
neoancient authored Dec 12, 2020
2 parents 527218b + 06fbfcf commit 7708064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 36 deletions.
42 changes: 9 additions & 33 deletions megamek/src/megamek/common/MechFileParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,42 +593,18 @@ else if (m.getType().hasFlag(MiscType.F_APOLLO)
}

if (m.getType().hasFlag(MiscType.F_TALON)) {
if (ent instanceof BipedMech) {
if ((m.getLocation() != Mech.LOC_LLEG)
&& (m.getLocation() != Mech.LOC_RLEG)) {
throw new EntityLoadingException(
"Talons are only legal in the Legs for "+ent.getShortName());
if (ent instanceof Mech) {
if (!ent.locationIsLeg(m.getLocation())) {
throw new EntityLoadingException("Talons are only legal in the Legs for " + ent.getShortName());
}

if (!ent.hasWorkingMisc(MiscType.F_TALON, -1, Mech.LOC_RLEG)
|| !ent.hasWorkingMisc(MiscType.F_TALON, -1,
Mech.LOC_LLEG)) {
throw new EntityLoadingException(
"Talons must be in all legs for "+ent.getShortName());
}
} else if (ent instanceof QuadMech) {
if ((m.getLocation() != Mech.LOC_LLEG)
&& (m.getLocation() != Mech.LOC_RLEG)
&& (m.getLocation() != Mech.LOC_LARM)
&& (m.getLocation() != Mech.LOC_RARM)) {
throw new EntityLoadingException(
"Talons are only legal in the Legs for "+ent.getShortName());
}

if (!ent.hasWorkingMisc(MiscType.F_TALON, -1, Mech.LOC_RLEG)
|| !ent.hasWorkingMisc(MiscType.F_TALON, -1,
Mech.LOC_LLEG)
|| !ent.hasWorkingMisc(MiscType.F_TALON, -1,
Mech.LOC_LARM)
|| !ent.hasWorkingMisc(MiscType.F_TALON, -1,
Mech.LOC_LARM)) {
throw new EntityLoadingException(
"Talons must be in all legs for "+ent.getShortName());
for (int loc = 0; loc < ent.locations(); loc++) {
if (ent.locationIsLeg(loc) && !ent.hasWorkingMisc(MiscType.F_TALON, -1, loc)) {
throw new EntityLoadingException("Talons must be in all legs for " + ent.getShortName());
}
}

} else {
throw new EntityLoadingException(
"Unable to load talons in non-Mek entity for "+ent.getShortName());
throw new EntityLoadingException("Unable to load talons in non-Mek entity for "
+ ent.getShortName());
}
}

Expand Down
6 changes: 3 additions & 3 deletions megamek/src/megamek/common/verifier/TestMech.java
Original file line number Diff line number Diff line change
Expand Up @@ -1001,11 +1001,11 @@ && countCriticalSlotsFromEquipInLocation(mech, m, loc) != 1) {
}

if (m.getType().hasFlag(MiscType.F_TALON)) {
int slots = getMech().isSuperHeavy() ? 1 : 2;
for (int loc = 0; loc < mech.locations(); loc++) {
if (mech.locationIsLeg(loc)
&& countCriticalSlotsFromEquipInLocation(mech, m, loc) != 2) {
if (mech.locationIsLeg(loc) && countCriticalSlotsFromEquipInLocation(mech, m, loc) != slots) {
illegal = true;
buff.append("Talons require two critical slots in each leg.\n");
buff.append("Talons require ").append(slots).append(" critical slots in each leg.\n");
break;
}
}
Expand Down

0 comments on commit 7708064

Please sign in to comment.