From 6761250482b4b0a6a47275c09a675410c89f691c Mon Sep 17 00:00:00 2001 From: Windchild292 Date: Tue, 19 Jan 2021 17:21:17 -0500 Subject: [PATCH 1/2] Adding better information blockers for multislot equipment --- .../src/mekhq/campaign/parts/MekLocation.java | 24 +++++++++++++++---- .../campaign/parts/MissingMekLocation.java | 17 +++++++++++-- .../parts/equipment/EquipmentPart.java | 4 ++-- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/parts/MekLocation.java b/MekHQ/src/mekhq/campaign/parts/MekLocation.java index 90ebb7bc47..35f69c5c1c 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekLocation.java +++ b/MekHQ/src/mekhq/campaign/parts/MekLocation.java @@ -23,6 +23,7 @@ import java.io.PrintWriter; import java.util.StringJoiner; +import megamek.common.MiscType; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; import org.w3c.dom.Node; @@ -641,11 +642,11 @@ public String checkFixable() { } //certain other specific crits need to be left out (uggh, must be a better way to do this!) - if (slot.getType() == CriticalSlot.TYPE_SYSTEM - && (slot.getIndex() == Mech.ACTUATOR_HIP - || slot.getIndex() == Mech.ACTUATOR_SHOULDER - || slot.getIndex() == Mech.SYSTEM_LIFE_SUPPORT - || slot.getIndex() == Mech.SYSTEM_SENSORS)) { + if ((slot.getType() == CriticalSlot.TYPE_SYSTEM) + && ((slot.getIndex() == Mech.ACTUATOR_HIP) + || (slot.getIndex() == Mech.ACTUATOR_SHOULDER) + || (slot.getIndex() == Mech.SYSTEM_LIFE_SUPPORT) + || (slot.getIndex() == Mech.SYSTEM_SENSORS))) { continue; } @@ -667,6 +668,19 @@ public String checkFixable() { } } + if (slot.getType() == CriticalSlot.TYPE_EQUIPMENT) { + if ((slot.getMount() != null) && !slot.getMount().isDestroyed()) { + EquipmentType equipmentType = slot.getMount().getType(); + if (equipmentType.hasFlag(MiscType.F_NULLSIG)) { + return "Null-Signature System must be salvaged or scrapped first."; + } else if (equipmentType.hasFlag(MiscType.F_VOIDSIG)) { + return "Void-Signature System must be salvaged or scrapped first."; + } else if (equipmentType.hasFlag(MiscType.F_CHAMELEON_SHIELD)) { + return "Chameleon shield must be salvaged or scrapped first."; + } + } + } + if (slot.isRepairable()) { return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first."; } diff --git a/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java b/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java index d43b66c1a1..b631c966bd 100644 --- a/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java +++ b/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java @@ -27,6 +27,7 @@ import megamek.common.IArmorState; import megamek.common.LandAirMech; import megamek.common.Mech; +import megamek.common.MiscType; import megamek.common.TechAdvancement; import mekhq.MekHqXmlUtil; import mekhq.campaign.Campaign; @@ -244,8 +245,8 @@ public String checkFixable() { //certain other specific crits need to be left out (uggh, must be a better way to do this!) if (slot.getType() == CriticalSlot.TYPE_SYSTEM) { // Skip Hip and Shoulder actuators - if ((slot.getIndex() == Mech.ACTUATOR_HIP - || slot.getIndex() == Mech.ACTUATOR_SHOULDER)) { + if ((slot.getIndex() == Mech.ACTUATOR_HIP) + || (slot.getIndex() == Mech.ACTUATOR_SHOULDER)) { continue; } if (unit.getEntity() instanceof LandAirMech) { @@ -265,7 +266,19 @@ public String checkFixable() { } } } + } else if (slot.getType() == CriticalSlot.TYPE_EQUIPMENT) { + if ((slot.getMount() != null) && !slot.getMount().isDestroyed()) { + EquipmentType equipmentType = slot.getMount().getType(); + if (equipmentType.hasFlag(MiscType.F_NULLSIG)) { + return "Null-Signature System must be salvaged or scrapped first. It can then be re-installed."; + } else if (equipmentType.hasFlag(MiscType.F_VOIDSIG)) { + return "Void-Signature System must be salvaged or scrapped first. It can then be re-installed."; + } else if (equipmentType.hasFlag(MiscType.F_CHAMELEON_SHIELD)) { + return "Chameleon shield must be salvaged or scrapped first. It can then be re-installed."; + } + } } + if (slot.isRepairable()) { return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first. They can then be re-installed."; } diff --git a/MekHQ/src/mekhq/campaign/parts/equipment/EquipmentPart.java b/MekHQ/src/mekhq/campaign/parts/equipment/EquipmentPart.java index b590d82077..93788faaa6 100644 --- a/MekHQ/src/mekhq/campaign/parts/equipment/EquipmentPart.java +++ b/MekHQ/src/mekhq/campaign/parts/equipment/EquipmentPart.java @@ -405,7 +405,7 @@ public String checkFixable() { if (unit.isLocationBreached(loc)) { return unit.getEntity().getLocationName(loc) + " is breached."; } - + if (unit.isLocationDestroyed(loc)) { return unit.getEntity().getLocationName(loc) + " is destroyed."; } @@ -701,7 +701,7 @@ private static void checkWeaponBay(Unit unit, EquipmentType type, int equipmentN } // if we are still here then we need to check the other weapons, if any of them - // are usable then we should do the same thing. Otherwise all weapons are destroyed + // are usable then we should do the same thing. Otherwise all weapons are destroyed // and we should mark the bay as unusuable. for (int wId : weaponBay.getBayWeapons()) { final Mounted m = unit.getEntity().getEquipment(wId); From 1b44d5eb0357eeb87881925cbe25bb571a325368 Mon Sep 17 00:00:00 2001 From: Windchild292 Date: Tue, 23 Feb 2021 12:54:11 -0700 Subject: [PATCH 2/2] Applying return text changes from review --- .../src/mekhq/campaign/parts/MissingMekLocation.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java b/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java index b631c966bd..46d1ee47b9 100644 --- a/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java +++ b/MekHQ/src/mekhq/campaign/parts/MissingMekLocation.java @@ -255,14 +255,14 @@ public String checkFixable() { if (unit.findPart(p -> p instanceof MissingLandingGear) != null) { continue; } else { - return "Landing gear in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first. They can then be re-installed."; + return "Landing gear in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first."; } // Skip Avionics if already gone } else if (slot.getIndex() == LandAirMech.LAM_AVIONICS) { if (unit.findPart(p -> p instanceof MissingAvionics) != null) { continue; } else { - return "Avionics in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first. They can then be re-installed."; + return "Avionics in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first."; } } } @@ -270,17 +270,17 @@ public String checkFixable() { if ((slot.getMount() != null) && !slot.getMount().isDestroyed()) { EquipmentType equipmentType = slot.getMount().getType(); if (equipmentType.hasFlag(MiscType.F_NULLSIG)) { - return "Null-Signature System must be salvaged or scrapped first. It can then be re-installed."; + return "Null-Signature System must be salvaged or scrapped first."; } else if (equipmentType.hasFlag(MiscType.F_VOIDSIG)) { - return "Void-Signature System must be salvaged or scrapped first. It can then be re-installed."; + return "Void-Signature System must be salvaged or scrapped first."; } else if (equipmentType.hasFlag(MiscType.F_CHAMELEON_SHIELD)) { - return "Chameleon shield must be salvaged or scrapped first. It can then be re-installed."; + return "Chameleon shield must be salvaged or scrapped first."; } } } if (slot.isRepairable()) { - return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first. They can then be re-installed."; + return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first."; } } return null;