theripper93 / enhancedcombathud

GNU General Public License v3.0
31 stars 37 forks source link

issue with new version of foundry #103

Closed vulpes-rex closed 2 years ago

vulpes-rex commented 2 years ago

I downloaded this after updating to version 0.9 of Foundry VTT and saw an issue when clicking the End Combat button, even after creating a fresh game world with only this module installed.

I was getting an error saying 'id' was unavailable. I found while debugging that combatant was no longer a property under combat and token.id didn't exist either.

I forked your project and fixed it in my fork and tested in Foundry, i was going to do a pull request with a new branch in your repository but didn't know if that was ok with you

Original code

Hooks.on("updateCombat", (combat, updates) => {
if (
    canvas.hud.enhancedcombathud?.hudData &&
    combat?.combatant?._token.id ==
      canvas.hud.enhancedcombathud?.hudData?.token?.id
  ) {
    canvas.hud.enhancedcombathud.newRound();
  }
  canvas.hud.enhancedcombathud?.updatePass();
});

My code that fixed the issue

Hooks.on("updateCombat", (combat, updates) => {
  if (
    canvas.hud.enhancedcombathud?.hudData &&
    combat?.current?.tokenId ==
      canvas.hud.enhancedcombathud?.hudData?.token?.data._id
  ) {
    canvas.hud.enhancedcombathud.newRound();
  }
  canvas.hud.enhancedcombathud?.updatePass();
});
theripper93 commented 2 years ago

should be fixed