Skip to content

feat: Add Trainer card legality for reprints + fixing some cards with surnames#996

Open
kvacquier wants to merge 4 commits intotcgdex:masterfrom
kvacquier:feat/trainer-legality-reprints-and-subnames
Open

feat: Add Trainer card legality for reprints + fixing some cards with surnames#996
kvacquier wants to merge 4 commits intotcgdex:masterfrom
kvacquier:feat/trainer-legality-reprints-and-subnames

Conversation

@kvacquier
Copy link
Copy Markdown
Contributor

Changes

  • Add Trainer card legality cache to share legality status between cards with the same name
  • Optimize compilation order: process cards from newest to oldest sets (for cache), then sort final output oldest first
  • Process Trainer cards sequentially, other cards in parallel for better performance
  • Add character name descriptions to Trainer cards (e.g., "Boss's Orders (Giovanni)")

Details

This PR implements a Trainer card legality cache system that ensures all Trainer cards with the same English name share the same legal status. When a newer Trainer card with the same name is legal, older versions of that Trainer card will also be marked as legal, which aligns with how Trainer cards work in the Pokémon TCG where same-name Trainers share legality.

The compilation process has been optimized to:

  • Process cards from newest to oldest sets during compilation (required for the Trainer cache to work correctly)
  • Process Trainer cards sequentially to build and check the cache
  • Process other cards (Pokemon, Energy) in parallel for better performance
  • Sort the final output by release date (oldest first) to maintain the original order

The cache uses English card names as keys to optimize memory usage, and only stores legality information for Trainer cards.

…- Add Trainer card cache to share legality status between cards with the same name - Process cards from newest to oldest sets during compilation (for cache) - Process Trainer cards sequentially, other cards in parallel for performance - Sort final output by release date (oldest first) to maintain original order - Add character name descriptions to Trainer cards (e.g., "Boss's Orders (Giovanni)") This ensures that if a newer Trainer card with the same name is legal, older versions of that Trainer card will also be marked as legal, which aligns with how Trainer cards work in the Pokémon TCG where same-name Trainers share legality.
@TCGdexBOT
Copy link
Copy Markdown
Member

TCGdexBOT commented Nov 17, 2025

🃏 10 Cards Changed

Details: 10 modified

Professor's Research (Professor Oak) (cel25-23) (found using en)
Language Language Language
English (en)
Professor's Research (Professor Oak) (English)
French (fr)
Professor's Research (Professor Oak) (French)
Spanish (es)
Professor's Research (Professor Oak) (Spanish)
Spanish (Mexico) (es-mx)
Professor's Research (Professor Oak) (Spanish (Mexico))
Italian (it)
Professor's Research (Professor Oak) (Italian)
Portuguese (pt)
Professor's Research (Professor Oak) (Portuguese)
Portuguese (Brazil) (pt-br)
Professor's Research (Professor Oak) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Professor's Research (Professor Oak) (Portuguese (Portugal))
German (de)
Professor's Research (Professor Oak) (German)
Dutch (nl)
Professor's Research (Professor Oak) (Dutch)
Polish (pl)
Professor's Research (Professor Oak) (Polish)
Russian (ru)
Professor's Research (Professor Oak) (Russian)

File: [data/Sword & Shield/Celebrations/23.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Celebrations/23.ts)
Set: Celebrations
Rarity: Holo Rare

Professor's Research (Professor Oak) (cel25-24) (found using en)
Language Language Language
English (en)
Professor's Research (Professor Oak) (English)
French (fr)
Professor's Research (Professor Oak) (French)
Spanish (es)
Professor's Research (Professor Oak) (Spanish)
Spanish (Mexico) (es-mx)
Professor's Research (Professor Oak) (Spanish (Mexico))
Italian (it)
Professor's Research (Professor Oak) (Italian)
Portuguese (pt)
Professor's Research (Professor Oak) (Portuguese)
Portuguese (Brazil) (pt-br)
Professor's Research (Professor Oak) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Professor's Research (Professor Oak) (Portuguese (Portugal))
German (de)
Professor's Research (Professor Oak) (German)
Dutch (nl)
Professor's Research (Professor Oak) (Dutch)
Polish (pl)
Professor's Research (Professor Oak) (Polish)
Russian (ru)
Professor's Research (Professor Oak) (Russian)

File: [data/Sword & Shield/Celebrations/24.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Celebrations/24.ts)
Set: Celebrations
Rarity: Ultra Rare

Boss's Orders (Giovanni) (swsh2-154) (found using en)
Language Language Language
English (en)
Boss's Orders (Giovanni) (English)
French (fr)
Boss's Orders (Giovanni) (French)
Spanish (es)
Boss's Orders (Giovanni) (Spanish)
Spanish (Mexico) (es-mx)
Boss's Orders (Giovanni) (Spanish (Mexico))
Italian (it)
Boss's Orders (Giovanni) (Italian)
Portuguese (pt)
Boss's Orders (Giovanni) (Portuguese)
Portuguese (Brazil) (pt-br)
Boss's Orders (Giovanni) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Boss's Orders (Giovanni) (Portuguese (Portugal))
German (de)
Boss's Orders (Giovanni) (German)
Dutch (nl)
Boss's Orders (Giovanni) (Dutch)
Polish (pl)
Boss's Orders (Giovanni) (Polish)
Russian (ru)
Boss's Orders (Giovanni) (Russian)

File: [data/Sword & Shield/Rebel Clash/154.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Rebel Clash/154.ts)
Set: Rebel Clash
Rarity: Holo Rare

Boss's Orders (Giovanni) (swsh2-189) (found using en)
Language Language Language
English (en)
Boss's Orders (Giovanni) (English)
French (fr)
Boss's Orders (Giovanni) (French)
Spanish (es)
Boss's Orders (Giovanni) (Spanish)
Spanish (Mexico) (es-mx)
Boss's Orders (Giovanni) (Spanish (Mexico))
Italian (it)
Boss's Orders (Giovanni) (Italian)
Portuguese (pt)
Boss's Orders (Giovanni) (Portuguese)
Portuguese (Brazil) (pt-br)
Boss's Orders (Giovanni) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Boss's Orders (Giovanni) (Portuguese (Portugal))
German (de)
Boss's Orders (Giovanni) (German)
Dutch (nl)
Boss's Orders (Giovanni) (Dutch)
Polish (pl)
Boss's Orders (Giovanni) (Polish)
Russian (ru)
Boss's Orders (Giovanni) (Russian)

File: [data/Sword & Shield/Rebel Clash/189.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Rebel Clash/189.ts)
Set: Rebel Clash
Rarity: Ultra Rare

Boss's Orders (Giovanni) (swsh2-200) (found using en)
Language Language Language
English (en)
Boss's Orders (Giovanni) (English)
French (fr)
Boss's Orders (Giovanni) (French)
Spanish (es)
Boss's Orders (Giovanni) (Spanish)
Spanish (Mexico) (es-mx)
Boss's Orders (Giovanni) (Spanish (Mexico))
Italian (it)
Boss's Orders (Giovanni) (Italian)
Portuguese (pt)
Boss's Orders (Giovanni) (Portuguese)
Portuguese (Brazil) (pt-br)
Boss's Orders (Giovanni) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Boss's Orders (Giovanni) (Portuguese (Portugal))
German (de)
Boss's Orders (Giovanni) (German)
Dutch (nl)
Boss's Orders (Giovanni) (Dutch)
Polish (pl)
Boss's Orders (Giovanni) (Polish)
Russian (ru)
Boss's Orders (Giovanni) (Russian)

File: [data/Sword & Shield/Rebel Clash/200.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Rebel Clash/200.ts)
Set: Rebel Clash
Rarity: Secret Rare

Boss's Orders (Lysandre) (swsh4.5-58) (found using en)
Language Language Language
English (en)
Boss's Orders (Lysandre) (English)
French (fr)
Boss's Orders (Lysandre) (French)
Spanish (es)
Boss's Orders (Lysandre) (Spanish)
Spanish (Mexico) (es-mx)
Boss's Orders (Lysandre) (Spanish (Mexico))
Italian (it)
Boss's Orders (Lysandre) (Italian)
Portuguese (pt)
Boss's Orders (Lysandre) (Portuguese)
Portuguese (Brazil) (pt-br)
Boss's Orders (Lysandre) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Boss's Orders (Lysandre) (Portuguese (Portugal))
German (de)
Boss's Orders (Lysandre) (German)
Dutch (nl)
Boss's Orders (Lysandre) (Dutch)
Polish (pl)
Boss's Orders (Lysandre) (Polish)
Russian (ru)
Boss's Orders (Lysandre) (Russian)

File: [data/Sword & Shield/Shining Fates/58.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Shining Fates/58.ts)
Set: Shining Fates
Rarity: Rare

Professor's Research (Professor Juniper) (swsh4.5-60) (found using en)
Language Language Language
English (en)
Professor's Research (Professor Juniper) (English)
French (fr)
Professor's Research (Professor Juniper) (French)
Spanish (es)
Professor's Research (Professor Juniper) (Spanish)
Spanish (Mexico) (es-mx)
Professor's Research (Professor Juniper) (Spanish (Mexico))
Italian (it)
Professor's Research (Professor Juniper) (Italian)
Portuguese (pt)
Professor's Research (Professor Juniper) (Portuguese)
Portuguese (Brazil) (pt-br)
Professor's Research (Professor Juniper) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Professor's Research (Professor Juniper) (Portuguese (Portugal))
German (de)
Professor's Research (Professor Juniper) (German)
Dutch (nl)
Professor's Research (Professor Juniper) (Dutch)
Polish (pl)
Professor's Research (Professor Juniper) (Polish)
Russian (ru)
Professor's Research (Professor Juniper) (Russian)

File: [data/Sword & Shield/Shining Fates/60.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Shining Fates/60.ts)
Set: Shining Fates
Rarity: Rare

Professor's Research (Professor Magnolia) (swsh1-178) (found using en)
Language Language Language
English (en)
Professor's Research (Professor Magnolia) (English)
French (fr)
Professor's Research (Professor Magnolia) (French)
Spanish (es)
Professor's Research (Professor Magnolia) (Spanish)
Spanish (Mexico) (es-mx)
Professor's Research (Professor Magnolia) (Spanish (Mexico))
Italian (it)
Professor's Research (Professor Magnolia) (Italian)
Portuguese (pt)
Professor's Research (Professor Magnolia) (Portuguese)
Portuguese (Brazil) (pt-br)
Professor's Research (Professor Magnolia) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Professor's Research (Professor Magnolia) (Portuguese (Portugal))
German (de)
Professor's Research (Professor Magnolia) (German)
Dutch (nl)
Professor's Research (Professor Magnolia) (Dutch)
Polish (pl)
Professor's Research (Professor Magnolia) (Polish)
Russian (ru)
Professor's Research (Professor Magnolia) (Russian)

File: [data/Sword & Shield/Sword & Shield/178.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Sword & Shield/178.ts)
Set: Sword & Shield
Rarity: Holo Rare

Professor's Research (Professor Magnolia) (swsh1-201) (found using en)
Language Language Language
English (en)
Professor's Research (Professor Magnolia) (English)
French (fr)
Professor's Research (Professor Magnolia) (French)
Spanish (es)
Professor's Research (Professor Magnolia) (Spanish)
Spanish (Mexico) (es-mx)
Professor's Research (Professor Magnolia) (Spanish (Mexico))
Italian (it)
Professor's Research (Professor Magnolia) (Italian)
Portuguese (pt)
Professor's Research (Professor Magnolia) (Portuguese)
Portuguese (Brazil) (pt-br)
Professor's Research (Professor Magnolia) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Professor's Research (Professor Magnolia) (Portuguese (Portugal))
German (de)
Professor's Research (Professor Magnolia) (German)
Dutch (nl)
Professor's Research (Professor Magnolia) (Dutch)
Polish (pl)
Professor's Research (Professor Magnolia) (Polish)
Russian (ru)
Professor's Research (Professor Magnolia) (Russian)

File: [data/Sword & Shield/Sword & Shield/201.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Sword & Shield/201.ts)
Set: Sword & Shield
Rarity: Ultra Rare

Professor's Research (Professor Magnolia) (swsh1-209) (found using en)
Language Language Language
English (en)
Professor's Research (Professor Magnolia) (English)
French (fr)
Professor's Research (Professor Magnolia) (French)
Spanish (es)
Professor's Research (Professor Magnolia) (Spanish)
Spanish (Mexico) (es-mx)
Professor's Research (Professor Magnolia) (Spanish (Mexico))
Italian (it)
Professor's Research (Professor Magnolia) (Italian)
Portuguese (pt)
Professor's Research (Professor Magnolia) (Portuguese)
Portuguese (Brazil) (pt-br)
Professor's Research (Professor Magnolia) (Portuguese (Brazil))
Portuguese (Portugal) (pt-pt)
Professor's Research (Professor Magnolia) (Portuguese (Portugal))
German (de)
Professor's Research (Professor Magnolia) (German)
Dutch (nl)
Professor's Research (Professor Magnolia) (Dutch)
Polish (pl)
Professor's Research (Professor Magnolia) (Polish)
Russian (ru)
Professor's Research (Professor Magnolia) (Russian)

File: [data/Sword & Shield/Sword & Shield/209.ts](https://github.com/tcgdex/cards-database/blob/2f21648376e7cd43ffe6f4ed9af11ee485cedfec/data/Sword & Shield/Sword & Shield/209.ts)
Set: Sword & Shield
Rarity: Secret Rare

@thomas-bassett
Copy link
Copy Markdown
Contributor

Hey, some of this maybe fixed without a big change to the compiler by using this: #1002
would just need to update the legality endpoint to check for reprint links

@kvacquier
Copy link
Copy Markdown
Contributor Author

The change is not that big and does not really impact performances, where it's more reliable for the way the card reprint legality works (based on English name only)

@thomas-bassett
Copy link
Copy Markdown
Contributor

thomas-bassett commented Nov 21, 2025

It was more that this requires a strict ordering of compilation which might be risky long term as it's possible someone could also change something about the compiler which changes the order unaware that this needed it.

Thus getting incorrect legality. Is there a way this can be guaranteed without the strict compilation?

@kvacquier
Copy link
Copy Markdown
Contributor Author

| Thus getting incorrect legality. Is there a way this can be guaranteed without the strict compilation?
Would be complicated, since the rule is purely based on if there's a card with the same English name currently legal (on trainer card list), so we need to check check that and I did not find a more efficient way than doing this in that order : a hard request make the compilation way slower, generating updated legal .ts would over-complex CI and would be really hard on rotations (where the current way fix that)

@thomas-bassett
Copy link
Copy Markdown
Contributor

Yeah I see what you mean. It's a difficult one. I've not looked at it enough to truly understand the flow. I just know from experience relying on an unchecked order of operations is not a good idea. Could this be computed at run time instead? With a legality endpoint?

@thomas-bassett
Copy link
Copy Markdown
Contributor

I do realise that even the endpoint isn't a good solution

@thomas-bassett
Copy link
Copy Markdown
Contributor

Could we change this to run after compilation. its a bit of a bigger compiler change but i believe it will set a better precedent and also be helpful for future changes.

So allow the compile to run normally. before writing to the json add in a step to go through all of the cards for that language and do the legality checks. edit the legality info on the card then pass through to save the json like normal. This should give us the enhanced legality and the safety that we are not relying on a compilation order?

Hows that sound?

@kvacquier kvacquier force-pushed the feat/trainer-legality-reprints-and-subnames branch 2 times, most recently from e169352 to 0cf2990 Compare December 4, 2025 23:47
@kvacquier kvacquier force-pushed the feat/trainer-legality-reprints-and-subnames branch from 0cf2990 to 401a348 Compare December 4, 2025 23:48
@kvacquier
Copy link
Copy Markdown
Contributor Author

Could we change this to run after compilation. its a bit of a bigger compiler change but i believe it will set a better precedent and also be helpful for future changes.

So allow the compile to run normally. before writing to the json add in a step to go through all of the cards for that language and do the legality checks. edit the legality info on the card then pass through to save the json like normal. This should give us the enhanced legality and the safety that we are not relying on a compilation order?

Hows that sound?

I've applied your feedback

@thomas-bassett
Copy link
Copy Markdown
Contributor

Looks good, at the moment we are only using the en name this wouldnt work for anything in the data-asia folder as that wouldnt have en in the card data

@kvacquier
Copy link
Copy Markdown
Contributor Author

Looks good, at the moment we are only using the en name this wouldnt work for anything in the data-asia folder as that wouldnt have en in the card data

AFAIK, in asia, each country as it's own format, legality and rules about reprint (at leasts there's rules for specific, Japan, China and Korea that are different...), so we can not do it the same way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants