mythridium/combat-simulator

Import set fail for potions

Closed this issue · 1 comments

Describe the bug
While importing an equipment set, only the equipment is imported. Pets, astrology .. is not.

To Reproduce
Steps to reproduce the behavior:

  1. Import set.
  2. Only gear will be imported.

Due to the nature of error, it seems it will appears only in some languages. Here, it happens in the french version of Melvor.

Expected behavior
Pets and astrology should be imported.

Device:
Steam, mobile and web affected.

Additional context
The issue happens here :

/**
   * Updates the images and tooltips for potions when the potion tier is changed
   * @param {number} potionTier The new potion tier
   */
  updatePotionTier(potionTier) {
      this.potionTier = potionTier;
      document.getElementById("MCS Potion Tier Dropdown").selectOption(potionTier);
      this.combatPotionRecipes.forEach((recipe) => {
          const potion = recipe.potions[potionTier];
          const img = document.getElementById(`MCS ${this.getPotionHtmlId(potion)} Button Image`);
          img.src = potion.media; // Uncaught TypeError: Cannot set properties of null (setting 'src')
          this.setTooltip(img.parentElement, this.getPotionTooltip(recipe.potions[this.potionTier]));
      });

The line const img = document.getElementById('MCS ${this.getPotionHtmlId(potion)} Button Image'); tries to look for an image, id 'MCS Potion de Force au corps à corps IV Button Image' ("Melee_Strength_Potion_IV") while the "correct" id is 'MCS Potion de Force au corps à corps I Button Image'. Note : a non-breaking space is present before the I.

Quick and dirty test : when img.src = potion.media; and this.setTooltip(img.parentElement, this.getPotionTooltip(recipe.potions[this.potionTier])); are commented, astrology and pets are imported.

Thanks so much for reporting this issue. I've released a fix which should resolve this issue.

Feel free to create more issues if you run into any further issues.

Fixed in 6f1e164