From a230d5f50549d07fdc2c27891c6e86816cb82007 Mon Sep 17 00:00:00 2001 From: Weaver Date: Fri, 25 Oct 2024 16:53:21 -0700 Subject: [PATCH 1/3] Refit - fix some minor/easy things --- MekHQ/src/mekhq/campaign/parts/Refit.java | 59 ++++++++++++----------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/parts/Refit.java b/MekHQ/src/mekhq/campaign/parts/Refit.java index 15972ceb9f..9345d43b69 100644 --- a/MekHQ/src/mekhq/campaign/parts/Refit.java +++ b/MekHQ/src/mekhq/campaign/parts/Refit.java @@ -412,7 +412,7 @@ public void calculate() { // Not the same armor continue; } - if ((oldPart instanceof VeeStabilizer) // FIXME: WeaverThree - I think something is missing here + if ((oldPart instanceof VeeStabilizer) && (newPart instanceof VeeStabilizer) && (oldPart.getLocation() != newPart.getLocation())) { continue; } @@ -471,7 +471,7 @@ public void calculate() { continue; } - if ((oldPart instanceof VeeStabilizer) // FIXME: WeaverThree - I think something is missing here + if ((oldPart instanceof VeeStabilizer) && (newPart instanceof VeeStabilizer) && (oldPart.getLocation() != newPart.getLocation())) { continue; } @@ -636,8 +636,10 @@ public void calculate() { || oldEngine.getEngineType() != newEngine.getEngineType()) { updateRefitClass(customJob ? CLASS_E : CLASS_D); } - if (((MissingEnginePart) newPart).getEngine().getSideTorsoCriticalSlots().length > 0) { - // FIXME: WeaverThree - It won't be new stuff if the engine is the same class... + + if (newEngine.getSideTorsoCriticalSlots().length > oldEngine.getSideTorsoCriticalSlots().length) { + // WeaverThree - This still dosen't account for downgrading engine removing from the parts + // That can wait for rework locationHasNewStuff[Mek.LOC_LT] = true; locationHasNewStuff[Mek.LOC_RT] = true; } @@ -717,6 +719,7 @@ public void calculate() { if ((crits == oldCrits) && (oldType != null) // FIXME: WeaverThree - CamOps doesn't specifiy anything about weapon types + // -- Not sure how best to resolve this quickly && (type.hasFlag(WeaponType.F_LASER) == oldType.hasFlag(WeaponType.F_LASER)) && (type.hasFlag(WeaponType.F_MISSILE) == oldType.hasFlag(WeaponType.F_MISSILE)) && (type.hasFlag(WeaponType.F_BALLISTIC) == oldType.hasFlag(WeaponType.F_BALLISTIC)) @@ -728,7 +731,7 @@ public void calculate() { } else if (crits <= oldCrits) { // FIXME: WeaverThree - Class B is "Stuff added where something was removed, other than thing removed" - // This is the wrong logic + // This is the wrong logic - not sure how to fix it quickly thisPartRefitClass = CLASS_B; matchFound = true; matchIndex = index; @@ -1037,7 +1040,7 @@ public void calculate() { nloc++; } } - // FIXME: WeaverThree - This is not how we do customizations anymore + // WeaverThree - Actually this is the correct time multiplier for omni swaps... time = 30 * nloc; } @@ -1056,6 +1059,7 @@ public void calculate() { for (int loc = 0; loc < newEntity.locations(); loc++) { if (locationHasNewStuff[loc] && oldUnit.isLocationDestroyed(loc)) { // FIXME: WeaverThree - Why would this be a thing? Surely we'd replace the location during the refit... + // I don't think we do but maybe we should? errorStrings.add("Can't add new equipment to a missing " + newEntity.getLocationAbbr(loc)); } } @@ -1086,7 +1090,7 @@ private void calculateRefurbishment() { } else if (newEntity instanceof BattleArmor || newEntity instanceof Tank || newEntity instanceof ProtoMek) { time = WORKWEEK; } else { - time = 1111; // FIXME: WeaverThree - I'm sorry, what! + time = WORKWEEK * 2; // Default to same as Mek logger.error("Unit " + newEntity.getModel() + " did not set its time correctly."); } @@ -1183,7 +1187,7 @@ public void begin() throws EntityLoadingException, IOException { AmmoBin ammoBin = (AmmoBin) part; ammoBin.setShotsNeeded(ammoBin.getFullShots()); part.setRefitUnit(oldUnit); - // FIXME: WeaverThree - the following function ignores ammo bins... + // WeaverThree - the following function ignores ammo bins... only if they don't have a unit getCampaign().getQuartermaster().addPart(part, 0); newUnitParts.add(part); @@ -1599,7 +1603,7 @@ private void complete() { } oldUnit.setParts(newParts); - // TODO: WeaverThree - What does this do?? + // WeaverThree - Watford's tool final EquipmentUnscrambler unscrambler = EquipmentUnscrambler.create(oldUnit); final EquipmentUnscramblerResult result = unscrambler.unscramble(); if (!result.succeeded()) { @@ -1793,19 +1797,19 @@ public void saveCustomization() throws EntityLoadingException { /** * @return time multiplier for this refit's current class */ - private int getTimeMultiplier() { + private float getTimeMultiplier() { int mult = switch(refitClass) { - // FIXME: WeaverThree - This isn't accurate to Camops 211 case NO_CHANGE -> 0; - case CLASS_A, CLASS_B -> 1; - case CLASS_C -> 2; - case CLASS_D -> 3; - case CLASS_E -> 4; - case CLASS_F -> 5; + case CLASS_A -> 2; + case CLASS_B -> 3; + case CLASS_C -> 5; + case CLASS_D -> 8; + case CLASS_E -> 9; + case CLASS_F -> 10; default -> 1; }; - if (customJob) { - mult *= 2; + if (!customJob) { + mult *= 0.5; } return mult; } @@ -1853,15 +1857,15 @@ public boolean needsFixing() { @Override public int getDifficulty() { return switch (refitClass) { - // FIXME: WeaverThree - This isn't accurate to Camops 211 case NO_CHANGE -> 0; - case CLASS_A, CLASS_B -> 1; - case CLASS_C, CLASS_D -> 2; - case CLASS_E -> 3; - case CLASS_F -> 4; + case CLASS_A -> 2; + case CLASS_B, CLASS_C -> 3; + case CLASS_D, CLASS_E -> 4; + case CLASS_F -> 5; case CLASS_OMNI -> -2; default -> 1; }; + // Refit kit bonus added below in getAllMods } @@ -1879,8 +1883,8 @@ public TargetRoll getAllMods(Person tech) { mods.addModifier(1, "difficult to maintain"); } - if (customJob) { - mods.addModifier(2, "custom job"); + if (!customJob) { + mods.addModifier(-2, "refit kit used"); } if ((null != tech) && tech.getOptions().booleanOption(PersonnelOptions.TECH_ENGINEER)) { @@ -2828,13 +2832,12 @@ private void assignBayParts() { * @param entity Either the starting or the ending unit of the refit. * @return The number of heat sinks the unit mounts that are not tracked as parts. */ - private int untrackedHeatSinkCount(Entity entity) { + private static int untrackedHeatSinkCount(Entity entity) { if (entity instanceof Mek) { return Math.min(((Mek) entity).heatSinks(), entity.getEngine().integralHeatSinkCapacity(((Mek) entity).hasCompactHeatSinks())); - } else if (newEntity.getClass() == Aero.class) { // Aero but not subclasses - // FIXME: shouldn't this be entity and not newEntity? This method should be static? + } else if (entity.getClass() == Aero.class) { // Aero but not subclasses return entity.getEngine().getWeightFreeEngineHeatSinks(); } else { From bd17de286e8b58ace455703cccafb75e55c14ede Mon Sep 17 00:00:00 2001 From: Weaver Date: Fri, 25 Oct 2024 17:13:42 -0700 Subject: [PATCH 2/3] Refit - Adding and removing a door is one hour, not ten --- MekHQ/src/mekhq/campaign/parts/Refit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/campaign/parts/Refit.java b/MekHQ/src/mekhq/campaign/parts/Refit.java index 9345d43b69..18cc1b91f8 100644 --- a/MekHQ/src/mekhq/campaign/parts/Refit.java +++ b/MekHQ/src/mekhq/campaign/parts/Refit.java @@ -825,7 +825,7 @@ public void calculate() { } else { doorsRemoved = Math.max(0, doorsRemoved + deltaDoors); } - time += (doorsAdded + doorsRemoved) * 600; + time += (doorsAdded + doorsRemoved) * WORKHOUR; } // Step 4: loop through remaining equipment on oldunit parts and add time for From b60f6822403cf07152be0b4297a52c969c71eefc Mon Sep 17 00:00:00 2001 From: Weaver Date: Fri, 25 Oct 2024 21:01:07 -0700 Subject: [PATCH 3/3] RefitTest - Update for Camops Values --- MekHQ/unittests/mekhq/campaign/parts/RefitTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java b/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java index 1f44a4cdef..951dd1a5db 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/RefitTest.java @@ -181,8 +181,8 @@ public void locust1Vto1ETest() { // + 3 removals @ 120 mins ea // + 1 move @ 120 mins ea // + 3 adds @ 120 mins ea - // x 3 (Class D) - assertEquals((120.0 * 7.0) * 3.0, refit.getActualTime(), 0.1); + // x 8*.5=4 (Class D) (CamOps) + assertEquals((120.0 * 7.0) * 4.0, refit.getActualTime(), 0.1); // Cost? // + 1 Medium Laser @ 40,000 ea @@ -577,8 +577,8 @@ public void fleaFLE4toFLE15Test() { // + 1 facing change @ 120 mins ea // + 5 adds @ 120 mins ea // + 16 armor changes @ 5 mins ea - // x 3 (Class D) - assertEquals(((120.0 * 9.0) + (5.0 * 16.0)) * 3.0, refit.getActualTime(), 0.1); + // x 8*0.5 = 4 (Class D with kit, camops) + assertEquals(((120.0 * 9.0) + (5.0 * 16.0)) * 4.0, refit.getActualTime(), 0.1); // Cost? // + 2 Medium Lasers @ 40,000 ea