-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Hello,
I quite appreciate this little game, so I made a little wrapper script to log wins and playing time. It is available in my private github, so I paste the whole thing here. Feel free to include this under in the project if you wish.
#!/usr/bin/sh
DATABASE_PATH=~/.local/state/ttysolitaire
DATABASE=$DATABASE_PATH/db
mkdir -p $DATABASE_PATH
touch $DATABASE
FILE_RESULT=$(mktemp)
FILE_TIME=$(mktemp)
/usr/bin/time -f "%e" -o $FILE_TIME sh -c "ttysolitaire | tee $FILE_RESULT"
RESULT=$(grep "You won" $FILE_RESULT | wc -l)
GAME_TIME=$(cat $FILE_TIME)
echo $RESULT $GAME_TIME >> $DATABASE
rm -fr $FILE_TIME $FILE_RESULT
# Treating the database
GAME_TOTAL=$(cat $DATABASE | wc -l)
GAME_WINS=$(cut --delimiter " " --fields 1 $DATABASE | grep 1 | wc -l)
TIME_AVERAGE=$(grep '^1' $DATABASE | cut --delimiter " " --fields 2 | datamash mean 1)
echo Win Rate $GAME_WINS/$GAME_TOTAL $(echo "scale=2; 100 * $GAME_WINS / $GAME_TOTAL" | bc)%
if [ $RESULT -eq 1 ]; then
echo Time/Average $GAME_TIME/$TIME_AVERAGE
fiMetadata
Metadata
Assignees
Labels
No labels