Exalted Dice

A dice rolling command that lets you provide the number of dice rolled, and a target range.

Author: Sketch@M*U*S*H
Category: Games
Commands: @create, @lock, @remit, @set.
Features: #lambda, regexp commands.
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Exalted Dice

@create Exalted Dice
@lock Exalted Dice==me
@set Exalted Dice=!NO_COMMAND
&CMD Exalted Dice=$^(?>\+?roll\s+)(\d+)(?\:t(\d+))?(d)?$:@remit %L=%n rolls %1d10[if(%3,%bfor damage)], target of [ifelse(%2,%2+,7+)]: [u(do_dice,u(fn_n_d10,%1),ifelse(%2,%2,7),t(%3))]
@set Exalted Dice/CMD=regexp
&COLOR_DICE Exalted Dice=ifelse(u(fn_any_successes,%0,%1),u(color_successes,%0,%1),u(color_failures,%0,%1))
&COLOR_FAILURES Exalted Dice=map(#lambda/switch(\%0,1,ansi(hr,1),<%1,ansi(r,\%0),\%0),%0)
&COLOR_SUCCESSES Exalted Dice=map(#lambda/switch(\%0,10,ansi(hg,10),>[dec(%1)],ansi(g,\%0),\%0),%0)
&COUNT_DICE Exalted Dice=ifelse(u(fn_any_successes,%0,%1),u(pluralize,success,u(fn_count_successes,%0,%1,%2)).,u(pluralize,one,u(fn_count_ones,%0,%1,%2)).)
&DESCRIBE Exalted Dice=The most holy dice you'll ever see, EVER. [ansi(h,+roll X\[tY\]\[d\])] to roll them. [ansi(h,Y)], the target range, defaults to 7. Use [ansi(h,d)] to count rolls of 10 as one success instead of two.
@set Exalted Dice/DESCRIBE=no_command visual prefixmatch public nearby
&DO_DICE Exalted Dice=\([u(color_dice,%0,%1)]\) = [u(count_dice,%0,%1,%2)]
&FN_ANY_SUCCESSES Exalted Dice=gte(last(sort(%0,n)),%1)
&FN_COUNT_ONES Exalted Dice=words(graball(%0,1))
&FN_COUNT_SUCCESSES Exalted Dice=fold(#lambda/add(\%0,switch(\%1,10,[ifelse(%2,1,2)],>[ifelse(%1,dec(%1),6)],1,0)),%0,0)
&FN_COUNT_SUCCESSES_COMMENT Exalted Dice=@@(%0 - List of space-delimited dice rolls; %1 - success threshhold; %2 - 10 is worth 1 success if TRUE)
&FN_N_D10 Exalted Dice=ifelse(isint(%0),switch(%0,<1,0,iter(lnum(1,%0),rand(1,10))),[@@(Invoke must_be_integer error message)][div(0.1,0.1)])
&PLURALIZE Exalted Dice=%1 %0[if(neq(%1,1),reswitchi(%0,\[aeiou\]$,s,es))]

look Dice