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:

Book Review: The Science of Evil

In favor of philosophical argumentation

via Thing of Things August 22, 2024

When it gets complicated is when your impact is spiking

You’ve started a project or company. Great idea, great team, you’re cranking away. Build a prototype, work on acquiring the key partnerships, figure out launch planning, get a few initial users… simple enough right?

via Home August 19, 2024

How good can you be at Codenames without knowing any words?

About eight years ago, I was playing a game of Codenames where the game state was such that our team would almost certainly lose if we didn't correctly guess all of our remaining words on our turn. From the given clue, we were unable to do this. Altho…

via Posts on August 11, 2024

more     (via openring)