From ab45cfc1c6ac286138adb3c6552f137d155134ae Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 30 Jul 2024 16:48:23 +0200 Subject: [PATCH 1/2] add quirks to units --- .../Caveat Emptor/Carbine CON-9M-D ConstructionMech MOD.mtf | 6 ++++++ .../mechs/XTRs/Caveat Emptor/Crosscut IIC SolahmaMech.mtf | 3 +++ 2 files changed, 9 insertions(+) diff --git a/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Carbine CON-9M-D ConstructionMech MOD.mtf b/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Carbine CON-9M-D ConstructionMech MOD.mtf index 71a2579212f..567afc193f8 100644 --- a/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Carbine CON-9M-D ConstructionMech MOD.mtf +++ b/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Carbine CON-9M-D ConstructionMech MOD.mtf @@ -9,6 +9,12 @@ source:XTR: Caveat Emptor rules level:5 role:Ambusher +quirk:illegal_design +quirk:gas_hog +quirk:stable +quirk:exp_actuator +quirk:no_twist + mass:30 engine:90 ICE Engine(IS) structure:IS Industrial diff --git a/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Crosscut IIC SolahmaMech.mtf b/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Crosscut IIC SolahmaMech.mtf index 4db846462c9..9abdcd96bd1 100644 --- a/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Crosscut IIC SolahmaMech.mtf +++ b/megamek/data/mechfiles/mechs/XTRs/Caveat Emptor/Crosscut IIC SolahmaMech.mtf @@ -14,6 +14,9 @@ engine:300 XXL (Clan) Engine(IS) structure:IS Industrial myomer:Standard +quirk:illegal_design +quirk:hard_pilot + heat sinks:11 Single walk mp:10 jump mp:0 From 083f37f75c198594af06eb35b87d82d9fad42079 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 30 Jul 2024 16:49:07 +0200 Subject: [PATCH 2/2] adaptations for illegal design quirk, remove unnecessary overrides --- .../i18n/megamek/client/messages.properties | 3 +- megamek/src/megamek/common/MechView.java | 19 ++++---- .../verifier/TestAdvancedAerospace.java | 5 +- .../src/megamek/common/verifier/TestAero.java | 9 ++-- .../common/verifier/TestBattleArmor.java | 10 ++-- .../megamek/common/verifier/TestEntity.java | 24 +++++----- .../megamek/common/verifier/TestInfantry.java | 9 ++-- .../src/megamek/common/verifier/TestMech.java | 47 ++++++++++--------- .../common/verifier/TestProtomech.java | 9 ++-- .../common/verifier/TestSmallCraft.java | 5 +- .../common/verifier/TestSupportVehicle.java | 9 ++-- .../src/megamek/common/verifier/TestTank.java | 9 ++-- 12 files changed, 79 insertions(+), 79 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 621e5822504..ee40246d412 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -2341,7 +2341,8 @@ MechView.Pod=Pod MechView.Fixed=Fixed MechView.Quirks=Quirks MechView.WeaponQuirks=Weapon Quirks -MechView.InvalidReasons=Invalid Reasons +MechView.InvalidReasons=Invalid because: +MechView.InvalidButIllegalQuirk=Illegal Design Quirk, would be invalid because: #Minelaying MineDensityDialog.title=Mine Density diff --git a/megamek/src/megamek/common/MechView.java b/megamek/src/megamek/common/MechView.java index f702ac15601..5bedd82b0b7 100644 --- a/megamek/src/megamek/common/MechView.java +++ b/megamek/src/megamek/common/MechView.java @@ -546,11 +546,16 @@ public MechView(final Entity entity, final boolean showDetail, final boolean use TestEntity testEntity = TestEntity.getEntityVerifier(entity); if (testEntity != null) { - testEntity.correctEntity(sb, entity.getTechLevel()); - - if (!sb.toString().isEmpty()) { + testEntity.correctEntity(sb); + if (!sb.isEmpty()) { sInvalid.add(new SingleLine()); - sInvalid.add(new LabeledElement(Messages.getString("MechView.InvalidReasons"), "\n" + sb)); + String[] errorLines = sb.toString().split("\n"); + String label = entity.hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN) ? + Messages.getString("MechView.InvalidButIllegalQuirk") : + Messages.getString("MechView.InvalidReasons"); + ItemList errorList = new ItemList(label); + Arrays.stream(errorLines).forEach(errorList::addItem); + sInvalid.add(errorList); } } } @@ -659,21 +664,17 @@ public String getMechReadout() { public String getMechReadout(@Nullable String fontName) { String docStart = ""; String docEnd = ""; - String preStart = ""; - String preEnd = ""; if (formatting == ViewFormatting.HTML && (fontName != null)) { docStart = "
"; docEnd = "
"; - preStart = "
";
-            preEnd = "
"; } else if (formatting == ViewFormatting.DISCORD) { docStart = "```ansi\n"; docEnd = "```"; } return docStart + getMechReadoutHead() + getMechReadoutBasic() + getMechReadoutLoadout() - + getMechReadoutFluff() + preStart + getMechReadoutInvalid() + preEnd + docEnd; + + getMechReadoutFluff() + getMechReadoutInvalid() + docEnd; } private List getInternalAndArmor() { diff --git a/megamek/src/megamek/common/verifier/TestAdvancedAerospace.java b/megamek/src/megamek/common/verifier/TestAdvancedAerospace.java index f9a45b07a25..6fc55db8ce7 100644 --- a/megamek/src/megamek/common/verifier/TestAdvancedAerospace.java +++ b/megamek/src/megamek/common/verifier/TestAdvancedAerospace.java @@ -18,6 +18,7 @@ import megamek.common.equipment.AmmoMounted; import megamek.common.equipment.ArmorType; import megamek.common.equipment.WeaponMounted; +import megamek.common.options.OptionsConstants; import megamek.common.util.StringUtil; import megamek.common.weapons.bayweapons.BayWeapon; import megamek.common.weapons.capitalweapons.ScreenLauncherWeapon; @@ -630,7 +631,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct &= correctGravDecks(buff); correct &= correctBays(buff); correct &= correctCriticals(buff); - + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestAero.java b/megamek/src/megamek/common/verifier/TestAero.java index 88fcf89cc1b..f9e58c3e2a8 100644 --- a/megamek/src/megamek/common/verifier/TestAero.java +++ b/megamek/src/megamek/common/verifier/TestAero.java @@ -692,11 +692,6 @@ public boolean correctHeatSinks(StringBuffer buff) { return true; } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, aero.getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { boolean correct = true; @@ -750,7 +745,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct &= !hasIllegalEquipmentCombinations(buff); correct &= !hasMismatchedLateralWeapons(buff); correct &= correctHeatSinks(buff); - + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestBattleArmor.java b/megamek/src/megamek/common/verifier/TestBattleArmor.java index a63c5477039..72a033ca5f0 100644 --- a/megamek/src/megamek/common/verifier/TestBattleArmor.java +++ b/megamek/src/megamek/common/verifier/TestBattleArmor.java @@ -17,6 +17,7 @@ import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.common.equipment.ArmorType; +import megamek.common.options.OptionsConstants; import megamek.common.util.StringUtil; import megamek.common.weapons.infantry.InfantryWeapon; @@ -1020,11 +1021,6 @@ public boolean correctWeight(StringBuffer buff, boolean showO, boolean showU) { return correct; } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, getEntity().getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { boolean correct = true; @@ -1059,7 +1055,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct &= correctManipulators(buff); correct &= correctMovement(buff); - + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestEntity.java b/megamek/src/megamek/common/verifier/TestEntity.java index 9d1f20f1a40..46620d2c3ff 100755 --- a/megamek/src/megamek/common/verifier/TestEntity.java +++ b/megamek/src/megamek/common/verifier/TestEntity.java @@ -18,6 +18,7 @@ import megamek.common.annotations.Nullable; import megamek.common.enums.MPBoosters; import megamek.common.equipment.ArmorType; +import megamek.common.equipment.WeaponMounted; import megamek.common.util.StringUtil; import java.io.File; @@ -74,7 +75,9 @@ private Ceil(double mult) { public abstract String printWeightControls(); - public abstract boolean correctEntity(StringBuffer buff); + public boolean correctEntity(StringBuffer buff) { + return correctEntity(buff, getEntity().getTechLevel()); + } public abstract boolean correctEntity(StringBuffer buff, int ammoTechLvl); @@ -1474,19 +1477,16 @@ public boolean hasIllegalEquipmentCombinations(StringBuffer buff) { } } } - if ((isMech() || isTank() || isAero()) - && (!getEntity().hasEngine() - || (!getEntity().getEngine().isFusion() - && (getEntity().getEngine().getEngineType() != Engine.FISSION)))) { - for (Mounted m : getEntity().getWeaponList()) { - if (((WeaponType) m.getType()).getAmmoType() == AmmoType.T_IGAUSS_HEAVY) { - buff.append("Improved Heavy Gauss requires a fusion or fission engine.\n"); + Engine engine = getEntity().getEngine(); + if (!getEntity().hasEngine() || !(engine.isFusion() || engine.isFission())) { + for (WeaponMounted m : getEntity().getWeaponList()) { + if ((m.getType().getAmmoType() == AmmoType.T_GAUSS_HEAVY) + || (m.getType().getAmmoType() == AmmoType.T_IGAUSS_HEAVY)) { + buff.append("Heavy Gauss Rifles require a fusion or fission engine\n"); illegal = true; } else if (m.getType().hasFlag(WeaponType.F_FLAMER) - && (((WeaponType) m.getType()).getAmmoType() == AmmoType.T_NA) - && (!getEntity().hasEngine() || (!getEntity().getEngine().isFusion() - && (getEntity().getEngine().getEngineType() != Engine.FISSION)))) { - buff.append("Standard flamers require a fusion or fission engine.\n"); + && (m.getType().getAmmoType() == AmmoType.T_NA)) { + buff.append("Standard flamers require a fusion or fission engine\n"); illegal = true; } } diff --git a/megamek/src/megamek/common/verifier/TestInfantry.java b/megamek/src/megamek/common/verifier/TestInfantry.java index a149eb8b15a..be88995d0b4 100644 --- a/megamek/src/megamek/common/verifier/TestInfantry.java +++ b/megamek/src/megamek/common/verifier/TestInfantry.java @@ -130,11 +130,6 @@ public String printWeightArmor() { return ""; } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, getEntity().getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { Infantry inf = (Infantry) getEntity(); @@ -198,7 +193,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { buff.append("Infantry may not have more than one armor kit!\n"); correct = false; } - + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestMech.java b/megamek/src/megamek/common/verifier/TestMech.java index 805d87a55ec..fd01b999db3 100755 --- a/megamek/src/megamek/common/verifier/TestMech.java +++ b/megamek/src/megamek/common/verifier/TestMech.java @@ -18,6 +18,8 @@ import megamek.common.annotations.Nullable; import megamek.common.equipment.ArmorType; import megamek.common.equipment.WeaponMounted; +import megamek.common.options.OptionsConstants; +import megamek.common.options.Quirks; import megamek.common.util.StringUtil; import megamek.common.weapons.artillery.ArtilleryWeapon; import megamek.common.weapons.autocannons.ACWeapon; @@ -680,11 +682,6 @@ public boolean correctMovement(StringBuffer buff) { return true; } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, getEntity().getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { boolean correct = true; @@ -732,6 +729,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct = correct && checkMiscSpreadAllocation(mech, misc, buff); } correct = correct && correctMovement(buff); + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } @@ -1047,23 +1047,6 @@ && countCriticalSlotsFromEquipInLocation(mech, m, loc) != 1) { } if (mech.isSuperHeavy()) { - switch (mech.hasEngine() ? mech.getEngine().getEngineType() : Engine.NONE) { - case Engine.NORMAL_ENGINE: - case Engine.LARGE_ENGINE: - break; - case Engine.XL_ENGINE: - case Engine.XXL_ENGINE: - case Engine.COMPACT_ENGINE: - case Engine.LIGHT_ENGINE: - if (mech.isIndustrial()) { - buff.append("Superheavy industrialMechs can only use standard or large fusion engine\n"); - illegal = true; - } - break; - default: - buff.append("Superheavy Mechs must use some type of fusion engine\n"); - illegal = true; - } if (mech.getGyroType() != Mech.GYRO_SUPERHEAVY) { buff.append("Superheavy Mechs must use a superheavy gyro.\n"); illegal = true; @@ -1099,6 +1082,26 @@ && countCriticalSlotsFromEquipInLocation(mech, m, loc) != 1) { buff.append("industrial mechs can only mount standard gyros\n"); illegal = true; } + if (hasDoubleHeatSinks()) { + buff.append("Industrial Meks cannot mount double heat sinks\n"); + illegal = true; + } + switch (mech.hasEngine() ? engine.getEngineType() : Engine.NONE) { + case Engine.NORMAL_ENGINE: + break; + case Engine.COMBUSTION_ENGINE: + case Engine.FUEL_CELL: + case Engine.FISSION: + if (mech.isSuperHeavy()) { + buff.append("Superheavy Industrial Meks can only use standard or large fusion engines\n"); + illegal = true; + } + break; + default: + buff.append("Industrial Meks can only use standard and large fusion engines, ICEs, fuel cells or fission\n"); + illegal = true; + break; + } } if (mech.isPrimitive()) { diff --git a/megamek/src/megamek/common/verifier/TestProtomech.java b/megamek/src/megamek/common/verifier/TestProtomech.java index 2cda0b1a2a0..2a9a2b21c27 100644 --- a/megamek/src/megamek/common/verifier/TestProtomech.java +++ b/megamek/src/megamek/common/verifier/TestProtomech.java @@ -17,6 +17,7 @@ import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.common.equipment.ArmorType; +import megamek.common.options.OptionsConstants; import megamek.common.util.StringUtil; import java.util.HashMap; @@ -213,11 +214,6 @@ public double getWeightCarryingSpace() { return 0.0; } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, getEntity().getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { boolean correct = true; @@ -249,6 +245,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct = false; } correct = correct && correctMovement(buff); + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestSmallCraft.java b/megamek/src/megamek/common/verifier/TestSmallCraft.java index f19c2b0b0ef..e749e6b7457 100644 --- a/megamek/src/megamek/common/verifier/TestSmallCraft.java +++ b/megamek/src/megamek/common/verifier/TestSmallCraft.java @@ -18,6 +18,7 @@ import megamek.common.equipment.AmmoMounted; import megamek.common.equipment.ArmorType; import megamek.common.equipment.WeaponMounted; +import megamek.common.options.OptionsConstants; import megamek.common.util.StringUtil; import java.math.BigInteger; @@ -510,7 +511,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct &= correctHeatSinks(buff); correct &= correctCrew(buff); correct &= correctCriticals(buff); - + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestSupportVehicle.java b/megamek/src/megamek/common/verifier/TestSupportVehicle.java index b4efce7df5e..049a01f4324 100644 --- a/megamek/src/megamek/common/verifier/TestSupportVehicle.java +++ b/megamek/src/megamek/common/verifier/TestSupportVehicle.java @@ -17,6 +17,7 @@ import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.common.equipment.ArmorType; +import megamek.common.options.OptionsConstants; import megamek.common.util.StringUtil; import megamek.common.weapons.flamers.VehicleFlamerWeapon; import megamek.common.weapons.infantry.InfantryWeapon; @@ -919,11 +920,6 @@ public boolean canUsePintleTurret() { getEntity().getWeightClass() == EntityWeightClass.WEIGHT_SMALL_SUPPORT); } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, getEntity().getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { boolean correct = true; @@ -1119,6 +1115,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { if (!correctCriticals(buff)) { correct = false; } + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; } diff --git a/megamek/src/megamek/common/verifier/TestTank.java b/megamek/src/megamek/common/verifier/TestTank.java index b4c36d1c578..ce5d7e0d053 100755 --- a/megamek/src/megamek/common/verifier/TestTank.java +++ b/megamek/src/megamek/common/verifier/TestTank.java @@ -17,6 +17,7 @@ import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.common.equipment.ArmorType; +import megamek.common.options.OptionsConstants; import megamek.common.util.StringUtil; import megamek.common.weapons.flamers.VehicleFlamerWeapon; import megamek.common.weapons.lasers.CLChemicalLaserWeapon; @@ -283,11 +284,6 @@ public Tank getTank() { return tank; } - @Override - public boolean correctEntity(StringBuffer buff) { - return correctEntity(buff, getEntity().getTechLevel()); - } - @Override public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { boolean correct = true; @@ -392,6 +388,9 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { if (!correctCriticals(buff)) { correct = false; } + if (getEntity().hasQuirk(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN)) { + correct = true; + } return correct; }