@pkmn/data 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,7 +90,7 @@ import {Generations} from '@pkmn/data';
90
90
 
91
91
  const gens = new Generations(Dex);
92
92
  assert(gens.get(1).types.get('Ghost').effectiveness['Psychic'] === 0);
93
- assert(gens.get(8).types.totalEffectiveness('Dark', ['Ghost', 'Psychic']) === 4);
93
+ assert(gens.get(9).types.totalEffectiveness('Dark', ['Ghost', 'Psychic']) === 4);
94
94
  assert(gens.get(5).species.get('Dragapult') === undefined);
95
95
  assert(gens.get(3).species.get('Chansey').prevo === undefined);
96
96
  assert(Array.from(gens.get(1).species).length === 151);
@@ -118,9 +118,9 @@ release. This can be accomplished by passing an `ExistsFn` implementation as the
118
118
  the `Generations` constructor:
119
119
 
120
120
  ```ts
121
- // These species are unobtainable outside of their own generations, but this data gets lost in the
122
- // Pokémon Showdown data files because isNonstandard is a scalar value and isNonstandard = 'Past'
123
- // overwrites the isNonstandard = 'Unobtainable' designation
121
+ // These species are unobtainable outside of their own generations, but @pkmn/dex doesn't contain
122
+ // the artificial 'natDexTier' field which allows Pokémon Showdown to track this so we harcode it.
123
+ // If using @pkmn/sim instead, this list can be replaced with a `d.natDexTier !== 'Illegal'` check.
124
124
  const NATDEX_UNOBTAINABLE_SPECIES = [
125
125
  'Eevee-Starter', 'Floette-Eternal', 'Pichu-Spiky-eared', 'Pikachu-Belle', 'Pikachu-Cosplay',
126
126
  'Pikachu-Libre', 'Pikachu-PhD', 'Pikachu-Pop-Star', 'Pikachu-Rock-Star', 'Pikachu-Starter',
@@ -128,14 +128,14 @@ const NATDEX_UNOBTAINABLE_SPECIES = [
128
128
  ];
129
129
 
130
130
  const NATDEX_EXISTS = (d: Data, g: GenerationNum) => {
131
- // The "National Dex" rules only apply to gen 8, but this ExistsFn gets called on all generations
132
- if (g !== 8) return Generations.DEFAULT_EXISTS(d, g);
131
+ // The "National Dex" rules only apply to gen 8+, but this ExistsFn gets called on all generations
132
+ if (g < 8) return Generations.DEFAULT_EXISTS(d, g);
133
133
  // These checks remain unchanged from the default existence filter
134
134
  if (!d.exists) return false;
135
135
  if (d.kind === 'Ability' && d.id === 'noability') return false;
136
136
  // "National Dex" rules allows for data from the past, but not other forms of nonstandard-ness
137
137
  if ('isNonstandard' in d && d.isNonstandard && d.isNonstandard !== 'Past') return false;
138
- // Unlike the check in the default existence function we don't want to filter out the 'Illegal' tier
138
+ // Unlike the check in the default existence function we don't want to filter the 'Illegal' tier
139
139
  if ('tier' in d && d.tier === 'Unreleased') return false;
140
140
  // Filter out the unobtainable species
141
141
  if (d.kind === 'Species' && NATDEX_UNOBTAINABLE_SPECIES.includes(d.name)) return false;
@@ -180,10 +180,10 @@ typechecking, but in the case of `@pkmn/data` the wrapper is required as `Genera
180
180
  The recommended way of using `@pkmn/data` in a web browser is to **configure your bundler**
181
181
  ([Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/),
182
182
  [Parcel](https://parceljs.org/), etc) to minimize it and package it with the rest of your
183
- application. If you do not use a bundler, a convenience `production.min.js` is included in the
184
- package. You simply need to depend on `./node_modules/@pkmn/data/build/production.min.js` in a
185
- `script` tag (which is what the unpkg shortcut above is doing), after which **`Generations` will be
186
- accessible as a global.**
183
+ application. If you do not use a bundler, a convenience `index.min.js` is included in the package.
184
+ You simply need to depend on `./node_modules/@pkmn/data/build/index.min.js` in a `script` tag (which
185
+ is what the unpkg shortcut above is doing), after which **`pkmn.data` will be accessible as a
186
+ global.**
187
187
 
188
188
  ## Limitations
189
189
 
package/build/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { AbilityName, Condition, Data, Dex, EggGroup, EvoType, FormeName, GenderName, GenerationNum, ID, ItemName, Move, MoveCategory, MoveName, MoveSource, Nature, Nonstandard, Species as DexSpecies, SpeciesAbility, SpeciesName, SpeciesTag, StatID, StatsTable, Tier, Type as DexType, TypeName } from '@pkmn/dex-types';
2
- export declare type ExistsFn = (d: Data, g: GenerationNum) => boolean;
3
- declare type BoundExistsFn = (d: Data) => boolean;
4
- export declare function toID(text: any): ID;
5
- export declare class Generations {
1
+ import * as _pkmn_dex_types from '@pkmn/dex-types';
2
+ import { Data, GenerationNum, ID, Dex, Move, Species as Species$1, SpeciesName, Nonstandard, StatsTable, FormeName, SpeciesAbility, AbilityName, TypeName, EggGroup, SpeciesTag, Tier, MoveName, ItemName, GenderName, EvoType, Condition, Nature, MoveCategory, Type as Type$1, MoveSource, StatID } from '@pkmn/dex-types';
3
+ export { Ability, AbilityData, AbilityName, As, BasicEffect, BoostID, BoostsTable, Condition, ConditionData, Data, DataKind, Dex, Effect, EffectData, EffectType, EggGroup, EventInfo, EventInfoData, EvoType, FieldCondition, FormeName, GameType, GenID, GenderName, GenerationNum, HPColor, HPTypeName, HitEffect, ID, Item, ItemData, ItemName, Learnset, LearnsetData, Move, MoveCategory, MoveData, MoveName, MoveSource, MoveTarget, Nature, NatureData, NatureName, Nonstandard, Player, PokemonSet, SecondaryEffect, SideCondition, SideID, SpeciesData, SpeciesName, StatID, StatsTable, StatusName, Tier, TypeData, TypeName, Weather } from '@pkmn/dex-types';
4
+
5
+ type ExistsFn = (d: Data, g: GenerationNum) => boolean;
6
+ type BoundExistsFn = (d: Data) => boolean;
7
+ declare function toID(text: any): ID;
8
+ declare class Generations {
6
9
  private readonly cache;
7
10
  private readonly dex;
8
11
  private readonly exists;
@@ -11,7 +14,7 @@ export declare class Generations {
11
14
  get(g: string | number): Generation;
12
15
  [Symbol.iterator](): Generator<Generation, void, unknown>;
13
16
  }
14
- export declare class Generation {
17
+ declare class Generation {
15
18
  readonly abilities: Abilities;
16
19
  readonly items: Items;
17
20
  readonly moves: Moves;
@@ -29,28 +32,28 @@ export declare class Generation {
29
32
  toString(): string;
30
33
  toJSON(): string;
31
34
  }
32
- export declare class Abilities {
35
+ declare class Abilities {
33
36
  private readonly dex;
34
37
  private readonly exists;
35
38
  constructor(dex: Dex, exists: BoundExistsFn);
36
- get(name: string): import("@pkmn/dex-types").Ability | undefined;
37
- [Symbol.iterator](): Generator<import("@pkmn/dex-types").Ability, void, unknown>;
39
+ get(name: string): _pkmn_dex_types.Ability | undefined;
40
+ [Symbol.iterator](): Generator<_pkmn_dex_types.Ability, void, unknown>;
38
41
  }
39
- export declare class Items {
42
+ declare class Items {
40
43
  private readonly dex;
41
44
  private readonly exists;
42
45
  constructor(dex: Dex, exists: BoundExistsFn);
43
- get(name: string): import("@pkmn/dex-types").Item | undefined;
44
- [Symbol.iterator](): Generator<import("@pkmn/dex-types").Item, void, unknown>;
46
+ get(name: string): _pkmn_dex_types.Item | undefined;
47
+ [Symbol.iterator](): Generator<_pkmn_dex_types.Item, void, unknown>;
45
48
  }
46
- export declare class Moves {
49
+ declare class Moves {
47
50
  private readonly dex;
48
51
  private readonly exists;
49
52
  constructor(dex: Dex, exists: BoundExistsFn);
50
53
  get(name: string): Move | undefined;
51
54
  [Symbol.iterator](): Generator<Move, void, unknown>;
52
55
  }
53
- export declare class Species {
56
+ declare class Species {
54
57
  private readonly cache;
55
58
  private readonly dex;
56
59
  private readonly exists;
@@ -58,7 +61,7 @@ export declare class Species {
58
61
  get(name: string): Specie | undefined;
59
62
  [Symbol.iterator](): Generator<Specie, void, unknown>;
60
63
  }
61
- export declare class Specie implements DexSpecies {
64
+ declare class Specie implements Species$1 {
62
65
  readonly id: ID;
63
66
  readonly name: SpeciesName;
64
67
  readonly fullname: string;
@@ -120,32 +123,32 @@ export declare class Specie implements DexSpecies {
120
123
  readonly canHatch: boolean;
121
124
  private readonly dex;
122
125
  private static readonly EXCLUDE;
123
- constructor(dex: Dex, exists: BoundExistsFn, species: DexSpecies);
126
+ constructor(dex: Dex, exists: BoundExistsFn, species: Species$1);
124
127
  get formeNum(): number;
125
128
  toString(): SpeciesName;
126
129
  toJSON(): {
127
130
  [key: string]: any;
128
131
  };
129
132
  }
130
- export declare class Conditions {
133
+ declare class Conditions {
131
134
  private readonly dex;
132
135
  private readonly exists;
133
136
  constructor(dex: Dex, exists: BoundExistsFn);
134
137
  get(name: string): Condition | undefined;
135
138
  }
136
- export declare class Natures {
139
+ declare class Natures {
137
140
  private readonly dex;
138
141
  private readonly exists;
139
142
  constructor(dex: Dex, exists: BoundExistsFn);
140
143
  get(name: string): Nature | undefined;
141
144
  [Symbol.iterator](): Generator<Nature, void, unknown>;
142
145
  }
143
- declare type TypeTarget = {
146
+ type TypeTarget = {
144
147
  getTypes: () => TypeName[];
145
148
  } | {
146
149
  types: TypeName[];
147
150
  } | TypeName[] | TypeName;
148
- export declare class Types {
151
+ declare class Types {
149
152
  private readonly cache;
150
153
  private readonly unknown;
151
154
  private readonly dex;
@@ -164,8 +167,8 @@ export declare class Types {
164
167
  type: TypeName;
165
168
  } | TypeName, target: TypeTarget): number;
166
169
  }
167
- export declare type TypeEffectiveness = 0 | 0.5 | 1 | 2;
168
- export declare class Type {
170
+ type TypeEffectiveness = 0 | 0.5 | 1 | 2;
171
+ declare class Type {
169
172
  readonly id: ID;
170
173
  readonly name: TypeName;
171
174
  readonly effectType: 'Type';
@@ -179,7 +182,7 @@ export declare class Type {
179
182
  readonly HPdvs: Partial<StatsTable>;
180
183
  readonly category?: Exclude<MoveCategory, 'Status'>;
181
184
  private readonly types;
182
- constructor(type: DexType, dex: Dex, types: Types);
185
+ constructor(type: Type$1, dex: Dex, types: Types);
183
186
  canDamage(target: TypeTarget): boolean;
184
187
  totalEffectiveness(target: TypeTarget): number;
185
188
  toString(): TypeName;
@@ -187,23 +190,23 @@ export declare class Type {
187
190
  [key: string]: any;
188
191
  };
189
192
  }
190
- declare type Restriction = 'Pentagon' | 'Plus' | 'Galar';
191
- export declare class Learnsets {
193
+ type Restriction = 'Pentagon' | 'Plus' | 'Galar' | 'Paldea';
194
+ declare class Learnsets {
192
195
  private readonly cache;
193
196
  private readonly gen;
194
197
  private readonly dex;
195
198
  private readonly exists;
196
199
  constructor(gen: Generation, dex: Dex, exists: BoundExistsFn);
197
- get(name: string): Promise<import("@pkmn/dex-types").Learnset | undefined>;
198
- [Symbol.iterator](): AsyncGenerator<import("@pkmn/dex-types").Learnset, void, unknown>;
199
- all(species: Specie): AsyncGenerator<import("@pkmn/dex-types").Learnset, void, unknown>;
200
+ get(name: string): Promise<_pkmn_dex_types.Learnset | undefined>;
201
+ [Symbol.iterator](): AsyncGenerator<_pkmn_dex_types.Learnset, void, unknown>;
202
+ all(species: Specie): AsyncGenerator<_pkmn_dex_types.Learnset, void, unknown>;
200
203
  learnable(name: string, restriction?: Restriction): Promise<{
201
204
  [moveid: string]: string[];
202
205
  } | undefined>;
203
206
  canLearn(name: string, move: Move | string, restriction?: Restriction): Promise<boolean>;
204
207
  isLegal(move: Move, sources: MoveSource[] | undefined, gen: Generation | Restriction): boolean | undefined;
205
208
  }
206
- export declare class Stats {
209
+ declare class Stats {
207
210
  private readonly dex;
208
211
  constructor(dex: Dex);
209
212
  calc(stat: StatID, base: number, iv?: number, ev?: number, level?: number, nature?: Nature): number;
@@ -215,4 +218,5 @@ export declare class Stats {
215
218
  toDV(iv: number): number;
216
219
  toIV(dv: number): number;
217
220
  }
218
- export { ID, As, Weather, FieldCondition, SideCondition, GenerationNum, GenderName, StatID, StatsTable, BoostID, BoostsTable, MoveCategory, MoveTarget, Nonstandard, EvoType, EggGroup, SideID, Player, GameType, HPColor, StatusName, NatureName, TypeName, HPTypeName, Tier, PokemonSet, AbilityName, ItemName, MoveName, SpeciesName, FormeName, EffectType, Effect, DataKind, Data, EffectData, HitEffect, SecondaryEffect, ConditionData, AbilityData, ItemData, MoveData, SpeciesData, MoveSource, EventInfoData, LearnsetData, TypeData, NatureData, BasicEffect, Condition, Ability, Item, Move, EventInfo, Learnset, Nature, GenID, Dex, } from '@pkmn/dex-types';
221
+
222
+ export { Abilities, Conditions, ExistsFn, Generation, Generations, Items, Learnsets, Moves, Natures, Specie, Species, Stats, Type, TypeEffectiveness, Types, toID };