--- dice.mpi 2000-10-11 17:05:04.000000000 +0900 +++ dice2.mpi 2006-07-23 03:08:51.000000000 +0900 @@ -20,30 +20,36 @@ $chan = $chanr; } - my($d, @d, $d1, $d2, $dice, $src, $err, $pm); + my($d, @d, $d1, $d2, $i, $dd, $dice, $src, $err, $pm); if ($mes =~ /^\s*([\d\s\t\.dD\(\)\+\-\*\/\%]+)\s*$/) { $d1 = $d2 = $1; if ($d2 =~ /d/i) { $d1 =~ s/D/d/g; while ($d1 =~ /\d+d(\d+|%)/) { - $src = $&; - ($err, $d, @d) = &_dice($src); - $d1 =~ s/$src/$d/; - $d1 =~ s/\(([\d+\.]+)\)/$1/g; - $d2 =~ s/$src/$d(${n}D$m)/; + $src = $&; + ($err, $d, @d) = &_dice($src); + $d1 =~ s/$src/$d/; + $d1 =~ s/\(([\d+\.]+)\)/$1/g; + $d2 =~ s/$src/$d(${n}D$m)/; } } if ($err > 0) { &sendSCL("$fromc: $dice_err[$err]", $chan); } else { - &sendSCL("$fromc: $d2 = " . eval($d1), $chan) if $d; + foreach (@d) { + $dd = "$dd, " . $_; + } + $dd =~ s/^, //; + $dd =~ s/, $//; + &sendSCL("$fromc: $d2 = (" . $dd . ")", $chan) if @d; } } } sub _dice { my $src = $_[0]; - my($err, $dice, @dice, $i, $l); + my($err, $dice, @dice, $i, $l, $nmax); $err = 0; + $nmax = 10; my(%lim) = ( 4, 3, 6, 20, 8, 10, 10, 20, 12, 2, 20, 5, 30, 2, 100, 2 ); @@ -56,14 +62,15 @@ } $err = 1 if $n <= 0 || $n > int($n); $err = 2 if $lim{$m} < 1; -# $err = 3 if $n > $nmax || $n > $lim{$m}; # no use - $err = 4 if rand(1) < $n * 0.005; + #$err = 3 if $n > $nmax || $n > $lim{$m}; # no use + $err = 3 if $n > $nmax; +# $err = 4 if rand(1) < $n * 0.005; @dice = (); for ($i = $dice = 0; $i < $n; $i++) { - $dice[$i] = $dice if $i < 10; + $dice[$i] = $dice if $i < 10; #10 = $nmax $dice += int(rand($m)) + $l; - $dice[$i] = $dice - $dice[$i] if $i < 10; + $dice[$i] = $dice - $dice[$i] if $i < 10; #10 = $nmax } $m = '%' if $l == 0;