Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Armor rework, part 1b #3827

Merged
merged 4 commits into from
Feb 4, 2024
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
29 changes: 8 additions & 21 deletions MekHQ/src/mekhq/campaign/market/PartsStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,29 +425,16 @@ private void stockVeeComponents(Campaign c) {

private void stockArmor(Campaign c) {
int amount;
for (int at = 0; at < EquipmentType.armorNames.length; at++) {
ArmorType is = ArmorType.of(at, false);
if (null != is) {
if (is.hasFlag(MiscType.F_BA_EQUIPMENT)) {
amount = (int)(5 * BaArmor.getPointsPerTon(at, false));
parts.add(new BaArmor(0, amount, at, -1, false, c));
} else {
amount = (int)(5.0 * is.getPointsPerTon());
parts.add(new Armor(0, at, amount, -1, false, false, c));
}
}
ArmorType clan = ArmorType.of(at, true);
if ((null != clan) && (is != clan)) {
if (clan.hasFlag(MiscType.F_BA_EQUIPMENT)) {
amount = (int)(5 * BaArmor.getPointsPerTon(at, true));
parts.add(new BaArmor(0, amount, at, -1, true, c));
} else {
amount = (int) (5.0 * clan.getPointsPerTon());
parts.add(new Armor(0, at, amount, -1, false, true, c));
}
for (ArmorType armor : ArmorType.allArmorTypes()) {
if (armor.hasFlag(MiscType.F_BA_EQUIPMENT)) {
amount = (int) (5 * armor.getWeightPerPoint());
parts.add(new BaArmor(0, amount, armor.getArmorType(), -1, armor.isClan(), c));
} else {
amount = (int) (5.0 * armor.getPointsPerTon());
parts.add(new Armor(0, armor.getArmorType(), amount, -1, false, armor.isClan(), c));
}
}
parts.add(new ProtomekArmor(0, EquipmentType.T_ARMOR_STANDARD, 100, -1, true, c));
parts.add(new ProtomekArmor(0, EquipmentType.T_ARMOR_STANDARD_PROTOMEK, 100, -1, true, c));
parts.add(new ProtomekArmor(0, EquipmentType.T_ARMOR_EDP, 66, -1, true, c));
}

Expand Down
12 changes: 6 additions & 6 deletions MekHQ/src/mekhq/campaign/parts/Armor.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Armor(int tonnage, int t, int points, int loc, boolean r, boolean clan, C
this.clan = clan;
this.name = "Armor";
if (type > -1) {
this.name += " (" + EquipmentType.armorNames[type] + ')';
this.name += " (" + ArmorType.of(type, clan).getName() + ')';
}
}

Expand All @@ -81,7 +81,7 @@ public double getTonnage() {

@Override
public Money getActualValue() {
return adjustCostsForCampaignOptions(Money.of(getTonnage() * EquipmentType.getArmorCost(type)));
return adjustCostsForCampaignOptions(Money.of(getTonnage() * ArmorType.of(type, clan).getCost()));
}

public double getTonnageNeeded() {
Expand All @@ -93,13 +93,13 @@ public double getTonnageNeeded() {
}

public Money getValueNeeded() {
return adjustCostsForCampaignOptions(Money.of(getTonnageNeeded() * EquipmentType.getArmorCost(type)));
return adjustCostsForCampaignOptions(Money.of(getTonnageNeeded() * ArmorType.of(type, clan).getCost()));
}

@Override
public Money getStickerPrice() {
// always in 5-ton increments
return Money.of(5 * EquipmentType.getArmorCost(type));
return Money.of(5 * ArmorType.of(type, clan).getCost());
}

@Override
Expand Down Expand Up @@ -568,7 +568,7 @@ public String fail(int rating) {
public String scrap() {
remove(false);
skillMin = SkillType.EXP_GREEN;
return EquipmentType.armorNames[type] + " armor scrapped.";
return ArmorType.of(type, clan).getName() + " armor scrapped.";
}

@Override
Expand Down Expand Up @@ -620,7 +620,7 @@ public void changeType(int ty, boolean cl) {
this.clan = cl;
this.name = "Armor";
if (type > -1) {
this.name += " (" + EquipmentType.armorNames[type] + ')';
this.name += " (" + ArmorType.of(type, clan).getName() + ')';
}
}

Expand Down
8 changes: 4 additions & 4 deletions MekHQ/src/mekhq/campaign/parts/ProtomekArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class ProtomekArmor extends Armor implements IAcquisitionWork {
public ProtomekArmor() {
this(0, EquipmentType.T_ARMOR_STANDARD, 0, -1, false, null);
this(0, EquipmentType.T_ARMOR_STANDARD_PROTOMEK, 0, -1, false, null);
}

public ProtomekArmor(int tonnage, int type, int points, int loc, boolean clan, Campaign c) {
Expand Down Expand Up @@ -72,14 +72,14 @@ public double getTonnageNeeded() {
@Override
public Money getValueNeeded() {
return adjustCostsForCampaignOptions(
Money.of(amountNeeded * EquipmentType.getProtomechArmorCostPerPoint(type)));
Money.of(amountNeeded * ArmorType.of(type, clan).getCost()));
}

@Override
public Money getStickerPrice() {
// always in 5-ton increments
return Money.of(5.0 / ArmorType.of(type, true).getWeightPerPoint() * getArmorPointsPerTon()
* EquipmentType.getProtomechArmorCostPerPoint(type));
* ArmorType.of(type, clan).getCost());
}

@Override
Expand Down Expand Up @@ -156,7 +156,7 @@ public void changeAmountAvailable(int amount) {

@Override
public TechAdvancement getTechAdvancement() {
if (type != EquipmentType.T_ARMOR_STANDARD) {
if (type != EquipmentType.T_ARMOR_STANDARD_PROTOMEK) {
final EquipmentType eq = EquipmentType.get(EquipmentType.getArmorTypeName(type, clan));
if (null != eq) {
return eq.getTechAdvancement();
Expand Down
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/campaign/unit/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import megamek.common.*;
import megamek.common.InfantryBay.PlatoonType;
import megamek.common.annotations.Nullable;
import megamek.common.equipment.ArmorType;
import megamek.common.icons.Camouflage;
import megamek.common.options.IOption;
import megamek.common.options.IOptionGroup;
Expand Down Expand Up @@ -1173,7 +1174,7 @@ public Money getSellValue() {
partsValue = partsValue.plus(200.0 * js.getFuel() / js.getFuelPerTon());

// armor
partsValue = partsValue.plus(js.getArmorWeight(js.locations()) * EquipmentType.getArmorCost(js.getArmorType(0)));
partsValue = partsValue.plus(js.getArmorWeight(js.locations()) * ArmorType.forEntity(js).getCost());

// heat sinks
Money sinkCost = Money.of(2000.0 + 4000.0 * js.getHeatType());// == HEAT_DOUBLE ? 6000 : 2000
Expand Down
Loading