Searching Magic Cards

Link post

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 41 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, mastodon