-
Notifications
You must be signed in to change notification settings - Fork 57
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
fix(treasure): Make drawTreasure async for 1.8.x #349
Conversation
c1f11db
to
df14be7
Compare
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 |
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! |
There was a problem hiding this 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 }), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
This fixes the deprecation messages for
drawTreasure
using a synchronous call for evaluation of a roll.