Skip to content

Instantly share code, notes, and snippets.

@EmperorPenguin18
Created December 24, 2025 03:53
Show Gist options
  • Select an option

  • Save EmperorPenguin18/823a1e41ebb170ebe3e19c00db3a9409 to your computer and use it in GitHub Desktop.

Select an option

Save EmperorPenguin18/823a1e41ebb170ebe3e19c00db3a9409 to your computer and use it in GitHub Desktop.
Morophon Creature Type Script
#!/bin/sh
# Keywords are considered "cheating" for the purposes of this script. This includes, as of writing, changeling, amass, living weapon, awaken, embalm, fabricate, eternalize, afterlife, incubate, for mirrodin!, and gift
# The query being done is an approximation, but should be 99.9% accurate
# Improvements: - Doesn't include goblin barrage or quest for the goblin lord, somehow compare number of type to number of name
# https://stackoverflow.com/questions/24656131/regex-for-existence-of-some-words-whose-order-doesnt-matter
# - Check that tiers are balanced
# - Overall testing
filename="type_log.csv" && \
ctype="$(shuf -n1 -e $(curl -s 'https://api.scryfall.com/catalog/creature-types' | jq .data[]))" && \
url="https://api.scryfall.com/cards/search?q=(t:$ctype+or+(o:/${ctype}s*/+-(name:/${ctype}s*/+o:~+-(o:/(goblins*+(.|\\n)*){2,}/+-o:/(~(.|\\n)*){2,}/))))+game%3Apaper" && \
count="$(curl -s "$url" | jq .total_cards)" && \
tier="F" && \
[ "${count}" -lt 3 ] && tier="SSS" || \
[ "${count}" -lt 10 ] && tier="S" || \
[ "${count}" -lt 50 ] && tier="A" || \
[ "${count}" -lt 100 ] && tier="B" || \
[ "${count}" -lt 250 ] && tier="C" || \
[ "${count}" -lt 500 ] && tier="D" && \
entry="$(cat $filename | wc -l)" && \
totaltype="$(grep $ctype $filename | wc -l)" && \
totaltier="$(grep ",$tier," $filename | wc -l)" && \
echo "$entry,$(date),$ctype,$totaltype,$count,$tier,$totaltier" >>$filename && \
echo "$ctype, count: $count, tier: $tier, entry: $entry\nquery: $(printf $url | sed 's/api\.scryfall.com\/cards/scryfall.com/g')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment