paulofmandown / rotLove

Roguelike Toolkit in Love. A Love2D/lua port of rot.js
http://paulofmandown.github.io/rotLove/
Other
258 stars 25 forks source link

Bugfix in dice module required #18

Closed timothymtorres closed 7 years ago

timothymtorres commented 7 years ago

After doing some testing today when I was adding a new feature I came across a severe bug that affects older versions of RL-Dice (including the rotLove dice module). The bug is triggered whenever the user is using sets, and causes the dice bonus to be the number of dice due to a pattern matching loophole I missed. Luckily a small fix is all that is required!

The following lines of code on lines 5661, 5662 at rotLove.lua need to be changed from:

local double_bonus = string.match(dice_notation, '[^%^+-]([+-]?[+-])%d+')
local bonus = string.match(dice_notation, '[^%^+-][+-]?([+-]%d+)')

to the following:

local double_bonus = string.match(dice_notation, '[d]%d+([+-]?[+-])%d+')
local bonus = string.match(dice_notation, '[d]%d+[+-]?([+-]%d+)')

And it should be good to go!

buckle2000 commented 7 years ago

Also in dice_basic.lua: you used D&D-xxxx as a variable name.

timothymtorres commented 7 years ago

@buckle2000 I noticed that earlier but didn't think it warranted a issue request because it was apart of the examples. A better variable name would have been DnD-xxxx.