annotate bin/roll @ 5612:794f3859f02c
<tswett> learn sex is a board game which originated in Britain in the 1870s before spreading throughout Europe in the 1890s. Sex was introduced to the rest of the world by a book, "The Complete Guide to Sex", written and published by Taneb in 1932, based on Taneb\'s extensive experience with a wide variety of forms of European sex.
author |
HackBot |
date |
Thu, 18 Jun 2015 01:06:51 +0000 |
parents |
e037173e0012 |
children |
|
rev |
line source |
0
|
1 #!/bin/bash
|
|
2 rolls="$*"
|
|
3 if [ "$rolls" = "" ] ; then rolls="1d6" ; fi
|
|
4
|
|
5 for i in $rolls
|
|
6 do
|
|
7 if expr "$i" : ".*[dD].*" >& /dev/null
|
|
8 then
|
|
9 rollc=`echo "$i" | sed 's/[dD].*//'`
|
|
10 diesz=`echo "$i" | sed 's/.*[dD]//'`
|
|
11 else
|
|
12 rollc=1
|
|
13 diesz="$i"
|
|
14 fi
|
|
15
|
|
16 roll=0
|
|
17 for (( j = 0; $j < $rollc; j++ ))
|
|
18 do
|
|
19 roll=$(( roll + (RANDOM % diesz) + 1 ))
|
|
20 done
|
|
21
|
|
22 echo -n $roll' '
|
|
23 done
|
|
24 echo
|