annotate bin/roll @ 12256:821155c00e34 draft

<fizzie> ` sed -e \'s|wisdom|bin|\' < ../bin/culprits > ../bin/cblprits; chmod a+x ../bin/cblprits
author HackEso <hackeso@esolangs.org>
date Sat, 07 Dec 2019 23:36:22 +0000
parents e037173e0012
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e037173e0012 Initial import.
HackBot
parents:
diff changeset
1 #!/bin/bash
e037173e0012 Initial import.
HackBot
parents:
diff changeset
2 rolls="$*"
e037173e0012 Initial import.
HackBot
parents:
diff changeset
3 if [ "$rolls" = "" ] ; then rolls="1d6" ; fi
e037173e0012 Initial import.
HackBot
parents:
diff changeset
4
e037173e0012 Initial import.
HackBot
parents:
diff changeset
5 for i in $rolls
e037173e0012 Initial import.
HackBot
parents:
diff changeset
6 do
e037173e0012 Initial import.
HackBot
parents:
diff changeset
7 if expr "$i" : ".*[dD].*" >& /dev/null
e037173e0012 Initial import.
HackBot
parents:
diff changeset
8 then
e037173e0012 Initial import.
HackBot
parents:
diff changeset
9 rollc=`echo "$i" | sed 's/[dD].*//'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
10 diesz=`echo "$i" | sed 's/.*[dD]//'`
e037173e0012 Initial import.
HackBot
parents:
diff changeset
11 else
e037173e0012 Initial import.
HackBot
parents:
diff changeset
12 rollc=1
e037173e0012 Initial import.
HackBot
parents:
diff changeset
13 diesz="$i"
e037173e0012 Initial import.
HackBot
parents:
diff changeset
14 fi
e037173e0012 Initial import.
HackBot
parents:
diff changeset
15
e037173e0012 Initial import.
HackBot
parents:
diff changeset
16 roll=0
e037173e0012 Initial import.
HackBot
parents:
diff changeset
17 for (( j = 0; $j < $rollc; j++ ))
e037173e0012 Initial import.
HackBot
parents:
diff changeset
18 do
e037173e0012 Initial import.
HackBot
parents:
diff changeset
19 roll=$(( roll + (RANDOM % diesz) + 1 ))
e037173e0012 Initial import.
HackBot
parents:
diff changeset
20 done
e037173e0012 Initial import.
HackBot
parents:
diff changeset
21
e037173e0012 Initial import.
HackBot
parents:
diff changeset
22 echo -n $roll' '
e037173e0012 Initial import.
HackBot
parents:
diff changeset
23 done
e037173e0012 Initial import.
HackBot
parents:
diff changeset
24 echo