commit 27611131eafd6cf302f949b84b9f9f63d4c8806d Author: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Thu Apr 25 16:21:02 2024 -0500 Init diff --git a/mkdeck.sh b/mkdeck.sh new file mode 100755 index 0000000..05dd226 --- /dev/null +++ b/mkdeck.sh @@ -0,0 +1,57 @@ +#!/bin/sh +#――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― +# Name: +# Desc: +# Reqs: +# Date: +#――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― + +FRENCH_SUITS="♣ ♢ ♡ ♠" +FRENCH_SUIT_CARDS="A 2 3 4 5 6 7 8 9 10" +FRENCH_ADDITIONAL_CARDS="♣♚ ♣♛ ♣♝ ♠♚ ♠♛ ♠♝ ♢♔ ♢♕ ♢♗ ♡♔ ♡♕ ♡♗ 🃏 🃏" + +shell_sanitize() { + local str="$1" + echo "$1" \ + | tr -d '$(){}`' +} + + +suit_cards() { + local name="$(shell_sanitize "$1")" + local suits="$(eval "echo \$${name}_SUITS")" + local suit_cards="$(eval "echo \$${name}_SUIT_CARDS")" + for suit in $suits; do + for suit_card in $suit_cards; do + printf "${suit}${suit_card} " + done + done + eval "echo \$${name}_ADDITIONAL_CARDS" +} + + +mkdeck() { + local dir="$1" + local deck_name="$2" + + local cards="$(suit_cards "$deck_name")" + if test -z "$cards"; then + echo "No cards found for deck $deck_name. Check your environment variables:" + echo "${deck_name}_SUITS, ${deck_name}_SUIT_CARDS, and ${deck_name}_ADDITIONAL_CARDS." + fi + + if test ! -d "$dir"; then + mkdir "$dir" + fi + if test ! -d "$dir"; then + echo "Failed to create deck directory at $dir." + return 2 + fi + + for card in $cards; do + touch "${dir}/${card}" + done +} + + +mkdeck "$1" "FRENCH"