comparing fomula
Anyone know of a foundry utility to compare two strings that might be dice formulae to tell which has the lesser deterministic value?
C
Calego•469d ago
🧵
use case:
I have two strings that
- might just be numbers ('3' and '4')
- might be simple formula ('3 + 3' and '4')
- might be nonDeterministic formula ('3 + 1d4' and '4')
I want to know:
- if both are deterministic formula, what is the
Floor
of their values
- if they aren't deterministic, I'll do nothing with either value
oh i can use dnd5e's simplifyRollFormula
for this
if the output of simplifyRollFormula
is parsable as a Number
, I can compare them easilyC
Calego•469d ago
ok wtf js
C
Calego•469d ago
oh, i'm dumb.
.floor
is for rounding
I'm looking for .min
this is definitely excessive...
BUT
it does do what I was looking for and covers all the edge cases I can think of
Most of the time I know of, if there's a bonus, it'll be adding to both msak
and rsak
to represent a global increase
but the data does support disparate mods, in which case, applying the lesser one is 'safe' to this display of 'spell attack modifier'M
Mana•469d ago
.evaluate({min:true, async:false})
doesn't work for you?
Or did I misunderstand what you were after?C
Calego•469d ago
is that a method on
Roll
?M
Mana•469d ago
Yes.
C
Calego•469d ago
min
would return the minimum possible based on the formula provided?M
Mana•469d ago
Yes. It sets the dice to minimum value they'd give instead of randomizing them and returns the result.
C
Calego•469d ago
gotcha, not quite what i'm looking for
I'm really looking to compare two formulas, and use the 'min' one
(but only if they're deterministic)
M
Mana•469d ago
Roll.isDeterministic is a thing
It also exists for individual terms.
That is available pre-eval
C
Calego•469d ago
so the alternative to using the dnd5e
simplifyRollFormula
would look something like :
M
Mana•469d ago
Almost, .isDeterministic is a getter.
And .evaluate() returns Roll instance, so you'd need to add .total there.
Also eval is async unless you tell it to be non-async.
C
Calego•469d ago
that I could probably DIY that actually if jk not as easy i expected in js
async:false
is being deprecated right?
isDeterministic
is trueM
Mana•469d ago
People keep saying it's not. The requirement for it is, because async is becoming the default.
And there's no warning in it that sync option is going away, just that it won't be the default.
C
Calego•469d ago
goootcha
M
Mana•469d ago
Anyway, you'd have this:
C
Calego•469d ago
so then the question i have is 'is the overhead of creating two
Roll
s to compare these strings greater than or less than using simplifyRollFormula
?'
odds are, less than, simplifyRollFormula is a heavy function now that I look closerM
Mana•469d ago
I'd favor whichever makes the intent of the code clearer.
C
Calego•469d ago
suspect this will never be clear 😛 but this is a solidly simpler solution and doesn't rely on 5e code
thanks @manaflower
LTL
Leo The League Lion•469d ago
@calego gave LeaguePoints™ to @manaflower (#15 • 203)
C
Calego•469d ago
🎉
UU
Unknown User•469d ago
C
Calego•469d ago
External constraint, could be a simple formula like "+1 +1 +2"
Want results from more Discord servers?
More Postssheet modules in 2.1.xstarting my run for my sheet modules now, will holler with what info I findCantrip Charges 🧵Cantrip Charges 🧵Item piles gridRough draft of a grid-based inventory system thing - it can't swap positions of entries yetMathJSas a javascript dependencyGet most matched Classes`const intersection = yourArray.filter(item1 => yourOtherArray.some(item2 => item2 === item1))`Application and EventsDoes anyone know if Foundry's `Application` (or the browser itself) does anything magical to clean uPopOut!Just starting a thread here for some discussion of "PopOut!" module in relation to my UI library / TPackage jam judge signup threadPackage jam judge signup thread (free league points inside)git filter troubleshootingI'm troubleshooting a new setup that my code contributors can benefit from. I'm using a .gitconfig fmultiroll damage roll messagesMessing with multiroll chat message in v10❓About Commissions**Do not post commissions in this thread.**
This thread is for discussing the commissions process, gIssue Submission ToolI'm looking for suggestions for free ticket submission without signing into GitHub that go beyond BuMM+, manifest+, attributions, and moreWe can make a thread to keep the MM+ discussion seperate if you'd likeGlitterSuppose someone wanted to make a module which created a stylistic ~~defect~~ enhancement that never Here s an example No template data inHere's an example. No template data in the actor object, but the object is associated with a templatRolling Hooks**Rolling Hooks!**
I am working on a couple of additions to one of the upcoming version of 5e to addWeight MRSure.2.0.0 explorationFrom Atropos in the mothership (in v10 Feedback)
> Hello folks, for those of you testing V10 using tElectron ViteIt loads at least.early v10 compat testing@dnd5e - No action required
Work is being done on fixing the core system compatibility with v10 in