Skip to content

Commit

Permalink
Merge pull request #5747 from IllianiCBT/resupply_clans
Browse files Browse the repository at this point in the history
Added Clan and Inner Sphere Resupply Restrictions
  • Loading branch information
HammerGS authored Jan 15, 2025
2 parents 1aa1816 + 6a03e7d commit 28c9749
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -522,6 +524,10 @@ private Map<String, PartDetails> collectParts() {
final Collection<UUID> unitIds = campaign.getForce(0).getAllUnits(true);
Map<String, PartDetails> 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);
Expand All @@ -543,6 +549,16 @@ private Map<String, PartDetails> collectParts() {
if (!unit.isSalvage() && (unit.isAvailable() || unit.isDeployed())) {
List<Part> parts = unit.getParts();
for (Part part : parts) {
if (part.isClan()) {
if (!allowClan) {
continue;
}
} else {
if (!allowInnerSphere) {
continue;
}
}

if (isIneligiblePart(part, unit)) {
continue;
}
Expand Down

0 comments on commit 28c9749

Please sign in to comment.