From 5fe5ef3d949f01ad68a3d683d6d69ffecc364fac Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 7 Sep 2013 15:03:57 -0400 Subject: rewrite roll in Go --- roll.php | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 roll.php (limited to 'roll.php') diff --git a/roll.php b/roll.php deleted file mode 100644 index c52f762..0000000 --- a/roll.php +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env php -]d[+MOD]\n"; -} - -function roll($input) { - preg_match('/([0-9]*)d([0-9]+)([+-][0-9]+)?/', $input, $matches); - if (sizeof($matches) < 2) { - usage(); - return; - } - $dice = (int)$matches[1]; - $die_size = (int)$matches[2]; - @$mod = (int)$matches[3]; - if ($dice<1) $dice = 1; - - $total = 0; - for ($i=0; $i < $dice; $i++) { - $v = mt_rand(1, $die_size); - echo $v.'+'; - $total += $v; - } - $total += $mod; - echo $mod.' = '.$total."\n"; -} - -if (sizeof($argv) == 1) { - usage(); -} -array_shift($argv); -foreach ($argv as $arg) { - roll($arg); -} -- cgit v1.2.3