@pkmn/data 0.6.3 → 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 +11 -11
- package/build/index.d.ts +37 -32
- package/build/index.js +568 -633
- package/build/index.js.map +1 -1
- package/build/index.min.js +1 -0
- package/build/index.mjs +582 -0
- package/build/index.mjs.map +1 -0
- package/package.json +13 -14
- package/build/production.min.js +0 -1
- package/build/production.min.js.map +0 -7
- package/build/production.min.js.old +0 -1
- package/index.ts +0 -841
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(
|
|
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
|
|
122
|
-
//
|
|
123
|
-
//
|
|
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
|
|
132
|
-
if (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
|
|
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 `
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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):
|
|
37
|
-
[Symbol.iterator](): Generator<
|
|
39
|
+
get(name: string): _pkmn_dex_types.Ability | undefined;
|
|
40
|
+
[Symbol.iterator](): Generator<_pkmn_dex_types.Ability, void, unknown>;
|
|
38
41
|
}
|
|
39
|
-
|
|
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):
|
|
44
|
-
[Symbol.iterator](): Generator<
|
|
46
|
+
get(name: string): _pkmn_dex_types.Item | undefined;
|
|
47
|
+
[Symbol.iterator](): Generator<_pkmn_dex_types.Item, void, unknown>;
|
|
45
48
|
}
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
64
|
+
declare class Specie implements Species$1 {
|
|
62
65
|
readonly id: ID;
|
|
63
66
|
readonly name: SpeciesName;
|
|
64
67
|
readonly fullname: string;
|
|
@@ -89,7 +92,6 @@ export declare class Specie implements DexSpecies {
|
|
|
89
92
|
readonly inheritsFrom: ID;
|
|
90
93
|
readonly tier: Tier.Singles | Tier.Other;
|
|
91
94
|
readonly doublesTier: Tier.Doubles;
|
|
92
|
-
readonly evoMove?: MoveName;
|
|
93
95
|
readonly changesFrom?: SpeciesName;
|
|
94
96
|
readonly cosmeticFormes?: SpeciesName[];
|
|
95
97
|
readonly otherFormes?: SpeciesName[];
|
|
@@ -111,40 +113,42 @@ export declare class Specie implements DexSpecies {
|
|
|
111
113
|
readonly requiredMove?: MoveName;
|
|
112
114
|
readonly gender?: GenderName;
|
|
113
115
|
readonly maxHP?: number;
|
|
116
|
+
readonly evoMove?: MoveName;
|
|
117
|
+
readonly evoItem?: string;
|
|
118
|
+
readonly evoRegion?: 'Alola' | 'Galar';
|
|
114
119
|
readonly evoLevel?: number;
|
|
115
120
|
readonly evoCondition?: string;
|
|
116
|
-
readonly evoItem?: string;
|
|
117
121
|
readonly evoType?: EvoType;
|
|
118
122
|
readonly condition?: Partial<Condition>;
|
|
119
123
|
readonly canHatch: boolean;
|
|
120
124
|
private readonly dex;
|
|
121
125
|
private static readonly EXCLUDE;
|
|
122
|
-
constructor(dex: Dex, exists: BoundExistsFn, species:
|
|
126
|
+
constructor(dex: Dex, exists: BoundExistsFn, species: Species$1);
|
|
123
127
|
get formeNum(): number;
|
|
124
128
|
toString(): SpeciesName;
|
|
125
129
|
toJSON(): {
|
|
126
130
|
[key: string]: any;
|
|
127
131
|
};
|
|
128
132
|
}
|
|
129
|
-
|
|
133
|
+
declare class Conditions {
|
|
130
134
|
private readonly dex;
|
|
131
135
|
private readonly exists;
|
|
132
136
|
constructor(dex: Dex, exists: BoundExistsFn);
|
|
133
137
|
get(name: string): Condition | undefined;
|
|
134
138
|
}
|
|
135
|
-
|
|
139
|
+
declare class Natures {
|
|
136
140
|
private readonly dex;
|
|
137
141
|
private readonly exists;
|
|
138
142
|
constructor(dex: Dex, exists: BoundExistsFn);
|
|
139
143
|
get(name: string): Nature | undefined;
|
|
140
144
|
[Symbol.iterator](): Generator<Nature, void, unknown>;
|
|
141
145
|
}
|
|
142
|
-
|
|
146
|
+
type TypeTarget = {
|
|
143
147
|
getTypes: () => TypeName[];
|
|
144
148
|
} | {
|
|
145
149
|
types: TypeName[];
|
|
146
150
|
} | TypeName[] | TypeName;
|
|
147
|
-
|
|
151
|
+
declare class Types {
|
|
148
152
|
private readonly cache;
|
|
149
153
|
private readonly unknown;
|
|
150
154
|
private readonly dex;
|
|
@@ -163,8 +167,8 @@ export declare class Types {
|
|
|
163
167
|
type: TypeName;
|
|
164
168
|
} | TypeName, target: TypeTarget): number;
|
|
165
169
|
}
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
type TypeEffectiveness = 0 | 0.5 | 1 | 2;
|
|
171
|
+
declare class Type {
|
|
168
172
|
readonly id: ID;
|
|
169
173
|
readonly name: TypeName;
|
|
170
174
|
readonly effectType: 'Type';
|
|
@@ -178,7 +182,7 @@ export declare class Type {
|
|
|
178
182
|
readonly HPdvs: Partial<StatsTable>;
|
|
179
183
|
readonly category?: Exclude<MoveCategory, 'Status'>;
|
|
180
184
|
private readonly types;
|
|
181
|
-
constructor(type:
|
|
185
|
+
constructor(type: Type$1, dex: Dex, types: Types);
|
|
182
186
|
canDamage(target: TypeTarget): boolean;
|
|
183
187
|
totalEffectiveness(target: TypeTarget): number;
|
|
184
188
|
toString(): TypeName;
|
|
@@ -186,23 +190,23 @@ export declare class Type {
|
|
|
186
190
|
[key: string]: any;
|
|
187
191
|
};
|
|
188
192
|
}
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
type Restriction = 'Pentagon' | 'Plus' | 'Galar' | 'Paldea';
|
|
194
|
+
declare class Learnsets {
|
|
191
195
|
private readonly cache;
|
|
192
196
|
private readonly gen;
|
|
193
197
|
private readonly dex;
|
|
194
198
|
private readonly exists;
|
|
195
199
|
constructor(gen: Generation, dex: Dex, exists: BoundExistsFn);
|
|
196
|
-
get(name: string): Promise<
|
|
197
|
-
[Symbol.iterator](): AsyncGenerator<
|
|
198
|
-
all(species: Specie): AsyncGenerator<
|
|
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>;
|
|
199
203
|
learnable(name: string, restriction?: Restriction): Promise<{
|
|
200
204
|
[moveid: string]: string[];
|
|
201
205
|
} | undefined>;
|
|
202
206
|
canLearn(name: string, move: Move | string, restriction?: Restriction): Promise<boolean>;
|
|
203
207
|
isLegal(move: Move, sources: MoveSource[] | undefined, gen: Generation | Restriction): boolean | undefined;
|
|
204
208
|
}
|
|
205
|
-
|
|
209
|
+
declare class Stats {
|
|
206
210
|
private readonly dex;
|
|
207
211
|
constructor(dex: Dex);
|
|
208
212
|
calc(stat: StatID, base: number, iv?: number, ev?: number, level?: number, nature?: Nature): number;
|
|
@@ -214,4 +218,5 @@ export declare class Stats {
|
|
|
214
218
|
toDV(iv: number): number;
|
|
215
219
|
toIV(dv: number): number;
|
|
216
220
|
}
|
|
217
|
-
|
|
221
|
+
|
|
222
|
+
export { Abilities, Conditions, ExistsFn, Generation, Generations, Items, Learnsets, Moves, Natures, Specie, Species, Stats, Type, TypeEffectiveness, Types, toID };
|