From 2c2a396a0609c1ffbedd5faa5ddeda430ee721a8 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 10 Jan 2025 10:38:49 -0600 Subject: [PATCH 1/3] Add Clan and Inner Sphere purchase restrictions Implemented conditions to differentiate purchase eligibility for Clan and Inner Sphere parts based on campaign settings and the timeline relative to the Battle of Tukayyid. This ensures faction-specific rules for resupply operations are enforced consistently. --- .../mission/resupplyAndCaches/Resupply.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java index 4e98dab774..4aa4acc6f9 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java @@ -19,6 +19,7 @@ import mekhq.campaign.universe.Faction; import java.math.BigInteger; +import java.time.LocalDate; import java.util.*; import static java.lang.Math.floor; @@ -68,6 +69,7 @@ public class Resupply { public static final int CARGO_MULTIPLIER = 4; public static final int RESUPPLY_AMMO_TONNAGE = 1; public static final int RESUPPLY_ARMOR_TONNAGE = 5; + final LocalDate BATTLE_OF_TUKAYYID = LocalDate.of(3052, 5, 21); private static final MMLogger logger = MMLogger.create(Resupply.class); @@ -522,6 +524,10 @@ private Map collectParts() { final Collection unitIds = campaign.getForce(0).getAllUnits(true); Map processedParts = new HashMap<>(); + boolean allowClan = (employerIsClan || campaign.getLocalDate().isAfter(BATTLE_OF_TUKAYYID)) + && campaign.getCampaignOptions().isAllowClanPurchases(); + boolean allowInnerSphere = campaign.getCampaignOptions().isAllowISPurchases(); + try { for (UUID unitId : unitIds) { Unit unit = campaign.getUnit(unitId); @@ -543,6 +549,16 @@ private Map collectParts() { if (!unit.isSalvage() && (unit.isAvailable() || unit.isDeployed())) { List parts = unit.getParts(); for (Part part : parts) { + if (part.isClan()) { + if (!allowClan) { + continue; + } + } else { + if (!allowInnerSphere) { + continue; + } + } + if (isIneligiblePart(part, unit)) { continue; } From 60bd3d073a18961e768a00a969b570bd5d63b1e3 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 10 Jan 2025 10:41:24 -0600 Subject: [PATCH 2/3] Refactored resupply logic to simplify purchase checks Removed unnecessary `allowInnerSphere` check and streamlined logic for determining eligible parts based on clan status. Improved readability and maintainability by consolidating conditional checks. --- .../mission/resupplyAndCaches/Resupply.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java index 4aa4acc6f9..822c08628f 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java @@ -524,9 +524,7 @@ private Map collectParts() { final Collection unitIds = campaign.getForce(0).getAllUnits(true); Map processedParts = new HashMap<>(); - boolean allowClan = (employerIsClan || campaign.getLocalDate().isAfter(BATTLE_OF_TUKAYYID)) - && campaign.getCampaignOptions().isAllowClanPurchases(); - boolean allowInnerSphere = campaign.getCampaignOptions().isAllowISPurchases(); + boolean allowClan = (employerIsClan || campaign.getLocalDate().isAfter(BATTLE_OF_TUKAYYID)); try { for (UUID unitId : unitIds) { @@ -549,14 +547,8 @@ private Map collectParts() { if (!unit.isSalvage() && (unit.isAvailable() || unit.isDeployed())) { List parts = unit.getParts(); for (Part part : parts) { - if (part.isClan()) { - if (!allowClan) { - continue; - } - } else { - if (!allowInnerSphere) { - continue; - } + if (part.isClan() && !allowClan) { + continue; } if (isIneligiblePart(part, unit)) { From 6a03e7dc25457b9c8aed61972af367f3e9396380 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 10 Jan 2025 10:42:15 -0600 Subject: [PATCH 3/3] Enforced campaign options for Clan and Inner Sphere purchases Added checks to respect campaign settings for allowing Clan and Inner Sphere part purchases during resupply. This ensures purchase availability aligns with the configured campaign options. --- .../mission/resupplyAndCaches/Resupply.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java index 822c08628f..4aa4acc6f9 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java @@ -524,7 +524,9 @@ private Map collectParts() { final Collection unitIds = campaign.getForce(0).getAllUnits(true); Map processedParts = new HashMap<>(); - boolean allowClan = (employerIsClan || campaign.getLocalDate().isAfter(BATTLE_OF_TUKAYYID)); + boolean allowClan = (employerIsClan || campaign.getLocalDate().isAfter(BATTLE_OF_TUKAYYID)) + && campaign.getCampaignOptions().isAllowClanPurchases(); + boolean allowInnerSphere = campaign.getCampaignOptions().isAllowISPurchases(); try { for (UUID unitId : unitIds) { @@ -547,8 +549,14 @@ private Map collectParts() { if (!unit.isSalvage() && (unit.isAvailable() || unit.isDeployed())) { List parts = unit.getParts(); for (Part part : parts) { - if (part.isClan() && !allowClan) { - continue; + if (part.isClan()) { + if (!allowClan) { + continue; + } + } else { + if (!allowInnerSphere) { + continue; + } } if (isIneligiblePart(part, unit)) {