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:

Weird People of History: Jenny from the Jane Abortion Collective

Direct action when abortion was illegal

via Thing of Things October 24, 2024

Inner dialogue, walking down the sidewalk

A discussion I have with myself a lot The post Inner dialogue, walking down the sidewalk appeared first on Otherwise.

via Otherwise October 10, 2024

Startup advice targeting low and middle income countries

This post was inspired by a week of working from Ambitious Impact’s office in London, and chatting with several of the startup charities there. While my experience is in the for-profit world, I think it’s applicable to entrepreneurs working on impact-driv…

via Home September 27, 2024

more     (via openring)