Skip to content

Improve mod creation - #48

Open
lonevox wants to merge 1 commit into
pkmn:mainfrom
lonevox:improve-moddata-type
Open

Improve mod creation#48
lonevox wants to merge 1 commit into
pkmn:mainfrom
lonevox:improve-moddata-type

Conversation

@lonevox

@lonevox lonevox commented Jul 29, 2026

Copy link
Copy Markdown

This improves mod creation by adding an optional FormatList to the ModData type. Currently, since the FormatList type isn't exported, I'm having to create a ModDefinition type from the second parameter of the Dex.mod function, like this:

import { Dex } from '@pkmn/sim';

type ModDefinition = NonNullable<Parameters<typeof Dex.mod>[1]>;

const baseFormat = Dex.formats.get("gen9customgame");
export const PKMN_MOD_DATA: ModDefinition = {
  Scripts: {
    inherit: baseFormat.mod,
    gen: 9,
  },
  Formats: [
    {
      name: "PKMN GD",
      mod: PKMN_MOD_ID,
      gameType: baseFormat.gameType,
      debug: baseFormat.debug,
      rated: false,
      ruleset: [baseFormat.name],
    },
  ],
};

export const PKMN_SIM_DEX = Dex.mod(PKMN_MOD_ID, PKMN_MOD_DATA);

This is not nice. The type change in this PR allows us to pass the ModData type as the second parameter in Dex.mod, which makes the code simpler:

import { Dex, type ModData } from '@pkmn/sim';

const baseFormat = Dex.formats.get("gen9customgame");
export const PKMN_MOD_DATA = {
  Scripts: {
    inherit: baseFormat.mod,
    gen: 9,
  },
  Formats: [
    {
      name: "PKMN GD",
      mod: PKMN_MOD_ID,
      gameType: baseFormat.gameType,
      debug: baseFormat.debug,
      rated: false,
      ruleset: [baseFormat.name],
    },
  ],
} satisfies ModData;

export const PKMN_SIM_DEX = Dex.mod(PKMN_MOD_ID, PKMN_MOD_DATA);

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant