Searching Magic Cards

June 3rd, 2024
gaming
I like playing Magic, except for the "it's designed to pump away your money" aspect. So I like formats where I can play with other people's cards a lot! My favorite is probably drafting from booster packs where someone else will keep all the cards, but yesterday Stevie brought over a Forgetful Fish-style deck he'd put together, and we played a couple times. The only creature in this format is the Dandan, a 4/1 blue creature with:

Dandan can't attack unless defending player controls an Island.

When you control no Islands, sacrifice Dandan.

One of the cards in Stevie's deck was Magical Hack, a blue instant with:

Change the text of target spell or permanent by replacing all instances of one basic land type with another.

It's role in the deck was primarily to kill Dandans, by replacing "Island" on an opponent's Dandan with any basic land type they don't have. But it got me wondering: does it happen that there are any textual uses of the six basic land types [1] that are not intended to be about a basic land? For example, if a card happened to use the word "forestall", perhaps you could do something fun with it?

Supposedly you can search cards with regular expressions on Scryfall but I couldn't get it to work. Instead, I downloaded the cards as JSON from MTGJson [2] and wrote a ~10 line python script:

unusual_land_re = re.compile(
    r"(?i)"
    r"((plains)|(island)|(swamp)|(wastes)|(mountain)|(forest))"
    r"(?!(\b|s\b|[.]|walk\b|cycling\b))")

for fname in glob.glob("*.json.gz"):
  with gzip.open(fname) as inf:
    r = json.load(inf)
    if "cards" not in r["data"]: continue
    for card in r["data"]["cards"]:
      if "text" not in card: continue
        if unusual_land_re.search(card["text"]):
          print("%s: %s" % (card["name"], card["text"]))

The first time I ran it I got a bunch of "Forestcycling" etc, but after adding "cycling" to the query (as reproduced above) it didn't find anything. Oh well.

I probably could have gotten regexp searching working if I'd played with it a little more, but if I ever want to look for a card in a way that isn't reducible to a regular expression search this could be a good place to start!


[1] Forest, Plains, Mountain, Island, Swamp, and now Wastes

[2]

$ curl -sS https://mtgjson.com/api/v5/ | \
      grep -o '[^">]*.json.gz' | sort | uniq > gzip_jsons.txt
$ for x in $(cat gzip_jsons.txt); do
  wget https://mtgjson.com/api/v5/$x
done
$ du -hs .
1.0G .

Comment via: facebook, lesswrong, mastodon

Recent posts on blogs I like:

Jealousy In Polyamory Isn't A Big Problem And I'm Tired Of Being Gaslit By Big Self-Help

The nuance is in the post, guys

via Thing of Things July 18, 2024

Trust as a bottleneck to growing teams quickly

non-trust is reasonable • trust lets collaboration scale • symptoms of trust deficit • how to proactively build trust

via benkuhn.net July 13, 2024

Coaching kids as they learn to climb

Helping kids learn to climb things that are at the edge of their ability The post Coaching kids as they learn to climb appeared first on Otherwise.

via Otherwise July 10, 2024

more     (via openring)