From 18faf74d8eb7be889906d6b0e71c8cda66ae1616 Mon Sep 17 00:00:00 2001 From: cwspain Date: Tue, 2 Jan 2024 18:36:52 -0600 Subject: [PATCH 1/3] Make more obvious that SpaceStation::modular does double duty. Fix cost multiplier calculation for non-modular stations with kf adapter. --- megamek/src/megamek/common/SpaceStation.java | 27 +++++++++++++------ .../src/megamek/common/loaders/BLKFile.java | 4 +-- .../common/loaders/BLKSpaceStationFile.java | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/megamek/src/megamek/common/SpaceStation.java b/megamek/src/megamek/common/SpaceStation.java index a6885da71bc..6c6bbfc5928 100644 --- a/megamek/src/megamek/common/SpaceStation.java +++ b/megamek/src/megamek/common/SpaceStation.java @@ -24,7 +24,7 @@ public class SpaceStation extends Jumpship { private static final long serialVersionUID = -3160156173650960985L; // This only affects cost, but may have an effect in a large-scale strategic setting. - private boolean modular = false; + private boolean modularOrKFAdapter = false; @Override public int getUnitType() { @@ -52,7 +52,7 @@ public SpaceStation() { @Override public TechAdvancement getConstructionTechAdvancement() { - return modular? TA_SPACE_STATION_MODULAR : TA_SPACE_STATION; + return modularOrKFAdapter ? TA_SPACE_STATION_MODULAR : TA_SPACE_STATION; } public static TechAdvancement getModularTA() { @@ -61,17 +61,22 @@ public static TechAdvancement getModularTA() { /** * Designates whether this is a modular space station - * @param modular + * @param modularOrKFAdapter Whether the space station can be transported by jumpship. */ - public void setModular(boolean modular) { - this.modular = modular; + public void setModularOrKFAdapter(boolean modularOrKFAdapter) { + this.modularOrKFAdapter = modularOrKFAdapter; } /** - * @return True if this space station has a modular construction, otherwise false. + * @return True if this space station has a modular construction (or has a KF adapter for stations less than 100kt, + * otherwise false. */ + public boolean isModularOrKFAdapter() { + return modularOrKFAdapter; + } + public boolean isModular() { - return modular; + return modularOrKFAdapter && getWeight() > 100000; } @Override @@ -81,7 +86,13 @@ public double getCost(CalculationReport calcReport, boolean ignoreAmmo) { @Override public double getPriceMultiplier() { - return modular ? 50.0 : 5.0; + if (isModular()) { + return 50.0; + } else if (modularOrKFAdapter) { + return 20.0; + } else { + return 5.0; + } } /** diff --git a/megamek/src/megamek/common/loaders/BLKFile.java b/megamek/src/megamek/common/loaders/BLKFile.java index 26ad00ea777..dbe02215953 100644 --- a/megamek/src/megamek/common/loaders/BLKFile.java +++ b/megamek/src/megamek/common/loaders/BLKFile.java @@ -26,8 +26,6 @@ import megamek.common.util.BuildingBlock; import megamek.common.weapons.bayweapons.BayWeapon; import megamek.common.weapons.infantry.InfantryWeapon; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; public class BLKFile { @@ -1106,7 +1104,7 @@ public static BuildingBlock getBlock(Entity t) { blk.writeBlockData("jump_range", ws.getJumpRange()); } } else if ((t instanceof SpaceStation) - && ((SpaceStation) t).isModular()) { + && ((SpaceStation) t).isModularOrKFAdapter()) { blk.writeBlockData("modular", 1); } diff --git a/megamek/src/megamek/common/loaders/BLKSpaceStationFile.java b/megamek/src/megamek/common/loaders/BLKSpaceStationFile.java index bd2d5a6af45..ab5d8335282 100644 --- a/megamek/src/megamek/common/loaders/BLKSpaceStationFile.java +++ b/megamek/src/megamek/common/loaders/BLKSpaceStationFile.java @@ -125,7 +125,7 @@ public Entity getEntity() throws EntityLoadingException { } if (dataFile.exists("modular")) { - a.setModular(true); + a.setModularOrKFAdapter(true); } // Grav Decks - two approaches From f26979fd0397a96eaae2ed69b2f308ef69d00b3c Mon Sep 17 00:00:00 2001 From: cwspain Date: Tue, 2 Jan 2024 18:45:41 -0600 Subject: [PATCH 2/3] Add tech advancement for non-modular station with KF adapter. --- megamek/src/megamek/common/SpaceStation.java | 28 +++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/megamek/src/megamek/common/SpaceStation.java b/megamek/src/megamek/common/SpaceStation.java index 6c6bbfc5928..28fae4ef69f 100644 --- a/megamek/src/megamek/common/SpaceStation.java +++ b/megamek/src/megamek/common/SpaceStation.java @@ -43,6 +43,14 @@ public SpaceStation() { .setAvailability(RATING_C, RATING_D, RATING_C, RATING_C) .setStaticTechLevel(SimpleTechLevel.ADVANCED); + private static final TechAdvancement TA_SPACE_STATION_KF_ADAPTER = new TechAdvancement(TECH_BASE_ALL) + .setISAdvancement(2350, 2375, DATE_NONE, 2850, 3048).setClanAdvancement(2350, 2375) + .setPrototypeFactions(F_TH).setProductionFactions(F_TH) + // The adapter itself is tech rating C, but this is the base for a station with an adapter. + .setReintroductionFactions(F_FS).setTechRating(RATING_D) + .setAvailability(RATING_D, RATING_F, RATING_D, RATING_D) + .setStaticTechLevel(SimpleTechLevel.ADVANCED); + private static final TechAdvancement TA_SPACE_STATION_MODULAR = new TechAdvancement(TECH_BASE_ALL) .setISAdvancement(2565, 2585, DATE_NONE, 2790, 3090).setClanAdvancement(2565, 2585) .setPrototypeFactions(F_TH).setProductionFactions(F_TH) @@ -52,13 +60,21 @@ public SpaceStation() { @Override public TechAdvancement getConstructionTechAdvancement() { - return modularOrKFAdapter ? TA_SPACE_STATION_MODULAR : TA_SPACE_STATION; + if (isModular()) { + return TA_SPACE_STATION_MODULAR; + } else if (hasKFAdapter()) { + return TA_SPACE_STATION_KF_ADAPTER; + } else { + return TA_SPACE_STATION; + } } - + + public static TechAdvancement getKFAdapterTA() { return TA_SPACE_STATION_KF_ADAPTER; } + public static TechAdvancement getModularTA() { return TA_SPACE_STATION_MODULAR; } - + /** * Designates whether this is a modular space station * @param modularOrKFAdapter Whether the space station can be transported by jumpship. @@ -79,6 +95,10 @@ public boolean isModular() { return modularOrKFAdapter && getWeight() > 100000; } + public boolean hasKFAdapter() { + return modularOrKFAdapter && getWeight() <= 100000; + } + @Override public double getCost(CalculationReport calcReport, boolean ignoreAmmo) { return SpaceStationCostCalculator.calculateCost(this, calcReport, ignoreAmmo); @@ -88,7 +108,7 @@ public double getCost(CalculationReport calcReport, boolean ignoreAmmo) { public double getPriceMultiplier() { if (isModular()) { return 50.0; - } else if (modularOrKFAdapter) { + } else if (hasKFAdapter()) { return 20.0; } else { return 5.0; From d8e61bfbbd0ce0945a8439cf93c27fe2d3f6e87e Mon Sep 17 00:00:00 2001 From: cwspain Date: Tue, 2 Jan 2024 18:58:25 -0600 Subject: [PATCH 3/3] Change label of modular checkbox depending on weight of station. --- megamek/src/megamek/common/SpaceStation.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/common/SpaceStation.java b/megamek/src/megamek/common/SpaceStation.java index 28fae4ef69f..14da6ecd2cf 100644 --- a/megamek/src/megamek/common/SpaceStation.java +++ b/megamek/src/megamek/common/SpaceStation.java @@ -22,7 +22,10 @@ */ public class SpaceStation extends Jumpship { private static final long serialVersionUID = -3160156173650960985L; - + + /** A station over this weight in may built as a modular station. */ + public static final double MODULAR_MININUM_WEIGHT = 100000.0; + // This only affects cost, but may have an effect in a large-scale strategic setting. private boolean modularOrKFAdapter = false; @@ -92,11 +95,11 @@ public boolean isModularOrKFAdapter() { } public boolean isModular() { - return modularOrKFAdapter && getWeight() > 100000; + return modularOrKFAdapter && getWeight() > MODULAR_MININUM_WEIGHT; } public boolean hasKFAdapter() { - return modularOrKFAdapter && getWeight() <= 100000; + return modularOrKFAdapter && getWeight() <= MODULAR_MININUM_WEIGHT; } @Override