pkmn / ps

Modular Pokémon Showdown
MIT License
107 stars 15 forks source link

@pkmn/sim: Running `Dex.formats.getRuleTable(Dex.formats.get('gen9lc'))` crashes #25

Closed thejetou closed 7 months ago

thejetou commented 11 months ago

Describe the bug:

Running Dex.formats.getRuleTable(Dex.formats.get('gen9lc')) crashes on @pkmn/sim:0.7.57 with the error:

Uncaught Error: Rule "-Stantler" in "[Gen 9] LC" already exists in "Little Cup"
    at DexFormats.getRuleTable (/home/jet/workspace/pkmnsimtest/node_modules/@pkmn/sim/build/cjs/sim/dex-formats.js:514:27)

Example:

import { Dex } from '@pkmn/sim'
Dex.includeFormats();
console.log(Dex.formats.getRuleTable(Dex.formats.get('gen9lc')));

Expected behavior:

Dex.formats.getRuleTable should have returned the rule table and not crashed.

Additional context:

Running the equivalent code on https://github.com/smogon/pokemon-showdown/commit/813f2efdc80d9b6b6f45f88eef6991d3b806f981 works as expected.

Discord conversation: https://discord.com/channels/689316505560809576/689316506265321535/1170051792818667621

scheibo commented 11 months ago

Per our conversation i think this might possibly be related to https://github.com/pkmn/ps/issues/21#issuecomment-1722582277 so I think I might have to solve them together. Will try to find some time to look into these Dex issues this month.

scheibo commented 7 months ago

Per convo on discord: we should move formats which depend on mods (eg. gen9vgc2023regd) out of @pkmn/sim's config/formats.ts and instead include them in @pkmn/mods. gen9lc doesn't crash because of this issue, but mod-dependent formats also crash so I figured I'd just address that in this same issue