2024-04-25 16:21:02 -05:00
|
|
|
#!/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")"
|
2024-04-25 16:31:37 -05:00
|
|
|
local suits=n"$(eval "echo \$${name}_SUITS")"
|
2024-04-25 16:21:02 -05:00
|
|
|
local suit_cards="$(eval "echo \$${name}_SUIT_CARDS")"
|
2024-04-25 16:31:37 -05:00
|
|
|
|
2024-04-25 16:21:02 -05:00
|
|
|
for suit in $suits; do
|
|
|
|
for suit_card in $suit_cards; do
|
|
|
|
printf "${suit}${suit_card} "
|
|
|
|
done
|
|
|
|
done
|
2024-04-25 16:31:37 -05:00
|
|
|
|
2024-04-25 16:21:02 -05:00
|
|
|
eval "echo \$${name}_ADDITIONAL_CARDS"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-25 16:31:37 -05:00
|
|
|
mkdeck_dir() {
|
2024-04-25 16:21:02 -05:00
|
|
|
local dir="$1"
|
|
|
|
|
|
|
|
if test ! -d "$dir"; then
|
|
|
|
mkdir "$dir"
|
|
|
|
fi
|
|
|
|
if test ! -d "$dir"; then
|
2024-04-25 16:31:37 -05:00
|
|
|
1>&2 echo "Failed to create deck directory at $dir."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mkdeck_cards() {
|
|
|
|
local dir="$1"
|
|
|
|
local deck_name="$2"
|
|
|
|
local cards="$(suit_cards "$deck_name")"
|
|
|
|
|
|
|
|
if test -z "$cards"; then
|
|
|
|
1>&2 echo "No cards found for deck $deck_name. Check your environment variables:"
|
|
|
|
1>&2 echo "${deck_name}_SUITS, ${deck_name}_SUIT_CARDS, and ${deck_name}_ADDITIONAL_CARDS."
|
|
|
|
exit 3
|
2024-04-25 16:21:02 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
for card in $cards; do
|
|
|
|
touch "${dir}/${card}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-25 16:31:37 -05:00
|
|
|
mkdeck() {
|
|
|
|
local dir="$1"
|
|
|
|
local deck_name="$2"
|
|
|
|
mkdeck_dir "$dir"
|
|
|
|
mkdeck_cards "$dir" "$deck_name"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-25 16:21:02 -05:00
|
|
|
mkdeck "$1" "FRENCH"
|