#!/bin/bash # Defaults FEAT_COUNT=1 SUCCESS_COUNT=0 # Help function show_help() { echo "Usage: $0 [FEAT_DICE] [SUCCESS_DICE]" echo "" echo "Arguments:" echo " FEAT_DICE Number of 1d12 Feat Dice to roll (default: 1)" echo " SUCCESS_DICE Number of 1d6 Success Dice to roll (default: 0)" echo "" echo "Options:" echo " -h, --help Show this help message" echo "" echo "Examples:" echo " $0 # Rolls 1 Feat Die" echo " $0 1 3 # Rolls 1 Feat Die and 3 Success Dice" echo " $0 2 0 # Rolls 2 Feat Dice" exit 0 } # Check for help flag if [[ "$1" == "-h" || "$1" == "--help" ]]; then show_help fi # Check for arguments if [[ "$1" =~ ^[0-9]+$ ]]; then FEAT_COUNT=$1 if [[ "$2" =~ ^[0-9]+$ ]]; then SUCCESS_COUNT=$2 fi fi # Colors and formatting BOLD='\033[1m' RED='\033[31m' GREEN='\033[32m' CYAN='\033[36m' # Using Cyan for Gandalf as it's bright/distinct RESET='\033[0m' # Function to generate a random number between 1 and max roll() { local max=$1 # Read 2 bytes from /dev/urandom, convert to decimal, modulo max, add 1 # This provides better randomness than $RANDOM val=$(od -An -N2 -tu2 /dev/urandom) echo $(( (val % max) + 1 )) } echo -e "${BOLD}Rolling for The One Ring...${RESET}\n" TOTAL=0 # Roll Feat Dice (1d12) if [ "$FEAT_COUNT" -gt 0 ]; then echo -n -e "Feat Dice (${FEAT_COUNT}d12): " for ((i=0; i