From 166948749c12b3500f29c7c3b76a2f6b341ab122 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 19 Aug 2020 19:44:03 -0400 Subject: [PATCH] forgot to push some module changes. They seem to be working though, so may as well do it now. --- modules/roll/roll.sh | 24 +++++++++++++++++++++--- modules/spin/spin.sh | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/roll/roll.sh b/modules/roll/roll.sh index 881c465..2721301 100755 --- a/modules/roll/roll.sh +++ b/modules/roll/roll.sh @@ -6,14 +6,32 @@ roll_dice() { local i local total=0 for i in $(seq $count) ; do - total=$((total + $RANDOM % $sides + 1)) + local die=$(($RANDOM % $sides + 1)) + total=$((total + $die)) + if [[ $i -le 10 ]]; then + if [[ $i -lt $count ]]; then + echo -n "${die}, " + else + if [[ $count -gt 1 ]]; then + echo -n "and ${die} " + else + echo -n "${die} " + fi + fi + fi done - echo $total + if [[ $((count - 10)) -gt 1 ]]; then + echo -n "and $((count - 10)) more dice " + fi + if [[ $((count - 10)) -eq 1 ]]; then + echo -n "and 1 more die " + fi + echo "for a total of ${total}." } rollString="${3##* }" if ! [[ "$rollString" =~ ^[1-9][0-9]*[dD][1-9][0-9]*$ ]]; then msg "$2" "${1}: Usage is roll #d# where # is greater than 0." else - msg "$2" "$1:: I rolled ${rollString} and got a total of $(roll_dice ${rollString})." + msg "$2" "$(roll_dice ${rollString})" fi diff --git a/modules/spin/spin.sh b/modules/spin/spin.sh index 015c683..1919da6 100755 --- a/modules/spin/spin.sh +++ b/modules/spin/spin.sh @@ -17,6 +17,7 @@ if [[ "$spinPlus" == "$message" ]]; then fi fi +spin="${spin%[[:punct:]]}" message="${message} $spin $spin $spin " spinCount=$((RANDOM % 7 + 7)) for i in $(seq $spinCount) ; do