Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(treasure): Make drawTreasure async for 1.8.x #349

Merged
merged 2 commits into from
Mar 28, 2023

Conversation

bakbakbakbakbak
Copy link
Collaborator

This fixes the deprecation messages for drawTreasure using a synchronous call for evaluation of a roll.

@bakbakbakbakbak bakbakbakbakbak changed the title Fix(treasure): Make drawtreasure async Fix(treasure): Make drawTreasure async Feb 11, 2023
@bakbakbakbakbak bakbakbakbakbak changed the title Fix(treasure): Make drawTreasure async Fix(treasure): Make drawTreasure async for 1.8.x Feb 11, 2023
@bakbakbakbakbak bakbakbakbakbak changed the title Fix(treasure): Make drawTreasure async for 1.8.x fix(treasure): Make drawTreasure async for 1.8.x Feb 11, 2023
@anthonyronda anthonyronda self-requested a review March 3, 2023 12:03
@bakbakbakbakbak bakbakbakbakbak force-pushed the fix/drawtreasure_async branch from c1f11db to df14be7 Compare March 3, 2023 15:23
@anthonyronda
Copy link
Member

I'm running into the following unexpected behavior with this change: treasure table selects every row, every draw, as though all rows are 100% chance of being drawn

@anthonyronda
Copy link
Member

the above behavior is fixed with the following change:

 const percent = (chance) => {
    const roll = new Roll("1d100");
    roll.evaluate({ async: false });
    return roll.total <= chance;
  };

basically de-async-ing the roll evaluation. I ran into this as well and it's why I set this particular code aside when doing the V9 deprecation work

HOWEVER! There are no deprecations for synchronous rolls so maybe this is satisfactory?

@bakbakbakbakbak
Copy link
Collaborator Author

bakbakbakbakbak commented Mar 5, 2023

the above behavior is fixed with the following change:

 const percent = (chance) => {
    const roll = new Roll("1d100");
    roll.evaluate({ async: false });
    return roll.total <= chance;
  };

basically de-async-ing the roll evaluation. I ran into this as well and it's why I set this particular code aside when doing the V9 deprecation work

HOWEVER! There are no deprecations for synchronous rolls so maybe this is satisfactory?

Yep! And no deprecation warning in console :D See new commit!

Copy link
Member

@anthonyronda anthonyronda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

const text = r.getChatText(r);
data.treasure[r.id] = {
img: r.data.img,
img: r.img,
text: TextEditor.enrichHTML(text, { async: false }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also encountered a roadblock here: we ought to make this async as well, yes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bakbakbakbakbak I think you might have missed this? or was there a reason this one is still sync?

@anthonyronda anthonyronda merged commit 8efcb42 into vttred:1.8.x Mar 28, 2023
@bakbakbakbakbak bakbakbakbakbak deleted the fix/drawtreasure_async branch April 9, 2023 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants