Chemscribbler / aesopstables

2 stars 10 forks source link

Fix decklist import failing on cards with curly quotes or curly apostrophes. #36

Closed finnbar closed 1 month ago

finnbar commented 1 month ago

Aesop's Tables asks players to import their decklists via the Jinteki.net format. However, some cards in the Jinteki.net format do not have the same titles as their actual printed title. The most common example that a number of players were thrown by was “Pretty” Mary da Silva, which is rendered as "Pretty" Mary da Silva (note the different quote marks) in the Jinteki.net output. If players copy/paste the Jinteki.net output into Aesop's Tables, decklist import will complain that "Pretty" Mary da Silva is not a valid card.

This fixes this issue by correctly comparing to the stripped_title of each card rather than just the title - there was code that seemed to attempt to do this, but if it found that it matched a stripped_title then it would just error rather than treating the card title as the non-stripped version.

The other issue is that the Jinteki.net format preserves accents, but stripped_title does not. Thus, when we check some card name against stripped_title, we remove any accents from that card name first.

If you would like, I made a pair of decklists for testing this against: an extremely normal Nova list and a similarly normal Ampere list.

This issue is fairly urgent for tournaments which use decklist imports: we nearly had to give a player a game loss in a single-elimination cut at Bristol Regionals because their decklist omitted "Pretty" Mary da Silva and Aesop's Pawnshop for some reason. I can't say for sure whether this PR fixes whatever happened, but both of those cards are affected by this bug so I would not be surprised if this fixed it.

Brief note I just spotted: I had to update the cards.json included in the repo as it was out-of-date. It replaced it with a version with no line breaks for some reason, so it looks like I deleted 14000 lines of code! Feel free to revert this part.

Chemscribbler commented 1 month ago

This breaks existing import logic - Events, Resources, etc. are no longer recognized as non-cards when copied and pasted from Jinteki.net (which is a reasonable enough reading of "Jinteki format" that I want to make sure it's supported.

(Also as a small future note - if you can avoid putting quotes in the pull request name, I do some of my dev work on a Windows machine - and it cannot accept " as part of a path name)

Chemscribbler commented 1 month ago

Thanks for fixing this, was quite helpful 👍

finnbar commented 1 month ago

re: "Jinteki format" - okay that seems reasonable, and makes the undocumented bracket checks in the previous version of the decklist parser make a lot more sense. Thank you for fixing that.