Rolisteam / DiceParser

Powerful dice Roller is used as discord bot, irc bot, cli tool and inside Rolisteam : 1d20+4, 1L[head,arm,leg,belly,chest], 1d6+1d8, 8+5*3
http://www.rolisteam.org/
GNU General Public License v3.0
125 stars 31 forks source link

Creating a list of constant: `m` give wrong results / core dumps, parenthesis with multiples sub-expression either #13

Open robinmoussu opened 6 years ago

robinmoussu commented 6 years ago

I was trying to write unit test, and I was searching a was trying to find the best way to have deterministic test (I would like to use constant instead of dices to test the operators).

I don't this issue need to be fixed now, I just would like to have a workaround.

$dice "3;4;5;1;ms"
zsh: segmentation fault (core dumped)  ./*/bin/dice "3;4;5;1;ms"

With d1 instead of constant it doesn't work either:

$dice "3d1;4d1;5d1;1d1;ms"
zsh: segmentation fault (core dumped)  ./*/bin/dice "3d1;4d1;5d1;1d1;ms"

I tried removing the ; before the m. The m operator dosen't do his job

$dice "3;4;5;1ms"
Result: 0 - details:[3;4;5;1ms ()]

At least the d1 version works (but it's obviously what I want to do)

$dice "3d1;4d1;5d1;1d1ms"
Result: 13 - details:[3d1;4d1;5d1;1d1ms (1 1 1 1 1 1 1 1 1 1 1 1 1)]

So I tried to do it with the L dice

$dice "L[3];L[4];L[5];L[1]"
3 ; 4 ; 5 ; 1
$dice "L[3];L[4];L[5];L[1];m"
zsh: segmentation fault (core dumped)  ./*/bin/dice "L[3];L[4];L[5];L[1];m"

But unfortunatly, m don't works with list, it look like

$dice "L[3];L[4];L[5];L[1]m"
1

Btw, I also tried to use parenthesis instead of m, and it's not working as expected

$dice "(3;4;5;1)s"
Result: 3,4,5,1 - details:[(3;4;5;1)s ()]
robinmoussu commented 6 years ago

Ideally, the last syntax ((3;4;5;1)ms) is the one I would probably prefer.

In fact I think that I will need at one point a way to specify the full list of all the next rolls, if I want to be able to unit test the reroll and reroll until operator (witch could be only accessible in c++, not necessarily from the cli).

robinmoussu commented 6 years ago

I was able to mock the dices (see PR #15), so I don't think this issue is urgent. You may consider close it if you will.