tablesort icon indicating copy to clipboard operation
tablesort copied to clipboard

Include a dice (🎲) sorting function

Open lordslair opened this issue 4 years ago • 0 comments

Hello,

I discovered your project (an awesome one), and I created a new fonction to be able to sort dice results.

Why ? Because for many role play games, player characteristics are displayed with a number of dice and a bonus/malus Player1 Strength : 3D6 +2 Player2 Strength : 2D4 -1

I needed to parse and sort these, as I can't compare them as strings Comparing '3D6 +2' and '2D4 -1' means nothing per se. So basically I extract the number of dice, the eventual bonus/malus, calc the average, and sort this result

It works well using the 5.2.0 release, as its the one I'm using on my side

Spoiler alert: I'm really not a JS developper, so my commit might looks crappy. I did my best though !

lordslair avatar Oct 23 '20 17:10 lordslair