Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate that arms only have one shield #6623

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion megamek/src/megamek/common/verifier/TestMek.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import megamek.common.*;
import megamek.common.annotations.Nullable;
import megamek.common.equipment.ArmorType;
import megamek.common.equipment.MiscMounted;
import megamek.common.equipment.WeaponMounted;
import megamek.common.options.OptionsConstants;
import megamek.common.util.StringUtil;
Expand Down Expand Up @@ -834,12 +835,13 @@ public boolean hasIllegalEquipmentCombinations(StringBuffer buff) {
boolean hasMekJumpBooster = false;
boolean hasPartialWing = false;
EquipmentType advancedMyomer = null;
HashSet<Integer> shieldLocations = new HashSet<>();

// First we find all the equipment that is required or incompatible with other
// equipment,
// so we don't have to execute another loop each time one of those situations
// comes up.
for (Mounted<?> m : mek.getMisc()) {
for (MiscMounted m : mek.getMisc()) {
hasHarjelII |= m.getType().hasFlag(MiscType.F_HARJEL_II);
hasHarjelIII |= m.getType().hasFlag(MiscType.F_HARJEL_III);
hasNullSig |= m.getType().hasFlag(MiscType.F_NULLSIG);
Expand All @@ -855,6 +857,16 @@ public boolean hasIllegalEquipmentCombinations(StringBuffer buff) {
}
hasMekJumpBooster |= m.is(EquipmentTypeLookup.MECHANICAL_JUMP_BOOSTER);
hasPartialWing |= m.getType().hasFlag(MiscType.F_PARTIAL_WING);

if (m.getType().hasFlag(MiscType.F_CLUB) &&
(m.getType().getSubType() & (MiscType.S_SHIELD_SMALL | MiscType.S_SHIELD_MEDIUM | MiscType.S_SHIELD_LARGE)) != 0) {
if (shieldLocations.contains(m.getLocation())) {
illegal = true;
buff.append("Only one shield can be mounted in a location.\n");
} else {
shieldLocations.add(m.getLocation());
}
}
}

for (Mounted<?> m : getEntity().getMisc()) {
Expand Down