Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion megamek/i18n/megamek/common/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,9 @@ MovementType.Fighter=Fighter
MovementType.Rail=Rail
MovementType.MagLev=MagLev
MovementType.Airship=Airship
MovementType.StationKeeping=Station Keeping
MovementType.StationKeeping=Station Keeping

MiscType.drones=drones
MiscType.drone=drone
MiscType.theaters=theaters
MiscType.theater=theater
4 changes: 2 additions & 2 deletions megamek/src/megamek/common/Aero.java
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
defEqBV += etype.getBV(this);
bvText.append(startRow);
bvText.append(startColumn);
bvText.append(etype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append("+");
Expand Down Expand Up @@ -2275,7 +2275,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
bvText.append(startRow);
bvText.append(startColumn);

bvText.append(mtype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append(endColumn);
Expand Down
3 changes: 1 addition & 2 deletions megamek/src/megamek/common/BattleArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1440,8 +1440,7 @@ && getModel().equals("[Flamer]")
for (Mounted mounted : getEquipment()) {
if ((mounted.getType() instanceof MiscType)
&& ((MiscType) mounted.getType()).hasFlag(MiscType.F_BA_MANIPULATOR)) {
long itemCost = (long) mounted.getType().getCost(this,
mounted.isArmored(), mounted.getLocation());
long itemCost = (long) mounted.getCost();
manipulatorCost += itemCost;
}

Expand Down
6 changes: 3 additions & 3 deletions megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -6943,10 +6943,10 @@ public static int getAdditionalNonGunner(Entity entity) {
crew += (int) m.getTonnage();
} else if (m.getType().hasFlag(MiscType.F_FIELD_KITCHEN)) {
crew += 3;
} else if (m.getType().hasFlag(MiscType.F_MASH)
|| m.getType().hasFlag(MiscType.F_MASH_EXTRA)
|| m.getType().hasFlag(MiscType.F_MOBILE_FIELD_BASE)) {
} else if (m.getType().hasFlag(MiscType.F_MOBILE_FIELD_BASE)) {
crew += 5;
} else if (m.getType().hasFlag(MiscType.F_MASH)) {
crew += 5 * (int) m.getSize();
}
}
return crew;
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/common/Dropship.java
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
defEqBV += etype.getBV(this);
bvText.append(startRow);
bvText.append(startColumn);
bvText.append(etype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append("+");
Expand Down Expand Up @@ -1325,7 +1325,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
bvText.append(startRow);
bvText.append(startColumn);

bvText.append(mtype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append(endColumn);
Expand Down
7 changes: 3 additions & 4 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10657,8 +10657,7 @@ public long getWeaponsAndEquipmentCost(boolean ignoreAmmo) {
if (mounted.isWeaponGroup()) {
continue;
}
long itemCost = (long) mounted.getType().getCost(this,
mounted.isArmored(), mounted.getLocation());
long itemCost = (long) mounted.getCost();

cost += itemCost;
if ((bvText != null) && (itemCost > 0)) {
Expand Down Expand Up @@ -13475,8 +13474,8 @@ public void addBattleForceSpecialAbilities(Map<BattleForceSPA,Integer> specialAb
specialAbilities.put(BattleForceSPA.CASEII, null);
} else if (m.getType().hasFlag(MiscType.F_DRONE_OPERATING_SYSTEM)) {
specialAbilities.put(BattleForceSPA.DRO, null);
} else if (m.getType().hasFlag(MiscType.F_DRONE_EXTRA)) {
specialAbilities.merge(BattleForceSPA.DCC, 1, Integer::sum);
} else if (m.getType().hasFlag(MiscType.F_DRONE_CARRIER_CONTROL)) {
specialAbilities.merge(BattleForceSPA.DCC, (int) m.getSize(), Integer::sum);
} else if (m.getType().hasFlag(MiscType.F_EJECTION_SEAT)) {
specialAbilities.put(BattleForceSPA.ES, null);
} else if (m.getType().hasFlag(MiscType.F_ECM)) {
Expand Down
70 changes: 63 additions & 7 deletions megamek/src/megamek/common/EquipmentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ public String getName() {
return name;
}

public String getName(double size) {
return getName();
}

public String getDesc() {
String result = EquipmentMessages.getString("EquipmentType." + name);
if (result != null) {
Expand All @@ -248,6 +252,10 @@ public String getDesc() {
return name;
}

public String getDesc(double size) {
return getDesc();
}

public String getInternalName() {
return internalName;
}
Expand Down Expand Up @@ -318,7 +326,19 @@ public SimpleTechLevel getStaticTechLevel() {
* @return The weight of the equipment in tons
*/
public double getTonnage(@Nullable Entity entity) {
return getTonnage(entity, Entity.LOC_NONE);
return getTonnage(entity, Entity.LOC_NONE, 1.0);
}

/**
* Calculates the weight of the equipment. If {@code entity} is {@code null}, equipment without
* a fixed weight will return {@link EquipmentType#TONNAGE_VARIABLE}.
*
* @param entity The unit the equipment is mounted on
* @param size The size of variable-sized equipment
* @return The weight of the equipment in tons
*/
public double getTonnage(@Nullable Entity entity, double size) {
return getTonnage(entity, Entity.LOC_NONE, size);
}

/**
Expand All @@ -327,9 +347,10 @@ public double getTonnage(@Nullable Entity entity) {
*
* @param entity The unit the equipment is mounted on
* @param location The mount location
* @param size The size (for variable-sized equipment)
* @return The weight of the equipment in tons
*/
public double getTonnage(Entity entity, int location) {
public double getTonnage(Entity entity, int location, double size) {
return tonnage;
}

Expand All @@ -341,14 +362,15 @@ public double getTonnage(Entity entity, int location) {
*
* @param entity The unit the equipment is mounted on
* @param location The mount location
* @param size The size (for variable-sized equipment)
* @param defaultMethod The rounding method to use for any variable weight equipment. Any equipment
* that is normally rounded to either the half ton or kg based on unit type
* will have this method applied instead.
* @return The weight of the equipment in tons
*/
public double getTonnage(Entity entity, int location, RoundWeight defaultMethod) {
public double getTonnage(Entity entity, int location, double size, RoundWeight defaultMethod) {
// Default implementation does not deal with variable-weight equipment.
return getTonnage(entity, location);
return getTonnage(entity, location, size);
}

void setTonnage(double tonnage) {
Expand Down Expand Up @@ -1046,9 +1068,18 @@ public static TechAdvancement getStructureTechAdvancement(int at, boolean clan)
}

/**
* For variable-sized equipment this assumes a size of 1.0.
*
* @return The C-Bill cost of the piece of equipment.
*/
public double getCost(Entity entity, boolean armored, int loc) {
return getCost(entity, armored, loc, 1.0);
}

/**
* @return The C-Bill cost of the piece of equipment.
*/
public double getCost(Entity entity, boolean armored, int loc, double size) {
return cost;
}

Expand Down Expand Up @@ -1081,6 +1112,28 @@ public boolean isVariableCriticals() {
return criticals == CRITICALS_VARIABLE;
}

/**
* @return Whether the item's size is variable independent of external factors
*/
public boolean isVariableSize() {
return false;
}

/**
* @return The increment between sizes of variable-sized equipment
*/
public Double variableStepSize() {
return 1.0;
}

/**
* @return The maximum size of variable-sized equipment. Items with no maximum
* return {@code null}.
*/
public @Nullable Double variableMaxSize() {
return null;
}

public TechAdvancement getTechAdvancement() {
return techAdvancement;
}
Expand Down Expand Up @@ -1346,7 +1399,7 @@ public static void writeEquipmentExtendedDatabase(File f) {
if (type.cost == EquipmentType.COST_VARIABLE) {
w.write("Variable");
} else {
w.write(Double.toString(type.getCost(null, false, -1)));
w.write(Double.toString(type.getCost(null, false, -1, 1.0)));
}
w.write(",");
if (type.bv == EquipmentType.BV_VARIABLE) {
Expand Down Expand Up @@ -1384,13 +1437,16 @@ protected static GameOptions getGameOptions() {
}

public String getShortName() {
if (shortName.trim().length() < 1) {
if (shortName.trim().isEmpty()) {
return getName();
}

return shortName;
}

public String getShortName(double size) {
return getShortName();
}

@Override
public boolean isIntroLevel() {
return techAdvancement.isIntroLevel();
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/common/Jumpship.java
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
defEqBV += etype.getBV(this);
bvText.append(startRow);
bvText.append(startColumn);
bvText.append(etype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append("+");
Expand Down Expand Up @@ -1827,7 +1827,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
bvText.append(startRow);
bvText.append(startColumn);

bvText.append(mtype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append(endColumn);
Expand Down
7 changes: 5 additions & 2 deletions megamek/src/megamek/common/Mech.java
Original file line number Diff line number Diff line change
Expand Up @@ -3612,7 +3612,7 @@ public int calculateBattleValue(boolean ignoreC3, boolean ignorePilot) {
bvText.append(startRow);
bvText.append(startColumn);

bvText.append(etype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append(endColumn);
Expand Down Expand Up @@ -4932,7 +4932,7 @@ && hasFunctionalArmAES(mounted.getLocation())) {
bvText.append(startRow);
bvText.append(startColumn);

bvText.append(mtype.getName());
bvText.append(mounted.getName());
bvText.append(endColumn);
bvText.append(startColumn);
bvText.append(endColumn);
Expand Down Expand Up @@ -6915,6 +6915,9 @@ private String decodeCritical(CriticalSlot cs) {
if (m.isOmniPodMounted()) {
toReturn.append(" ").append(MtfFile.OMNIPOD);
}
if (m.getType().isVariableSize()) {
toReturn.append(MtfFile.SIZE).append(m.getSize());
}
} else {
return "?" + index;
}
Expand Down
Loading