From c1c266eb1309506a0b9657b606437ecd2f622e37 Mon Sep 17 00:00:00 2001 From: cwspain Date: Sat, 27 Jan 2024 21:32:38 -0600 Subject: [PATCH 1/2] Removed armor PPT static methods from EquipmentType. --- MekHQ/src/mekhq/campaign/market/PartsStore.java | 11 +++++------ MekHQ/src/mekhq/campaign/parts/Armor.java | 12 ++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/market/PartsStore.java b/MekHQ/src/mekhq/campaign/market/PartsStore.java index 8f11617d37..79fc7af1c1 100644 --- a/MekHQ/src/mekhq/campaign/market/PartsStore.java +++ b/MekHQ/src/mekhq/campaign/market/PartsStore.java @@ -21,6 +21,7 @@ package mekhq.campaign.market; import megamek.common.*; +import megamek.common.equipment.ArmorType; import megamek.common.loaders.EntityLoadingException; import megamek.common.verifier.TestEntity; import megamek.common.weapons.InfantryAttack; @@ -425,25 +426,23 @@ private void stockVeeComponents(Campaign c) { private void stockArmor(Campaign c) { int amount; for (int at = 0; at < EquipmentType.armorNames.length; at++) { - String name = EquipmentType.getArmorTypeName(at, false); - EquipmentType is = EquipmentType.get(name); + ArmorType is = ArmorType.of(at, false); if (null != is) { if (is.hasFlag(MiscType.F_BA_EQUIPMENT)) { amount = (int)(5 * BaArmor.getPointsPerTon(at, false)); parts.add(new BaArmor(0, amount, at, -1, false, c)); } else { - amount = (int)(5.0 * 16.0 * EquipmentType.getArmorPointMultiplier(at, false)); + amount = (int)(5.0 * is.getPointsPerTon()); parts.add(new Armor(0, at, amount, -1, false, false, c)); } } - name = EquipmentType.getArmorTypeName(at, true); - EquipmentType clan = EquipmentType.get(name); + ArmorType clan = ArmorType.of(at, true); if ((null != clan) && (is != clan)) { if (clan.hasFlag(MiscType.F_BA_EQUIPMENT)) { amount = (int)(5 * BaArmor.getPointsPerTon(at, true)); parts.add(new BaArmor(0, amount, at, -1, true, c)); } else { - amount = (int) (5.0 * 16.0 * EquipmentType.getArmorPointMultiplier(at, true)); + amount = (int) (5.0 * clan.getPointsPerTon()); parts.add(new Armor(0, at, amount, -1, false, true, c)); } } diff --git a/MekHQ/src/mekhq/campaign/parts/Armor.java b/MekHQ/src/mekhq/campaign/parts/Armor.java index 00af42698c..165d036c38 100644 --- a/MekHQ/src/mekhq/campaign/parts/Armor.java +++ b/MekHQ/src/mekhq/campaign/parts/Armor.java @@ -22,6 +22,7 @@ import megamek.common.*; import megamek.common.annotations.Nullable; +import megamek.common.equipment.ArmorType; import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; @@ -84,7 +85,7 @@ public Money getActualValue() { } public double getTonnageNeeded() { - double armorPerTon = 16.0 * EquipmentType.getArmorPointMultiplier(type, isClanTechBase()); + double armorPerTon = ArmorType.of(type, isClanTechBase()).getPointsPerTon(); if (type == EquipmentType.T_ARMOR_HARDENED) { armorPerTon = 8.0; } @@ -247,8 +248,7 @@ public double getArmorWeight(int points) { // this roundabout method is actually necessary to avoid rounding // weirdness. Yeah, it's dumb. - double armorPointMultiplier = EquipmentType.getArmorPointMultiplier(getType(), isClanTechBase()); - double armorPerTon = 16.0 * armorPointMultiplier; + double armorPerTon = ArmorType.of(getType(), isClan()).getPointsPerTon(); if (getType() == EquipmentType.T_ARMOR_HARDENED) { armorPerTon = 8.0; } @@ -508,11 +508,7 @@ else if (campaign.getCampaignOptions().getIsAcquisitionPenalty() > 0) { } public double getArmorPointsPerTon() { - double armorPerTon = 16.0 * EquipmentType.getArmorPointMultiplier(type, clan); - if (type == EquipmentType.T_ARMOR_HARDENED) { - armorPerTon = 8.0; - } - return armorPerTon; + return ArmorType.of(type, clan).getPointsPerTon(); } public Part getNewPart() { From 2b2e22feeca23a1cbbf62fd7d65a8a2b02fd4500 Mon Sep 17 00:00:00 2001 From: cwspain Date: Sat, 27 Jan 2024 21:41:40 -0600 Subject: [PATCH 2/2] Removed static armor weight methods for BA and protos from EquipmentType. --- MekHQ/src/mekhq/campaign/parts/BaArmor.java | 5 +++-- MekHQ/src/mekhq/campaign/parts/ProtomekArmor.java | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/parts/BaArmor.java b/MekHQ/src/mekhq/campaign/parts/BaArmor.java index bc02e90385..20b1984602 100644 --- a/MekHQ/src/mekhq/campaign/parts/BaArmor.java +++ b/MekHQ/src/mekhq/campaign/parts/BaArmor.java @@ -23,6 +23,7 @@ import java.util.Objects; import megamek.common.EquipmentType; +import megamek.common.equipment.ArmorType; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.work.IAcquisitionWork; @@ -43,7 +44,7 @@ public static boolean canBeIs(int type) { public static double getPointsPerTon(int t, boolean isClan) { - return 1.0/EquipmentType.getBaArmorWeightPerPoint(t, isClan); + return 1.0 / ArmorType.of(t, isClan).getWeightPerPoint(); } public BaArmor() { @@ -64,7 +65,7 @@ public BaArmor clone() { @Override public double getTonnage() { - return EquipmentType.getBaArmorWeightPerPoint(type, clan) * amount; + return ArmorType.of(type, clan).getWeightPerPoint() * amount; } public Money getPointCost() { diff --git a/MekHQ/src/mekhq/campaign/parts/ProtomekArmor.java b/MekHQ/src/mekhq/campaign/parts/ProtomekArmor.java index b069fac612..41913203e3 100644 --- a/MekHQ/src/mekhq/campaign/parts/ProtomekArmor.java +++ b/MekHQ/src/mekhq/campaign/parts/ProtomekArmor.java @@ -26,6 +26,7 @@ import megamek.common.EquipmentType; import megamek.common.Protomech; import megamek.common.TechAdvancement; +import megamek.common.equipment.ArmorType; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.work.IAcquisitionWork; @@ -54,18 +55,18 @@ public ProtomekArmor clone() { @Override public double getTonnage() { - return EquipmentType.getProtomechArmorWeightPerPoint(type) * amount; + return ArmorType.of(type, true).getWeightPerPoint() * amount; } @Override public Money getActualValue() { return adjustCostsForCampaignOptions( - Money.of(amount * EquipmentType.getProtomechArmorCostPerPoint(type))); + Money.of(amount * ArmorType.of(type, true).getWeightPerPoint())); } @Override public double getTonnageNeeded() { - return amountNeeded / EquipmentType.getProtomechArmorWeightPerPoint(type); + return amountNeeded / ArmorType.of(type, true).getWeightPerPoint(); } @Override @@ -77,7 +78,7 @@ public Money getValueNeeded() { @Override public Money getStickerPrice() { // always in 5-ton increments - return Money.of(5.0 / EquipmentType.getProtomechArmorWeightPerPoint(type) * getArmorPointsPerTon() + return Money.of(5.0 / ArmorType.of(type, true).getWeightPerPoint() * getArmorPointsPerTon() * EquipmentType.getProtomechArmorCostPerPoint(type)); } @@ -117,7 +118,7 @@ public int getDifficulty() { @Override public double getArmorPointsPerTon() { - return 1.0 / EquipmentType.getProtomechArmorWeightPerPoint(type); + return 1.0 / ArmorType.of(type, true).getWeightPerPoint(); } @Override