Skip to content

Commit

Permalink
Merge pull request #5007 from MegaMek/modular_ss
Browse files Browse the repository at this point in the history
Space station KF adapters
  • Loading branch information
SJuliez authored Jan 3, 2024
2 parents 31e4214 + d8e61bf commit a7cbd85
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
56 changes: 45 additions & 11 deletions megamek/src/megamek/common/SpaceStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
*/
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 modular = false;
private boolean modularOrKFAdapter = false;

@Override
public int getUnitType() {
Expand All @@ -43,6 +46,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)
Expand All @@ -52,26 +63,43 @@ public SpaceStation() {

@Override
public TechAdvancement getConstructionTechAdvancement() {
return modular? 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 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() > MODULAR_MININUM_WEIGHT;
}

public boolean hasKFAdapter() {
return modularOrKFAdapter && getWeight() <= MODULAR_MININUM_WEIGHT;
}

@Override
Expand All @@ -81,7 +109,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 (hasKFAdapter()) {
return 20.0;
} else {
return 5.0;
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions megamek/src/megamek/common/loaders/BLKFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Entity getEntity() throws EntityLoadingException {
}

if (dataFile.exists("modular")) {
a.setModular(true);
a.setModularOrKFAdapter(true);
}

// Grav Decks - two approaches
Expand Down

0 comments on commit a7cbd85

Please sign in to comment.