annotate bin/roll @ 12268:6bbbe2a95120
draft
<b_jonas> slashlearn euclid//Euclid is a short geeky game in which the goal is to do Euclidean compass and straightedge constructions in as few steps as possible. It runs in the browser, found at "http://www.euclidthegame.com/". It was popular among #esoteric regulars in 2016-07.
author |
HackEso <hackeso@esolangs.org> |
date |
Mon, 16 Dec 2019 23:02:52 +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
|