Created
December 24, 2020 15:08
-
-
Save bazzargh/4f16b4dbb7a8a0cccf7ce5686d48db12 to your computer and use it in GitHub Desktop.
scrabble by mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
case "${1:-help}" in | |
inspect) | |
cat bag|openssl aes-256-cbc -a -d -salt -pass pass:scrabble | |
;; | |
start) | |
CONTENTS=$( | |
( | |
echo EEEEEEEEEEEE; | |
echo AAAAAAAAA; | |
echo IIIIIIIII; | |
echo OOOOOOOO; | |
echo NNNNNNRRRRRR; | |
echo TTTTTTLLLLSSSS; | |
echo UUUUDDDDGGG; | |
echo BBCCMMPP; | |
echo FFHHVVWWYY; | |
echo KJXQZ | |
) | fold -w1; | |
echo blank; | |
echo blank | |
) | |
echo "$CONTENTS"|shuf|openssl aes-256-cbc -a -salt -pass pass:scrabble > bag | |
;; | |
draw) | |
CONTENTS=$(cat bag|openssl aes-256-cbc -a -d -salt -pass pass:scrabble) | |
echo "$CONTENTS"|head -n ${2:-1} | |
echo "$CONTENTS"|tail -n +$(( ${2:-1} + 1))|shuf|openssl aes-256-cbc -a -salt -pass pass:scrabble > bag | |
;; | |
discard) | |
if [ ! -z "$2" ]; then | |
CONTENTS=$(cat bag|openssl aes-256-cbc -a -d -salt -pass pass:scrabble) | |
(echo $2;echo "$CONTENTS")|shuf|openssl aes-256-cbc -a -salt -pass pass:scrabble > bag | |
fi | |
;; | |
*) | |
cat <<-END | |
USAGE: | |
$(basename $0) start - shuffle all tiles into the bag | |
$(basename $0) draw N - draw N tiles from the bag | |
$(basename $0) discard A - return tile 'A' to the bag | |
$(basename $0) help - print this message | |
END | |
exit 1 | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment