Code Monkey home page Code Monkey logo

magic-search-engine's Introduction

Search engine for Magic: The Gathering cards.

Ruby on Rails frontend

To run frontend like http://mtg.wtf/

$ cd frontend
$ bundle
$ bundle exec rails s

Command line

To search card names from command line:

$ ./search-engine/bin/find_cards "query"

To search card names and content from command line:

$ ./search-engine/bin/find_cards -v "query"

To explore card database from Ruby console:

$ ./search-engine/bin/pry_cards

Testing

Tests for library and for Rails frontend are separate:

$ (cd search-engine; bundle install)
$ (cd search-engine; bundle exec rspec)
$ (cd frontend; bundle install)
$ (cd frontend; bundle exec rake test)

How to update database

Whenever new set is released:

  • Run rake rules:update in case Comprehensive Rules changed
  • If set is not Vintage-legal, add new set code to FormatVintage exclusions list
  • Add new set code and date to legalities in Standard, Modern, Pioneer, and Frontier if applicable
  • Update format tests
  • rake pennydreadful:update

Then import cards:

  • Run rake mtgjson:update to fetch mtgjson data and index it (this can fail if there are any mtgjson quality issues)
  • Run rake test and fix any tests failing due to data changes

Whenever banned and restricted list is announced:

  • Update BanlistTest and/or BanlistCommanderTest
  • Update Banlist data

Ban lists

magic-search-engine's People

Contributors

axxroytovu avatar davidmartos96 avatar deepsourcebot avatar fenhl avatar fverdoja avatar ivar avatar jhallbachner avatar kodawah avatar silasary avatar taw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

magic-search-engine's Issues

Direct card lookup is broken

Looking up a card directly by name (!Card Name) produces an error message. Example

We're sorry, but something went wrong.

If you are the application owner check the logs for more information.

License

I would like to create a fork of this for the Custom Magic community, since we now have the Custom Standard and Custom Eternal formats. Could you please add a licence that would allow me to do this?

playable:modern

It's not totally clear how to achieve that (fetch top-8 decks from wizards.com etc.), and what would be the threshold, but I wanted this feature a lot of times to just filter the relevant cards.

Whitespace is ignored for single-word search strings

I suspect this may be design choice, but I find it annoying that I can no longer (compared to magiccards.info) strictly search for "land" (i.e. while excluding "island" and "nonland") by using the search string o:" land".

Expose format history / banlist changes in UI

We have better banlist history information than anybody else, so it's a shame that it's burried deep in the code and only accessible via time:.

It would be nice to create interface for that.

Level Up cards have really messed up boxes

Example

Level up {R} 
LEVEL 4-7
4/4
Flying
LEVEL 8+
8/8
Flying, trample
{R}: Kargan Dragonlord gets +1/+0 until end of turn.
2/2

This really makes no sense. It should probably be, with proper symbols, something like:

[some indicator]
  Level up {R} 
  2/2
[LEVEL 4-7]
  Flying
  4/4
[LEVEL 8+]
  Flying, trample
  {R}: Kargan Dragonlord gets +1/+0 until end of turn.
  8/8

With proper icons, and some layout resembling actual card.

That will require fairly aggressive regexp shenanigans in indexer, as our data sources don't have that.

Low priority as it was just one set, and maro said it's 8 on storm scale so quite unlikely to ever return.

Missing symbols

The following symbols seem to be missing and are rendered as text instead:

  • {CHAOS} (plane cards)
  • {P} (Rage Extractor)
  • {PW} (rulings of plane cards)
  • Level symbols (cards with level up)
  • Loyalty costs (planeswalkers)

Mana costs in rulings are not displayed correctly

For an example see the card Grand Arbiter Augustin IV:

The rulings should read

  • 2006-05-01 Spells you cast that are both blue and white cost {2} less to cast.
  • 2006-05-01 This reduces only generic mana portion of mana costs. A spell you cast with mana cost {1}{W}{U} will cost {W}{U} to cast.

But instead they actually read

  • 2006-05-01 Spells you cast that are both blue and white cost less to cast.
  • 2006-05-01 This reduces only generic mana portion of mana costs. A spell you cast with mana cost will cost to cast.

Search by name, advanced

It would be helpful to be able to search by exact name in addition to other queries, e.g. to link to a combo:

name="Painter's Servant" or name=Grindstone

And this feature would be helpful for the MM3 number crunch currently going on: lexical name comparison. For example, to find the possible cards in slot 247:

f:Modern print<=M14 t:land name>"Selesnya Guildgate" name<"Simic Guildgate"

Rules page jumps to top after using section link

Clicking an anchor link to a section or rule on the rules page seems to trigger some sort of JS reload in addition to the anchor jump. The result is that the page scrolls up to the very top.

Increase gap between abilities

Currently, the paragraph break between abilities has the same height as line breaks within an ability. It would be useful to be able to tell where an ability ends and the next begins in a card's Oracle text.

There are queries which are difficult to express

Some things I wanted to do:

  • r>=rare - currently needs (r:rare or r:mythic) (what about r:special ?)
  • some way to express Standard-legal printings - is (st:core or st:ex) even right?
  • cards released on specific date - print:"2015-07-17" works, but requires quotes, print:2015-07-17 silently does print:2015 not 07 not 17
  • cards related to some other cards needs related:t:* since t:* matches everything.
  • hybrid mana in Oracle text - in most other contexts {u/g} and {g/u} both work, but for o: queries order needs to be specific
  • all queries about what's a reprint - simple queries don't work due to noise from promos, Duel Decks etc.
  • cards which are in two sets, like e:m10 alt:e:m11 - all operators like alt: are rather dubious, // is the only really intuitive one
  • example of failed query I tried - f:standard (r:rare or r:mythic) sort:new (st:core or st:ex) alt:(st:core or st:ex) - now f:standard r>=rare sort:new st:std alt:(st:std)

Advanced sorting features

The following features would be nice to have:

  • Reversed sorting. For example, -sort:name for reverse alphabetical order.
  • Sort by color or color identity: sort:color and sort:ci. I'd suggest the following order:
    • start with colorless,
    • then white, blue, black, red, green,
    • allied pairs (WU, UB, BR, RG, RW),
    • enemy pairs (WB, UR, BG, RW, GU),
    • shards (GWU, WUB, UBR, BRG, RGW),
    • wedges (WBG, URW, BGU, RWB, GUR),
    • 4-color (WUBR, UBRG, BRGW, RGWU, GWUB),
    • and finally WUBRG
  • Sort by rarity: sort:rare (special, mythic, rare, uncommon, common, land)
  • Multiple sort orders. For example, sort:cmc sort:color to sort by cmc first, and cards with the same cmc are sorted by color.

Banlist timelines should link to announcements whenever possible

Lists like this should contain links to provide some context.

This requires some tweaking of current format, as right now it's organized by date, and two announcements (like normal format and Commander) could possibly share same date.

Some really old stuff won't have good links.

Decklist visualizer

  • basic decklist visualizer, similar to one on wizards.com and everywhere else - two columns for cards, one for automatic preview on mouseover
  • group cards by main type
  • cards need to be links to details page
  • DeckList class somewhere to handle logic
  • show mana costs with card name maybe
  • sensible printing for preview selected by set code hint (this is lacking on most visualizers)
  • make it look decent
  • frontend needs to be able to get reasonable decklist and visualize it
  • split cards, DFCs etc. all work
  • connect it with https://github.com/taw/magic-preconstructed-decks somehow
  • create index for https://github.com/taw/magic-preconstructed-decks
  • decklist download button in one or more commonly used formats
  • experiment with alternative views, like one in mtggoldfish deck techs
  • let users automatically visualize decks based on upload, textarea input, or drag and drop
  • functionality like sample hand / mana curve / color breakdown etc.
  • previewed card should try to stay in view, see http://mtg.wtf/deck/c16/breed-lethality and scroll down
  • make download button not derp visually on narrower screens

This is only loosely connected to the whole search engine idea.

It mostly blocks #53

Allow searching by foreign name

It would be helpful if searching by name also worked for non-English card names, or if there were a special syntax for this.

Preconstructed deck lists

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.

Search engine enhancement ideas

Here's a bunch of vague ideas:

  • color search is mess - probably best to make it work like mana, with = <= >= etc.
  • if search engine fails to parse your query, it needs to give far better feedback
  • there's a bunch of secret syntax on mci like is:reprint / not:reprint
  • scryfall again has a bunch of cute nicknames like is:fetchland, I'm not terribly convinced we want to support that, but at least it's easy
  • scryfall has e:tsp+mm2 for cards that were in both tsp and mm2. We'd need to do somewhat awkward (e:tsp alt:e:mm2) or (e:mm2 alt:e:tsp).
  • they even have is:etb, that's presumably some cute regexp (actually their regexp is not that great, it misses Sun Titan and probably a lot of other cards)
  • some kind of search everywhere operator like *:gideon or any:gideon, which would expand to like gideon or t:gideon or o:gideon or ft:gideon.
  • I'm vaguely tempted to make any operator even work with colors etc. so you could say *:"blue elf" and it would among other things look for c:u t:elf. I'm even slightly tempted to make this default operator, so blue elf is any-search, and specifically title search would require name:"blue elf", but that's probably going too far.
  • Fix cards' release dates so X prerelease and X card are both counted as not reprints.
  • scryfall added regexp search, which we already sort of do for ~. Maybe it's worth considering (assuming we make sure there are no security problems here, regexps are code). I wanted to search for things like "+X/+X" a bunch of times.
  • support for some nicknames like is:fetchland added, but one that would be really interesting is is:manland. Possibly a few others for Commander use (manadork, manarock etc.), but less sure about those.
  • we have very good spelling correction system - for example searching "borborgmos" will return both relevant cards - except it doesn't deal with case where word is split, like when you search "gutshot", but card is Gut Shot.
  • now that we have regexp search for some fields, are there any other fields which could use it?

No idea if any of that will happen.

Any feedback?

Lands are treated as colored cards

I'm not sure why, but the search engine won't return any results for "c:c t:land". what this means in practice is that excluding colorless cards from a search fails to exclude lands.

Information about Vanguard MTGO-only cards is messed up

As far as I can tell, Gatherer is wrong, and mtgjson is wrong (in a different way).

Here's example on just one of avatars:

wiki says there were only 32 printed, rest is MTGO-only. That agrees with scan source.

Here's another one:

  • 1 2 - different art, but on-picture credit is UDON, but mtgjson credit is different

No idea what to do with those MTGO-only cards. Right now we have correct Oracle text, but "printings" are all messed up, and I'm not sure what's the one true source of information here.

Scoped time travel

It would be helpful if the time: syntax could be enclosed in parentheses to limit the time travel to the enclosed part of the query. Everything outside of the parentheses would be in relation to the current date as normal.

For example, to list all cards that rotated out of Standard with Shadows over Innistrad:

(time:OGW f:Standard) not (time:SOI f:Standard)

One with Nothing returns One with Nature

To reproduce:

  1. Query One with Nothing
  2. Card "One with Nature" is returned.

Noticed that if I query "One with Nothing" (with quotes), the correct card is returned.

Color Indicator

I think it would be great to have a mention of when a card has a color indicator.

As it is, there is absolutely no indication that Pact of Negation isn't colorless, for example.

Flipped flip cards should not have a nonzero mana cost

I want a list of things I can use as my commander. (t:Legendary t:Creature OR o:"can be your commander") mana>0 should do that, but apparently Autumn-Tail, Kitsune Sage is treated as having the same mana cost as Kitsune Mystic when that's not the case.

Short rarity query

There are only 6 possible rarities in MTG JSON: Common, Uncommon, Rare, Mythic Rare, Special, and Basic Land. It would make sense to have abbreviations for the rarity filters, for example:

  • r:L (Basic Land)
  • r:C (Common)
  • r:U (Uncommon)
  • r:R (Rare)
  • r:M (Mythic Rare)
  • r:S (Special)
    • possibly with r:P as an alias for r:S (used on the M15 frame for promo cards)

"bound" the search string?

Is there a way for the code to allow for restricting the search string so that nothing happens before or after it? Let's say I want cards whose rule text consists of "flying" and nothing else, I could search (say) o:|flying| (or maybe |flying, first strike| etc.). Or maybe I want cards with no keywords, like o:|whenever". Previously clever use of space in search string would allow some of it (o:flying -o:" "), but, well... #32 kinda makes it impossible anyway.

I know the use cases are a little weird, but I'm sure people could come up with more sensible ones.

Every card needs a picture

LQ only pictures are just fact of life, as it takes time for HQ scans to appear. But there's really no good reason to have cards without any pics at all. Current stats:

  • xln: 299 LQ - no scans yet, nothing to worry about
  • c17: 309 LQ - no scans yet, nothing to worry about
  • cma: 320 LQ - no scans yet, nothing to worry about
  • emn: 220 HQ, 3 LQ - meld cards HQ cards not really worth the effort
  • wmcq: 2 HQ, 3 No Picture
  • mlp: 32 HQ, 1 LQ, 3 No Picture
  • mgdc: 49 HQ, 1 LQ
  • gpx: 11 HQ, 1 No Picture - added missing picture as LQ
  • hho: 10 HQ, 1 No Picture - added missing picture as LQ
  • st2k: 20 HQ, 38 LQ
  • ptc: 128 HQ, 1 LQ, 173 No Picture
  • van: 32 HQ, 84 LQ
  • uqc: 5 HQ, 1 LQ

It's pretty much Prerelease Events cards.

Pictures exist off-repository, but existence of pictureless cards complicates features like deck visualizer's optimal printing selection #57 and sort:rarity #29

It's also entirely possible that some of these no-picture promos are mtgjson errors.

Loyalty symbols for planeswalkers

Example

Now that we use mana font, it wouldn't be too hard to make planeswalkers use loyalty icons.

They work differently from mana symbols costs (they're in own minicolumn, so next line won't go under them, but align with first line.

Medium priority, as current layout is perfectly understandable, but planeswalkers are very prominent cards so they could use some nice graphics.

Autofocus search field

It would be helpful if the search field could automatically take keyboard focus when you start typing on the page. Something like this maybe.

Investigate alternatives to mtgjson

mtgjson has been disappointing in quality, and that version 4 is not coming.

So I started writing a simple Gatherer scrapper https://github.com/taw/magic-database

Tasks are:

  • make scrapper work with split, flip, dfc, meld and other such nonstandard cards
  • export all of Gatherer to json with it
  • compare how many differences there are
  • with different cards, compare quality
  • check how many missing cards there are. By count 30911 of our cards have multiverseid, 30819 unique (duplicates presumably split cards etc.), 2213 are various mostly old promos without Gatherer ids.

After that possibilities are:

  • use importer as main source, maintain promo db manually
  • use importer as main source, use mtgjson as secondary source
  • create some mtgjson / importer hybrid that exports to "fixed" mtgjson format
  • or maybe it's all pointless

Another possibility is that with importer mtg.wtf could have spoiler cards, by just adding secondary source somehow, before Gatherer gets them.

Accept language codes printed on cards

Follow-up to #6: Simplified Chinese should be searchable by cs:巨龙, and Traditional Chinese should be searchable with ct:巨龍, since these are the language codes printed on the M15 card frame.

Ixalan Release

Just up

So Gatherer is a bit broken (Printings.asp fails), fortunately we don't use any information on it (that's list of card printings + legalities). I tweaked http://github.com/taw/magic-database to skip those bad files.

It will probably delay mtgjson a lot (unless Gatherer fixes it), so I'm pretty happy I wrote this backup.

If anybody needs mtgjson files, ./indexer/bin/merge_mtgjson can rebuild mtgjson-equivalent (except it currently drops printings field)

If you see any issues, report them here.

And I'm still seriously considering getting cards directly from spoilers, at least when spoiler is full (like Iconic Masters now).

Reserved List info

It would be useful to have a “this card is on the Reserved List” text on the card info page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.