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

Issue ith Macro and List #64

Closed rlalleme closed 4 years ago

rlalleme commented 4 years ago

Hi,

I am experiencing a problem when I have a macro defined and try to roll a list. For instance I have the following macro: id: 1 Pattern: t Command: d6[>=6] Regexp: False It works perfectly well.

But if I try to roll from a list, it will interfere: ! 1L[test,foo,bar] If the die would get the second or third value it would work, but if it is the first value, since it contains the letter used in the macro it gives a wrong answer.

! 1L[test,foo,bar]
  foo
! 1L[test,foo,bar]
  d6c

(In case it is important, I am experiencing this issue in Discord. I have not tried on rollisteam.)

obiwankennedy commented 4 years ago

I strongly recommand to use regular expression matching in your case. If you define your macro as:

!macro ([0-9]+)t \1d6c[>=6] 1

it should not interfere with list command as you make the matching more precise.

rlalleme commented 4 years ago

I agree and will use your method but would have expected the first case to work.

Your solution reduce the risk of triggering the issue, but it could still appear ;) roll 1L[36tons-truck,car]

However if it linked to its internal functioning, then the solution is to be careful with the macro names. (I suppose there is "cascading" effect to allow rules such as the one from the doc: 1d10;2d6+9;1d20;[$1,$2,$3,$4]k1.)