javalent / dice-roller

Inline dice rolling for Obsidian.md
265 stars 27 forks source link

🐞 is-min and is-max are incorrectly applied with kl and kh #320

Open ThaddaeusWiedemer opened 1 month ago

ThaddaeusWiedemer commented 1 month ago

Check for existing bug reports before submitting.

Expected Behavior

dice: 2d4kl has a min (max) of 1 (4) since only one die affects the result. Rolling a 1 (4) should apply the is-min (is-max) CSS class.

Current behaviour

The plugin applies the is-min CSS class for 2 (the min roll of 1 die), and I suspect it might try to apply is-max for an (impossible) roll of 8.

This might also affect dh and dl, but I haven't checked it.

Reproduction

  1. open a note and write dice: 2d4kl
  2. open the inspector with ctrl + shift + i and select the dice roller to inspect the CSS classes
  3. re-roll to observe that is-min is applied to 2, but not 1; is-max is not applied to 4

Which Operating Systems are you using?

Obsidian Version Check

1.5.12 and 1.4.13

Plugin Version

11.0.3

Confirmation

Possible solution

Correctly calculate the min/max values, accounting for the number of dropped and kept dice.