Bug - Fixed Maximizer recommends unequipping weapon with Smithsness offhand

Ryo_Sangnoir

Developer
Staff member
The easiest reproduction is:
Code:
@Test
public void shouldntUnequipWeapon() {
  var cleanups = new Cleanups(withEquipped(EquipmentManager.WEAPON, "seal-clubbing club"), withEquippableItem("Half a Purse"));

  try (cleanups) {
    assertTrue(maximize("meat"));
    recommendedSlotIsUnchanged(EquipmentManager.WEAPON);
  }
}
which fails. If "Half a Purse" is changed to "Bag o' Tricks" (which has a straight +15% meat bonus), it succeeds.

Changing MaximizerSpeculation.getScore to always recalculate the score and never use the cached value passes, but isn't ideal.
 

heeheehee

Developer
Staff member
Stupid fix:
Code:
if (!this.calculated) {
  this.calculate();
  this.calculate();
}

In particular, there's a problem with KoLCharacter.recalculateAdjustments: it adds modifiers from enchantments, then updates Smithsness. As a result of this ordering, Smithsness is still zero when we compute bonuses from Smiths gear, and so that initial bad value gets cached.

(yes, a better fix is to move the lines setting Modifiers.hoboPower / Modifiers.smithsness above "// Look at items". The stupid fix just amused me more.)
 
Last edited:
Top