praguepride
 member, 1496 posts
 "Hugs for the Hugs God!"
 - Warhammer Fluffy-K
Wed 28 Aug 2019
at 18:02
Dice Roller Bug - Star Wars FFG System
When using the FFG Star Wars dice roller (Edge of the Empire, Age of Rebellion, Force & Destiny) you have to list out your special dice in the roller, i.e. 2a 2d rolls 2 ability dice 2 difficulty dice.

HOWEVER if in the roller you don't put a space (i.e. rolling 2a2d instead of 2a 2d) then it will spit back no successes instead of throwing an error.

I would like to request an error handler that would check to see if there are more than one alphabetic character in a given "dice" input and instead of giving a result of "no successes" instead cancel the roll and give a user message like "Please put spaces between dice inputs".


The answer is probably regex but I'm pretty new at it so trying to figure out the way to work that voodoo.
praguepride
 member, 1497 posts
 "Hugs for the Hugs God!"
 - Warhammer Fluffy-K
Wed 28 Aug 2019
at 18:58
Dice Roller Bug - Star Wars FFG System
Here is a Regex pattern that would detect multiple letters (case insensitive) in the same word interspersed with numerics:

/(\d*[a-z]){2,}/gi


God damn do I hate regex. It is the most unintuitive yet powerful coding tool ever.

to break it down... (I think)


\d* is optional numeric
[a-z] is your range of alpha

{2,} means it looks for 2 instances or more of the above pattern
() puts it in a word grouping

/g is a global search so keep looking after the first match
i marks it as case insensitive.

So this will handle things like a2D as well as 2a2d etc.
LonePaladin
 member, 849 posts
 Creator of HeroForge
Thu 29 Aug 2019
at 03:11
Dice Roller Bug - Star Wars FFG System
Would it be possible to have it interpret multiple copies of a letter as additional dice? So, for instance, 'aaddd' would read the same as 'a2 d3'.
praguepride
 member, 1498 posts
 "Hugs for the Hugs God!"
 - Warhammer Fluffy-K
Thu 29 Aug 2019
at 11:13
Dice Roller Bug - Star Wars FFG System
I mean you could but that starts getting complicated fast. What if you write 2aa? What about a2a?

I dont think Jace wants to spend a week recoding the dice roller for a single game system. Just a warning would suffice.