taw / magic-search-engine

Search engine for Magic cards
MIT License
43 stars 20 forks source link

Preconstructed deck lists #53

Closed fenhl closed 6 years ago

fenhl commented 6 years ago

The help channel #mtgrules just got a question about which cards from the C13 precon Nature of the Beast are legal in Modern. Answering this question was possible by jumping through some hoops, but this could be improved: I would like to request a parameter deck: which would filter by cards (or, more correctly, printings) that appeared in that deck. The data for these deck lists can be obtained from the wiki, for example. With this feature, the question could be answered using the query deck:"Nature of the Beast" f:Modern.

fenhl commented 6 years ago

I could aggregate the data for these deck lists as an MTG JSON extension.

taw commented 6 years ago

Yeah, it sounds useful, and it's a nice weekend project to scrap all lists.

There's been quite a few decks.

I wrote scripts for scrapping decklist data from Wizards site, which could make it a lot faster - but it's been a while since I last used them.

fenhl commented 6 years ago

In case anyone is curious, here's how I answered the question without this feature:

  1. Open the edit page for the wiki article
  2. Remove the section headers from the decklist
  3. Copy the decklist to the clipboard
  4. Run the script pbpaste | perl -pe 's/[0-9]+ (.+?)\n/ or name="$1"/g' | perl -pe 's/$/)\n/' | perl -pe 's/^ or /(/'
  5. Paste the resulting query into mtg.wtf and add f:Modern
  6. Shorten the results page's URL using http://tinyurl.com/ to avoid IRC's message size limit (other URL shorteners including 4.ly, bit.ly, and goo.gl rejected the URL for being too long)
taw commented 6 years ago

Wiki has download links for decklists, that could save you one step.

taw commented 6 years ago

I'd redirect further discussion to this new repo: https://github.com/taw/magic-preconstructed-decks/issues/1

taw commented 6 years ago

All precons are now on the site. http://mtg.wtf/deck/c13/nature-of-the-beast etc.

Search is not implemented yet, I mostly need to figure out how to deal with decks having same name. For example there's been quite a few decks called "Goblins". (also one "Goblin" which seems like an error).

I could just match them all. e:"Merfolk vs. Goblins" deck:"Goblins" or e:rix deck:Angrath is reasonable enough UI. (well actually not really, a lot of precons contain cards from multiple sets)

There's one additional problem that currently decklists just pick one arbitrary printing when multiple are available. So the search engine thinks only 1/3 C17 Forests actually exist. In perfect world we'd have exact information which Forest was in which deck, given data we have, it's probably easiest to say it's in deck if any printing from given set is.

taw commented 6 years ago

deck:"Nature of the Beast" f:Modern query totally works now

I'm sure there are some issues with the system, they should go into separate tickets.

In perfect world, this information should probably move to mtgjson, but it's hard to get them to fix typos, so for time being I'll maintain it as part of https://github.com/taw/magic-preconstructed-decks

fenhl commented 6 years ago

We're rewriting MTG JSON in Python now. If you'd like to contribute or just give suggestions, feel free to join us on Discord: https://discord.gg/74GUQDE

taw commented 6 years ago

I'll drop by for a chat. Realistically I have so many unfinished projects and so little time, I won't be able to contribute much. This one was about one day to finish, but it waited half a year for that one free day.

It would be nice if at some point someone took over maintaining precon database and integrated it into new mtgjson, but it's a fairly easy project to run at this point.

Or even better if someone tagged what's foil and what's not, but that's a lot of decks to tag. (it's one of many prerequisites for is:foil / is:nonfoil search).