view bin/roll @ 3911:8c112ffd5765

<kmc> addquote zzo38 [~zzo38@24-207-49-17.eastlink.ca] has quit [Quit: I need the stats for the small leech, not the big one. So, if you write it on here while I am gone then when I return I will check.]
author HackBot
date Tue, 15 Oct 2013 22:19:50 +0000
parents e037173e0012
children
line wrap: on
line source

#!/bin/bash
rolls="$*"
if [ "$rolls" = "" ] ; then rolls="1d6" ; fi

for i in $rolls
do
    if expr "$i" : ".*[dD].*" >& /dev/null
    then
        rollc=`echo "$i" | sed 's/[dD].*//'`
        diesz=`echo "$i" | sed 's/.*[dD]//'`
    else
        rollc=1
        diesz="$i"
    fi

    roll=0
    for (( j = 0; $j < $rollc; j++ ))
    do
        roll=$(( roll + (RANDOM % diesz) + 1 ))
    done

    echo -n $roll' '
done
echo