#Looks like your system managed to find a
1 messages · Page 1 of 1 (latest)
2i is the entire expression, apparently :p
here's the permalink to the die, fwiw - https://github.com/StarWarsFoundryVTT/StarWarsFFG/blob/142f1ed9183da2d6dc94608e645ac632a5741409/modules/dice/dietype/DifficultyDie.js#L8
and where the exception hits RollFFG
https://github.com/StarWarsFoundryVTT/StarWarsFFG/blob/142f1ed9183da2d6dc94608e645ac632a5741409/modules/dice/roll.js#L9
LMK if I'm a derp and pulled the wrong data; I didn't actually implement this code - I've just started to support the system over the years
I don't know much about the FFG system. Should 2i be a valid roll equation?
yup, that's two difficulty dice
Usually when you define a new die type it should still have the d in the middle of the terms, unless the system is overriding stuff relatively deeply. I would have expected it to be more like 2di personally
this system was originally written back in the days of... Foundry 0.0.4 or something. so it doesn't follow a lot of the more recent standards
Yeah, that checks out
@viral crow I hope you could share some thoughts on this case when you have a chance.
Yes, 2i is not a valid dice term, custom terms should be in the form 2di as mxzf said. You can register custom terms with a custom denominator like so:
class DifficultyDie extends foundry.dice.terms.DiceTerm {
constructor(data) {
data.faces = 8;
super(data);
}
static DENOMINATION = "i";
}
CONFIG.Dice.terms.i = DifficultyDie;
Looking through the code, it looks like you've done this already, mostly
Can you check if Roll.parse("2di") works?
@viral crow I don't remember, did we end up adding any sort of hook for a formula pre-processor? I feel like that is something we might have discussed
something that would allow a system to, for example, re-interpret input strings like "2i" into a string "2di"?
Does sound familiar, we haven't added anything though
Roll.parse is public so systems are free to override it
Roll.parse("2di") does work. I see that the system attempts to convert StringTerms into dice (https://github.com/StarWarsFoundryVTT/StarWarsFFG/blob/142f1ed9183da2d6dc94608e645ac632a5741409/modules/dice/roll.js#L381), and running Roll.parse("2i") in v11 returns a stringterm, whereas v12 errors
I will have to look into it further then, it's not clear why it wouldn't still resolve to a string term
OK, I think I got to the bottom of it
Because StringTerms are lower precedence than NumericTerms, the 2 in 2i was being matched as a NumericTerm, and then throwing an error because the only things that can follow a NumericTerm are flavour, an operator, or the end of input, and i is obviously none of those things.
not having looked at the changelog yet, is there a fix for this in the testing release 1?
having now looked, I don't see it noted. @viral crow do you happen to know if this is planned to be fixed at all and/or prior to a full v12 release?
I believe Kim did implement a change to address this
ah, didn't find it in the changelog but I do see it returns a stringterm now instead of an error, thanks!
This was my mistake, I neglected to add an issue for this when resolving it; it slipped my mind, sorry