Skip to content

Commit f3bf055

Browse files
committed
Implement Obsolete quirk effects for campaign play
Adds campaign effects for the Obsolete quirk per BMM pg 86: - Maintenance rolls: +1 to +5 TN modifier based on years obsolete - Repair rolls: +1 to +5 TN modifier based on years obsolete - Resale value: 50%-100% multiplier based on years obsolete Changes: - Maintenance.java: Added obsolete modifier to getTargetForMaintenance() - Part.java: Added obsolete modifier to getAllMods() and getAllModsForMaintenance() - Unit.java: Applied obsolete resale modifier in getSellValue() - Added i18n keys for modifier descriptions --- PR Notes ## Summary Implements campaign effects for the Obsolete quirk from BattleMech Manual pg 86. Units with the Obsolete quirk now suffer penalties in MekHQ campaigns: - **Maintenance rolls**: +1 TN per 15 years obsolete (max +5) - **Repair rolls**: +1 TN per 15 years obsolete (max +5) - **Resale value**: -10% per 20 years obsolete (min 50%) ## Changes ### Maintenance & Repair TN Modifiers - **Maintenance.java**: Added obsolete modifier to `getTargetForMaintenance()` - **Part.java**: Added obsolete modifier to `getAllMods()` (repair work) and `getAllModsForMaintenance()` ### Resale Value - **Unit.java**: Applied `entity.getObsoleteResaleModifier()` in `getSellValue()` for both standard units and Infantry ### Internationalization - **Maintenance.properties**: Added `Maintenance.modifier.obsolete` - **Parts.properties**: Added `Part.modifier.obsolete` ## Dependencies - Requires MegaMek PR with Obsolete quirk implementation (provides `Entity.getObsoleteRepairModifier()` and `Entity.getObsoleteResaleModifier()`) ## Test Plan - [ ] Load campaign with unit that has Obsolete quirk set - [ ] Verify maintenance rolls show "obsolete" modifier in TN breakdown - [ ] Verify repair rolls show "obsolete" modifier in TN breakdown - [ ] Verify unit sell value is reduced based on years obsolete - [ ] Test with Infantry units (uses different sell value calculation)
1 parent 18e2467 commit f3bf055

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

MekHQ/resources/mekhq/resources/Maintenance.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ Maintenance.unableToMaintain={0}<b>Warning:</b>{1} {2} has realized they don''t
3333
This unit should be immediately reassigned to another tech, or maintenance time should be reduced.
3434
Maintenance.largeVessel={0}<b>Warning:</b>{1} {2} has realized they don''t have enough time to maintain {3}. \
3535
Maintenance time should be immediately reduced.
36+
# Modifier descriptions
37+
Maintenance.modifier.obsolete=obsolete

MekHQ/resources/mekhq/resources/Parts.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ PartRepairType.MEK_LOCATION.text=Locations
4949
PartRepairType.PHYSICAL_WEAPON.text=Physical Weapon
5050
PartRepairType.POD_SPACE.text=Pod
5151
PartRepairType.UNKNOWN_LOCATION.text=Error: Unknown Repair Type
52+
# Modifier descriptions
53+
Part.modifier.obsolete=obsolete

MekHQ/src/mekhq/campaign/parts/Part.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
*/
3434
package mekhq.campaign.parts;
3535

36+
import static mekhq.utilities.MHQInternationalization.getFormattedTextAt;
37+
3638
import java.io.PrintWriter;
3739
import java.text.DecimalFormat;
3840
import java.util.ArrayList;
@@ -104,6 +106,7 @@
104106
*/
105107
public abstract class Part implements IPartWork, ITechnology {
106108
private static final MMLogger LOGGER = MMLogger.create(Part.class);
109+
private static final String RESOURCE_BUNDLE = "mekhq.resources.Parts";
107110

108111
private static final DecimalFormat TONNAGE_FORMATTER = new DecimalFormat("0.#");
109112

@@ -975,6 +978,13 @@ public TargetRoll getAllMods(final @Nullable Person tech) {
975978
mods.addModifier(1, "difficult to maintain");
976979
}
977980

981+
// Apply obsolete quirk modifier
982+
int obsoleteMod = getUnit().getEntity().getObsoleteRepairModifier(campaign.getGameYear());
983+
if (obsoleteMod > 0) {
984+
mods.addModifier(obsoleteMod,
985+
getFormattedTextAt(RESOURCE_BUNDLE, "Part.modifier.obsolete"));
986+
}
987+
978988
if (getUnit().hasPrototypeTSM() &&
979989
((this instanceof MekLocation) ||
980990
(this instanceof MissingMekLocation) ||
@@ -1033,6 +1043,13 @@ public TargetRoll getAllModsForMaintenance() {
10331043
mods.addModifier(1, "difficult to maintain");
10341044
}
10351045

1046+
// Apply obsolete quirk modifier
1047+
int obsoleteMod = getUnit().getEntity().getObsoleteRepairModifier(campaign.getGameYear());
1048+
if (obsoleteMod > 0) {
1049+
mods.addModifier(obsoleteMod,
1050+
getFormattedTextAt(RESOURCE_BUNDLE, "Part.modifier.obsolete"));
1051+
}
1052+
10361053
if (getUnit().getTech() != null) {
10371054
if (getUnit().getTech().getOptions().booleanOption(PersonnelOptions.TECH_WEAPON_SPECIALIST) &&
10381055
((IPartWork.findCorrectRepairType(this) == PartRepairType.WEAPON) ||

MekHQ/src/mekhq/campaign/unit/Maintenance.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,16 @@ public static TargetRoll getTargetForMaintenance(Campaign campaign, IPartWork pa
420420

421421
target.append(partWork.getAllModsForMaintenance());
422422

423+
// Apply obsolete quirk modifier
424+
Unit unit = partWork.getUnit();
425+
if (unit != null && unit.getEntity() != null) {
426+
int obsoleteMod = unit.getEntity().getObsoleteRepairModifier(campaign.getGameYear());
427+
if (obsoleteMod > 0) {
428+
target.addModifier(obsoleteMod,
429+
getFormattedTextAt(RESOURCE_BUNDLE, "Maintenance.modifier.obsolete"));
430+
}
431+
}
432+
423433
if (campaignOptions.isUseEraMods()) {
424434
target.addModifier(campaign.getFaction().getEraMod(campaign.getGameYear()), "era");
425435
}

MekHQ/src/mekhq/campaign/unit/Unit.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,14 +1459,22 @@ public Money getSellValue() {
14591459
Money unitCost = Money.of(entity.getAlternateCost());
14601460
double[] usedPartPriceMultipliers = campaign.getCampaignOptions().getUsedPartPriceMultipliers();
14611461

1462-
return switch (this.getQuality()) {
1462+
Money infantryValue = switch (this.getQuality()) {
14631463
case QUALITY_A -> unitCost.multipliedBy(usedPartPriceMultipliers[0]);
14641464
case QUALITY_B -> unitCost.multipliedBy(usedPartPriceMultipliers[1]);
14651465
case QUALITY_C -> unitCost.multipliedBy(usedPartPriceMultipliers[2]);
14661466
case QUALITY_D -> unitCost.multipliedBy(usedPartPriceMultipliers[3]);
14671467
case QUALITY_E -> unitCost.multipliedBy(usedPartPriceMultipliers[4]);
14681468
case QUALITY_F -> unitCost.multipliedBy(usedPartPriceMultipliers[5]);
14691469
};
1470+
1471+
// Apply obsolete quirk resale modifier
1472+
double obsoleteMult = entity.getObsoleteResaleModifier(campaign.getGameYear());
1473+
if (obsoleteMult < 1.0) {
1474+
infantryValue = infantryValue.multipliedBy(obsoleteMult);
1475+
}
1476+
1477+
return infantryValue;
14701478
}
14711479

14721480
// We need to adjust this for equipment that doesn't show up as parts
@@ -1553,6 +1561,12 @@ public Money getSellValue() {
15531561
// Scale the final value by the entity's price multiplier
15541562
partsValue = partsValue.multipliedBy(entity.getPriceMultiplier());
15551563

1564+
// Apply obsolete quirk resale modifier
1565+
double obsoleteMult = entity.getObsoleteResaleModifier(campaign.getGameYear());
1566+
if (obsoleteMult < 1.0) {
1567+
partsValue = partsValue.multipliedBy(obsoleteMult);
1568+
}
1569+
15561570
return partsValue;
15571571
}
15581572

0 commit comments

Comments
 (0)