magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.86k stars 761 forks source link

MTGA import fails with some promo cards (on symbols in card number) #7666

Open ldeluigi opened 3 years ago

ldeluigi commented 3 years ago

As you can see: image

I exported the list from moxfield (MTGA format).

JayDi85 commented 3 years ago

Card name and set code are fine (xmage must use scryfall sets and codes): https://scryfall.com/card/prna/246p/breeding-pool shot_210310_192415

There are must be bug in mtga parser.

ldeluigi commented 3 years ago

I removed my hypothesis. I don't understand the cause

JayDi85 commented 3 years ago

Bug somewhere in the search pattern:

shot_210310_194432

luziferius commented 3 years ago

@ldeluigi All your cases contain non-numerical characters ;)

Bug somewhere in the search pattern:

I have written an MTGA parser for one of my projects, so here are some findings that you can benefit from:

Two things need to change:

First claim: TappedOut MTGA exports may not contain the collector number. A deck for reference: https://tappedout.net/mtg-decks/yarok-throw-your-lands-in-the-air/ The MTGA export of that deck contains lines like this (shortened the list)

1 Root Maze (10E)
1 Sakura-Tribe Scout (SOK)
1 Shrieking Drake (VIS)
1 Tainted Pact (ODY)

Second claim:

For reference, this is my RE that parses the MTGA format and works for the given cases: (?P<copies>\d+) (?P<name>.+) \((?P<set_code>\w+)\)( (?P<collector_number>.+))? It uses the Python RE syntax with named groups to extract the information from the lines. It may not be useful for you directly, but could serve as a reference point

github-actions[bot] commented 3 years ago

Unable to retrieve information for "?P\w+))( (?P\d+"

luziferius commented 3 years ago

Edit: I tested it, and it seems to work. So this is invalid.

Another point: Does \p{Alnum}+ match any of -_ or accented characters?

I used google a bit, but didn’t find a definite answer, but it points towards "no".

In other words, does the parser work with this deck list?

1 Abzan Kin-Guard (FRF) 120
1 _____ (UNH) 23
1 Séance (MM3) 22
1 Déjà Vu (POR) 53

This list contains a hyphen, underscores and accented characters.

I suggest to use \S+ instead of \p{Alnum}+, which should match those.