<div onclick="var seed=Number(/[0-9]+/.exec(location.href));function random(){seed=(seed*9301+49297)%233280;return seed/233280;};function DiceReplace(text){text=text.replace(/roll:([\dd+\-\s]+)/gi,function($0,$1){var sum=0;var rr=$1;$1='+'+$1;$1=$1.replace(/([\+\-])(\d{0,10})(?:(d)(\d{1,10}))?/gi,function($0,$1,$2,$3,$4){if($2)$2=parseInt($2,10);else if($3)$2=1;else$2=0;var r='';if(!$3){if(typeof(sum)!='string')if($1=='+')sum+=$2;else{sum -= $2;};return $1+$2;}if($2>25||$4>100000){sum='ERROR';return $1+'OUT OF RANGE'};for(let idx=0;idx<$2;idx++){var rnd=Math.floor(random()*$4)+1;r+=$1+'d'+$4+'('+rnd+')';if(typeof(sum)!='string')if($1=='+')sum+=rnd;else sum-=rnd;}return r;});return '[<b>ROLL : '+rr+'</b>='+$1.substr(1)+'=<b>'+sum+' </b>]'});return text;};document.body.innerHTML=DiceReplace(document.body.innerHTML);"> 骰子测试 </div>
试骰子
请登录之后再进行评论
登录
[ROLL : 1d5+2d3+7-d9-12=d5(3)+d3(3)+d3(1)+7-d9(7)-12=-5 ]