Open OrbitalBliss opened 5 years ago
Regarding the comments I don't see how that would work across multi-level rolls, cf. #193.
I don't see it as so much a problem, as a challenge. If an alias (or multi-alias) calls another multi-alias, it calls the first roll (mini-alias) by default, otherwise it needs to specify. Following the ? that references an earlier roll (mini-alias) within a multi-roll alias; ? could be used to call the entire roll from within a multi-roll alias called from other aliases. And, while I'm at it, perhaps ?d should be used to references earlier dice (specifically) results as opposed to entire (calculated) results of an alias (mini-alias).
/r $punch = 1d20+5 #Grog Punches | 1d10+6+(?d1=20,1d10) #Grog Punch Damage /r $kick = 2d20k1+7 #Grogs Kicks Have Advantage | 1d12+8+(?d1=20,1d12) #Grog Kick Damage /r $combo = #Grog Always Combos at +3 | $punch+3 | $punch?2 | $kick+3 | $kick?2 | #Final Damage | ?3 + ?5 $combo Might Return:
@OrbitalBliss: Grog Always Combos at +3
@OrbitalBliss: 1d20+5+3 Grog Punches = (20)+5+3 = 28
@OrbitalBliss: 1d10+6+(20=20,1d10) Grog Punch Damage = (7)+6+(9) = 22
@OrbitalBliss: 2d20k1+7+3 Grogs Kicks Have Advantage = (11,9)+5+3 = 19
@OrbitalBliss: 1d12+8+(12=20,1d12) Grog Kick Damage = (9)+6 = 15
@OrbitalBliss: Final Damage
@OrbitalBliss: 22 + 15 = 37
Notice: ?3 and ?5 recall those resolved/calculated "rolls" (mini alias) from within the current alias $punch?2 recalls the second "roll" (mini alias) from $punch ?d1 recalls the first 'die roll' from within the same alias as itself
$punch?d2 would recall the second die roll from the alias $punch, etc.
Thanks for the examples, they've got me thinking.
I want to reimplement the parser in nom 5 (it's using nom 3 now and the syntax has changed dramatically in nom 5). And that reimplementation should also break the one-expression-per-command limit.
I don't like the positional arguments. The named variables should require minimal boilerplate to use (no sigils or var
/ let
/ const
operators, just x =
, as in Haskell). The roll remains an expression, but evaluation of that expression can be separated into subexpressions with ;
. So in my book:
/r $punch = attack = 1d20 + 5 # Grog Punches; 1d10 + 6 + if attack == 20 {1d10} # Grog Punch Damage
As for the comments problem, the answer seems to lie in the multiline output, dedicating a separate line for every subexpression.
$punch?2
can be mistaken for a conditional statement, we might use the dot operator instead: $punch.attack
.
Memorized rolls would no longer work by lexical substitution, instead they'll be evaluated into a map of variables (with the final expression being in the r
variable unless named otherwise).
/r $punch.attack; $punch.r; $punch
would still roll the $punch
trice
(resulting in 9 lines of output).
To roll it once we'd need /r punch = $punch; punch.attack; punch.r; punch
(two lines of output for $punch
subexpressions and four lines of output for punch = $punch
, punch.attack
, punch.r
, punch
subexpressions each).
That's how I see it at present. But we'll need the pluggable dice engines implemented first, and then the new syntaxis will be developed at first as a pluggable dice engine.
P.S. I've added a parsers
subcrate that has the nom 5 parsers in it (as opposed to nom 3 parsers in dice.rs
), this might open an extra path for experimentation (besides or in parallel to pluggable dice engines).
Figured how to use nom 5 parsers from nom 3 parsers, giving us more options of how to integrate a new parsing strategy.
Please keep us updated on this, I have wanted this feature for a long time and hunted to see if someone else flagged it. This would do wonders for multiple attack rounds. E.g. /r 1d20+5 #Claw 1 | 1d20+5 #Claw 2 | 1d20+8 #Bite | 1d20+4 #Tail | 1d20+8 #Haste Bite
Having to do those each time is time consuming, being able to cut and paste that attack as one line each time would be wonderful, being able to memorize all that as a standard roll would be amazing.
Our group would like to see a Multiple Distinct Rolls option.
Perhaps: /r 2d20k1+5 # Grog Attacks With Advantage | 1d10+6 # Grog's Damage
Might Return:
Referencing earlier rolls conditionally would be wonderful: /r 1d20+5 # Grog Attacks | 1d10+6+(?1=20,1d10) # Grog's Damage In this case, is the first roll (?1) was a 20, add 1d10 more damage.
Finally, and mostly a seperate Request: Could the memorized rolls please also store (#) Comments? So memorizing the first example roll(s) above would be more convienient.