Skip to content

Instantly share code, notes, and snippets.

View qiolol's full-sized avatar
🌌
Our best art & most just societies & most profound bugs still lie ahead of us.

qiolol

🌌
Our best art & most just societies & most profound bugs still lie ahead of us.
  • Laniakea Supercluster
View GitHub Profile
@qiolol
qiolol / roll.sh
Created June 15, 2020 13:58
Polyhedral dice roller in Bash
#!/usr/bin/env bash
# Roll X dice with Y sides where $1 = "XdY" or "Y" and "X" is implied to be 1
# Inspired by Tippex x3
function roll() {
local re="^([1-9][0-9]*)*([dD]{0,1}([1-9][0-9]*)){0,1}$"
if [[ $1 =~ $re && ! $2 ]] ; then
# Parse input
local dice=1
local sides=0