Skip to content

Instantly share code, notes, and snippets.

@lynnfaraday
Created January 11, 2017 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynnfaraday/a3fd1c5d0cb7c2b3da9f7852bbeee9da to your computer and use it in GitHub Desktop.
Save lynnfaraday/a3fd1c5d0cb7c2b3da9f7852bbeee9da to your computer and use it in GitHub Desktop.
FFG Dice
+ffgroll <proficiency>+<ability>+<boost> vs <challenge>+<difficulty>+<setback>
+ffgroll 2+2+1 vs 2+1+2
Rolling proficiency die: S A
Rolling proficiency die: S
Rolling ability die: A A
Rolling ability die:
Rolling boost die: A
Rolling challenge die: F F
Rolling challenge die: T T
Rolling difficulty die:
Rolling setback die: T
Rolling setback die:
0 successes 1 advantages 2S 2F 4A 3T 0D 0R (roll=A A A A F F S S T T T)
+ffgroll 2+2+1 vs 2+1+2
Rolling proficiency die: S R
Rolling proficiency die: A
Rolling ability die: A
Rolling ability die: A A
Rolling boost die: A A
Rolling challenge die: F F
Rolling challenge die: F
Rolling difficulty die: F
Rolling setback die:
Rolling setback die: T
3 failures 5 advantages TRIUMPH! 1S 4F 6A 1T 0D 1R (roll=A A A A A A F F F F R S T)
@create FFG Roller
&CMD-ROLL FFG Roller=$+ffgroll *+*+* vs *+*+*:think pemit(%#,u(fun_results,%0,%1,%2,%3,%4,%5,%6))
&DESCRIBE FFG Roller=+ffgroll <proficiency>+<ability>+<boost> vs <challenge>+<difficulty>+<setback>
&DIE_ABILITY FFG Roller=|S|S|S S|A|A|S A|A A
&DIE_BOOST FFG Roller=||S|S A|A A|A
&DIE_CHALLENGE FFG Roller=|F|F|F F|F F|T T|F T|F T|T T|T T|F D
&DIE_DIFFICULTY FFG Roller=|F|F F|T|T|T|T T|F T
&DIE_PROFICIENCY FFG Roller=|S|S|S S|S S|A|S A|S A|S A|A A|A A|S R
&DIE_SETBACK FFG Roller=||F|F|T|T
@@ Rolls a single die. %0: type of die
&FUN_DIE FFG Roller=localize(setq(0,extract(shuffle(xget(ffg,die_%0),|),1,1,|))[pemit(%#,Rolling %0 die: %q0)]%q0)
@@ Calls fun_roll and parses the results into something meaningful.
&FUN_RESULTS FFG Roller=localize([setq(0,u(fun_roll,%0,%1,%2,%3,%4,%5))][setq(s,sub(words(matchall(%q0,S)),words(matchall(%q0,F))))][setq(a,sub(words(matchall(%q0,A)),words(matchall(%q0,T))))] [abs(%qs)] [switch(%qs,<0,failures,successes)] [abs(%qa)] [switch(%qa,<0,threats,advantages)] [switch(t(match(%q0,R)),1,TRIUMPH!)] [switch(t(match(%q0,D)),1,DESPAIR!)] [words(matchall(%q0,S))]S [words(matchall(%q0,F))]F [words(matchall(%q0,A))]A [words(matchall(%q0,T))]T [words(matchall(%q0,D))]D [words(matchall(%q0,R))]R (roll=%q0))
@@ Rolls the specified number of dice and returns a string like S S F F F A T R D
@@ S/F = success/fail, A/T = adv/threat, D = despair, R = triumph
&FUN_ROLL FFG Roller=[sort(squish([iter(lnum(%0),u(fun_die,proficiency))] [iter(lnum(%1),u(fun_die,ability))] [iter(lnum(%2),u(fun_die,boost))] [iter(lnum(%3),u(fun_die,challenge))] [iter(lnum(%4),u(fun_die,difficulty))] [iter(lnum(%5),u(fun_die,setback))]))]
@set FFG Roller/DESCRIBE=no_command visual prefixmatch public nearby
&STARTUP FFG Roller=@set me=!no_command
@set FFG Roller/STARTUP=no_command prefixmatch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment