@pkmn/data 0.9.7 → 0.9.9
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/build/index.d.mts +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +56 -107
- package/build/index.js.map +1 -1
- package/build/index.min.js +1 -1
- package/build/index.mjs +56 -107
- package/build/index.mjs.map +1 -1
- package/package.json +5 -5
package/build/index.d.mts
CHANGED
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
2
|
var DEFAULT_EXISTS = (d) => {
|
|
3
|
-
if (!d.exists)
|
|
4
|
-
|
|
5
|
-
if ("
|
|
6
|
-
return false;
|
|
7
|
-
if (d.kind === "Ability" && d.id === "noability")
|
|
8
|
-
return false;
|
|
3
|
+
if (!d.exists) return false;
|
|
4
|
+
if ("isNonstandard" in d && d.isNonstandard) return false;
|
|
5
|
+
if (d.kind === "Ability" && d.id === "noability") return false;
|
|
9
6
|
return !("tier" in d && ["Illegal", "Unreleased"].includes(d.tier));
|
|
10
7
|
};
|
|
11
8
|
var tr = (num, bits = 0) => bits ? (num >>> 0) % 2 ** bits : num >>> 0;
|
|
@@ -18,10 +15,8 @@ function assignWithout(a, b, exclude) {
|
|
|
18
15
|
return a;
|
|
19
16
|
}
|
|
20
17
|
function toID(text) {
|
|
21
|
-
if (text == null ? void 0 : text.id)
|
|
22
|
-
|
|
23
|
-
if (typeof text !== "string" && typeof text !== "number")
|
|
24
|
-
return "";
|
|
18
|
+
if (text == null ? void 0 : text.id) text = text.id;
|
|
19
|
+
if (typeof text !== "string" && typeof text !== "number") return "";
|
|
25
20
|
return ("" + text).toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
26
21
|
}
|
|
27
22
|
var _Generations = class _Generations {
|
|
@@ -33,10 +28,8 @@ var _Generations = class _Generations {
|
|
|
33
28
|
}
|
|
34
29
|
get(g) {
|
|
35
30
|
const gen = typeof g === "string" ? parseInt(g.slice(g.search(/\d/))) : g;
|
|
36
|
-
if (isNaN(+gen))
|
|
37
|
-
|
|
38
|
-
if (this.cache[gen])
|
|
39
|
-
return this.cache[gen];
|
|
31
|
+
if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);
|
|
32
|
+
if (this.cache[gen]) return this.cache[gen];
|
|
40
33
|
return this.cache[gen] = new Generation(this.dex.forGen(gen), (d) => this.exists(d, gen));
|
|
41
34
|
}
|
|
42
35
|
*[Symbol.iterator]() {
|
|
@@ -86,8 +79,7 @@ var Abilities = class {
|
|
|
86
79
|
*[Symbol.iterator]() {
|
|
87
80
|
for (const ability in this.dex.data.Abilities) {
|
|
88
81
|
const a = this.get(ability);
|
|
89
|
-
if (a)
|
|
90
|
-
yield a;
|
|
82
|
+
if (a) yield a;
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
};
|
|
@@ -103,8 +95,7 @@ var Items = class {
|
|
|
103
95
|
*[Symbol.iterator]() {
|
|
104
96
|
for (const item in this.dex.data.Items) {
|
|
105
97
|
const i = this.get(item);
|
|
106
|
-
if (i)
|
|
107
|
-
yield i;
|
|
98
|
+
if (i) yield i;
|
|
108
99
|
}
|
|
109
100
|
}
|
|
110
101
|
};
|
|
@@ -120,8 +111,7 @@ var Moves = class {
|
|
|
120
111
|
*[Symbol.iterator]() {
|
|
121
112
|
for (const move in this.dex.data.Moves) {
|
|
122
113
|
const m = this.get(move);
|
|
123
|
-
if (m)
|
|
124
|
-
yield m;
|
|
114
|
+
if (m) yield m;
|
|
125
115
|
}
|
|
126
116
|
}
|
|
127
117
|
};
|
|
@@ -134,19 +124,16 @@ var Species = class {
|
|
|
134
124
|
}
|
|
135
125
|
get(name) {
|
|
136
126
|
const species = this.dex.species.get(name);
|
|
137
|
-
if (!this.exists(species))
|
|
138
|
-
return void 0;
|
|
127
|
+
if (!this.exists(species)) return void 0;
|
|
139
128
|
const id = species.speciesid || species.id;
|
|
140
129
|
const cached = this.cache[id];
|
|
141
|
-
if (cached)
|
|
142
|
-
return cached;
|
|
130
|
+
if (cached) return cached;
|
|
143
131
|
return this.cache[id] = new Specie(this.dex, this.exists, species);
|
|
144
132
|
}
|
|
145
133
|
*[Symbol.iterator]() {
|
|
146
134
|
for (const species in this.dex.data.Species) {
|
|
147
135
|
const s = this.get(species);
|
|
148
|
-
if (s)
|
|
149
|
-
yield s;
|
|
136
|
+
if (s) yield s;
|
|
150
137
|
}
|
|
151
138
|
}
|
|
152
139
|
};
|
|
@@ -166,26 +153,20 @@ var _Specie = class _Specie {
|
|
|
166
153
|
if (species.abilities[1] && this.dex.abilities.get(species.abilities[1]).gen <= this.dex.gen) {
|
|
167
154
|
this.abilities[1] = species.abilities[1];
|
|
168
155
|
}
|
|
169
|
-
if (this.dex.gen >= 5 && species.abilities.H)
|
|
170
|
-
|
|
171
|
-
if (this.dex.gen >= 7 && species.abilities.S)
|
|
172
|
-
this.abilities.S = species.abilities.S;
|
|
156
|
+
if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;
|
|
157
|
+
if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;
|
|
173
158
|
} else {
|
|
174
159
|
this.abilities = { 0: "" };
|
|
175
160
|
}
|
|
176
161
|
this.evos = (_a = species.evos) == null ? void 0 : _a.filter((s) => exists(this.dex.species.get(s)));
|
|
177
162
|
this.nfe = !!((_b = this.evos) == null ? void 0 : _b.length);
|
|
178
|
-
if (!this.nfe)
|
|
179
|
-
this.evos = void 0;
|
|
163
|
+
if (!this.nfe) this.evos = void 0;
|
|
180
164
|
this.cosmeticFormes = (_c = species.cosmeticFormes) == null ? void 0 : _c.filter((s) => exists(this.dex.species.get(s)));
|
|
181
|
-
if (!((_d = this.cosmeticFormes) == null ? void 0 : _d.length))
|
|
182
|
-
this.cosmeticFormes = void 0;
|
|
165
|
+
if (!((_d = this.cosmeticFormes) == null ? void 0 : _d.length)) this.cosmeticFormes = void 0;
|
|
183
166
|
this.otherFormes = (_e = species.otherFormes) == null ? void 0 : _e.filter((s) => exists(this.dex.species.get(s)));
|
|
184
|
-
if (!((_f = this.otherFormes) == null ? void 0 : _f.length))
|
|
185
|
-
this.otherFormes = void 0;
|
|
167
|
+
if (!((_f = this.otherFormes) == null ? void 0 : _f.length)) this.otherFormes = void 0;
|
|
186
168
|
this.formeOrder = (_g = species.formeOrder) == null ? void 0 : _g.filter((s) => exists(this.dex.species.get(s)));
|
|
187
|
-
if (!this.formeOrder || this.formeOrder.length <= 1)
|
|
188
|
-
this.formeOrder = void 0;
|
|
169
|
+
if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = void 0;
|
|
189
170
|
this.formes = (_h = this.formeOrder) == null ? void 0 : _h.filter((s) => this.dex.species.get(s).isNonstandard !== "Gigantamax");
|
|
190
171
|
this.prevo = species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : void 0;
|
|
191
172
|
}
|
|
@@ -230,16 +211,14 @@ var Natures = class {
|
|
|
230
211
|
this.exists = exists;
|
|
231
212
|
}
|
|
232
213
|
get(name) {
|
|
233
|
-
if (this.dex.gen < 3)
|
|
234
|
-
return void 0;
|
|
214
|
+
if (this.dex.gen < 3) return void 0;
|
|
235
215
|
const nature = this.dex.natures.get(name);
|
|
236
216
|
return this.exists(nature) ? nature : void 0;
|
|
237
217
|
}
|
|
238
218
|
*[Symbol.iterator]() {
|
|
239
219
|
for (const nature in this.dex.data.Natures) {
|
|
240
220
|
const n = this.get(nature);
|
|
241
|
-
if (n)
|
|
242
|
-
yield n;
|
|
221
|
+
if (n) yield n;
|
|
243
222
|
}
|
|
244
223
|
}
|
|
245
224
|
};
|
|
@@ -275,21 +254,17 @@ var Types = class {
|
|
|
275
254
|
}, dex, this);
|
|
276
255
|
}
|
|
277
256
|
get(name) {
|
|
278
|
-
if (name === "???")
|
|
279
|
-
return this.unknown;
|
|
257
|
+
if (name === "???") return this.unknown;
|
|
280
258
|
const type = this.dex.types.get(name);
|
|
281
|
-
if (!this.exists(type))
|
|
282
|
-
return void 0;
|
|
259
|
+
if (!this.exists(type)) return void 0;
|
|
283
260
|
const cached = this.cache[type.id];
|
|
284
|
-
if (cached)
|
|
285
|
-
return cached;
|
|
261
|
+
if (cached) return cached;
|
|
286
262
|
return this.cache[type.id] = new Type(type, this.dex, this);
|
|
287
263
|
}
|
|
288
264
|
*[Symbol.iterator]() {
|
|
289
265
|
for (const type in this.dex.data.Types) {
|
|
290
266
|
const t = this.get(type);
|
|
291
|
-
if (t)
|
|
292
|
-
yield t;
|
|
267
|
+
if (t) yield t;
|
|
293
268
|
}
|
|
294
269
|
if (this.dex.gen >= 2 && this.dex.gen <= 4) {
|
|
295
270
|
yield this.unknown;
|
|
@@ -302,8 +277,7 @@ var Types = class {
|
|
|
302
277
|
return this.dex.getImmunity(source, target);
|
|
303
278
|
}
|
|
304
279
|
totalEffectiveness(source, target) {
|
|
305
|
-
if (!this.canDamage(source, target))
|
|
306
|
-
return 0;
|
|
280
|
+
if (!this.canDamage(source, target)) return 0;
|
|
307
281
|
const e = `${this.dex.getEffectiveness(source, target)}`;
|
|
308
282
|
return EFFECTIVENESS[e];
|
|
309
283
|
}
|
|
@@ -318,7 +292,8 @@ var Type = class {
|
|
|
318
292
|
this.effectiveness = { "???": 1 };
|
|
319
293
|
for (const k in dex.data.Types) {
|
|
320
294
|
const t = k.charAt(0).toUpperCase() + k.slice(1);
|
|
321
|
-
|
|
295
|
+
const data = dex.data.Types[k];
|
|
296
|
+
this.effectiveness[t] = DAMAGE_TAKEN[data.damageTaken[this.name] || 0];
|
|
322
297
|
}
|
|
323
298
|
}
|
|
324
299
|
canDamage(target) {
|
|
@@ -349,12 +324,10 @@ var Learnsets = class {
|
|
|
349
324
|
return this.exists(learnset) ? learnset : void 0;
|
|
350
325
|
}
|
|
351
326
|
async *[Symbol.iterator]() {
|
|
352
|
-
if (!this.dex.data.Learnsets)
|
|
353
|
-
await this.dex.learnsets.get("LOAD");
|
|
327
|
+
if (!this.dex.data.Learnsets) await this.dex.learnsets.get("LOAD");
|
|
354
328
|
for (const id in this.dex.data.Learnsets) {
|
|
355
329
|
const l = await this.get(id);
|
|
356
|
-
if (l)
|
|
357
|
-
yield l;
|
|
330
|
+
if (l) yield l;
|
|
358
331
|
}
|
|
359
332
|
}
|
|
360
333
|
async *all(species) {
|
|
@@ -375,11 +348,9 @@ var Learnsets = class {
|
|
|
375
348
|
} else {
|
|
376
349
|
id = toID(species.battleOnly || species.changesFrom || species.prevo);
|
|
377
350
|
}
|
|
378
|
-
if (!id)
|
|
379
|
-
break;
|
|
351
|
+
if (!id) break;
|
|
380
352
|
const s = this.gen.species.get(id);
|
|
381
|
-
if (!s)
|
|
382
|
-
break;
|
|
353
|
+
if (!s) break;
|
|
383
354
|
species = s;
|
|
384
355
|
learnset = await this.get(id);
|
|
385
356
|
}
|
|
@@ -388,12 +359,10 @@ var Learnsets = class {
|
|
|
388
359
|
// checks/restriction enforcement requires @pkmn/sim's TeamValidator.
|
|
389
360
|
async learnable(name, restriction) {
|
|
390
361
|
const species = this.gen.species.get(name);
|
|
391
|
-
if (!species)
|
|
392
|
-
return void 0;
|
|
362
|
+
if (!species) return void 0;
|
|
393
363
|
if (!restriction) {
|
|
394
364
|
const cached = this.cache[species.id];
|
|
395
|
-
if (cached)
|
|
396
|
-
return cached;
|
|
365
|
+
if (cached) return cached;
|
|
397
366
|
}
|
|
398
367
|
const moves = {};
|
|
399
368
|
for await (const learnset of this.all(species)) {
|
|
@@ -404,18 +373,14 @@ var Learnsets = class {
|
|
|
404
373
|
const sources = learnset.learnset[moveid];
|
|
405
374
|
if (this.isLegal(move, sources, restriction || this.gen)) {
|
|
406
375
|
const filtered = sources.filter((s) => +s.charAt(0) <= this.gen.num);
|
|
407
|
-
if (!filtered.length)
|
|
408
|
-
continue;
|
|
376
|
+
if (!filtered.length) continue;
|
|
409
377
|
if (moves[move.id]) {
|
|
410
378
|
const unique = [];
|
|
411
|
-
loop:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
continue loop;
|
|
417
|
-
unique.push(source);
|
|
418
|
-
}
|
|
379
|
+
loop: for (const source of filtered) {
|
|
380
|
+
const prefix = source.slice(0, 2);
|
|
381
|
+
for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;
|
|
382
|
+
unique.push(source);
|
|
383
|
+
}
|
|
419
384
|
moves[move.id].push(...unique);
|
|
420
385
|
} else {
|
|
421
386
|
moves[move.id] = filtered;
|
|
@@ -425,8 +390,7 @@ var Learnsets = class {
|
|
|
425
390
|
}
|
|
426
391
|
}
|
|
427
392
|
}
|
|
428
|
-
if (!restriction)
|
|
429
|
-
this.cache[species.id] = moves;
|
|
393
|
+
if (!restriction) this.cache[species.id] = moves;
|
|
430
394
|
return moves;
|
|
431
395
|
}
|
|
432
396
|
// BUG: this only covers what Pokémon Showdown deems "teambuilder legality" - proper legality
|
|
@@ -434,11 +398,9 @@ var Learnsets = class {
|
|
|
434
398
|
async canLearn(name, move, restriction) {
|
|
435
399
|
var _a;
|
|
436
400
|
const species = this.gen.species.get(name);
|
|
437
|
-
if (!species)
|
|
438
|
-
return false;
|
|
401
|
+
if (!species) return false;
|
|
439
402
|
move = typeof move === "string" && this.gen.moves.get(move) || move;
|
|
440
|
-
if (typeof move === "string")
|
|
441
|
-
return false;
|
|
403
|
+
if (typeof move === "string") return false;
|
|
442
404
|
for await (const learnset of this.all(species)) {
|
|
443
405
|
if (this.isLegal(move, (_a = learnset.learnset) == null ? void 0 : _a[move.id], restriction || this.gen)) {
|
|
444
406
|
return true;
|
|
@@ -449,19 +411,14 @@ var Learnsets = class {
|
|
|
449
411
|
// BUG: this only covers what Pokémon Showdown deems "teambuilder legality" - proper legality
|
|
450
412
|
// checks/restriction enforcement requires @pkmn/sim's TeamValidator.
|
|
451
413
|
isLegal(move, sources, gen) {
|
|
452
|
-
if (!sources)
|
|
453
|
-
return void 0;
|
|
414
|
+
if (!sources) return void 0;
|
|
454
415
|
const gens = sources.map((x) => Number(x[0]));
|
|
455
416
|
const minGen = Math.min(...gens);
|
|
456
417
|
const vcOnly = minGen === 7 && sources.every((x) => x[0] !== "7" || x === "7V") || minGen === 8 && sources.every((x) => x[0] !== "8" || x === "8V");
|
|
457
|
-
if (gen === "Pentagon")
|
|
458
|
-
|
|
459
|
-
if (gen === "
|
|
460
|
-
|
|
461
|
-
if (gen === "Galar")
|
|
462
|
-
return gens.includes(8) && !vcOnly;
|
|
463
|
-
if (gen === "Paldea")
|
|
464
|
-
return gens.includes(9);
|
|
418
|
+
if (gen === "Pentagon") return gens.includes(6);
|
|
419
|
+
if (gen === "Plus") return gens.includes(7) && !vcOnly;
|
|
420
|
+
if (gen === "Galar") return gens.includes(8) && !vcOnly;
|
|
421
|
+
if (gen === "Paldea") return gens.includes(9);
|
|
465
422
|
if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {
|
|
466
423
|
let legalGens = "";
|
|
467
424
|
let available = false;
|
|
@@ -469,14 +426,12 @@ var Learnsets = class {
|
|
|
469
426
|
legalGens += "3";
|
|
470
427
|
available = true;
|
|
471
428
|
}
|
|
472
|
-
if (available)
|
|
473
|
-
available = !GEN3_HMS.has(move.id);
|
|
429
|
+
if (available) available = !GEN3_HMS.has(move.id);
|
|
474
430
|
if (available || gens.includes(4)) {
|
|
475
431
|
legalGens += "4";
|
|
476
432
|
available = true;
|
|
477
433
|
}
|
|
478
|
-
if (available)
|
|
479
|
-
available = !GEN4_HMS.has(move.id);
|
|
434
|
+
if (available) available = !GEN4_HMS.has(move.id);
|
|
480
435
|
const minUpperGen = available ? 5 : Math.min(...gens.filter((g) => g > 4));
|
|
481
436
|
legalGens += "0123456789".slice(minUpperGen);
|
|
482
437
|
return legalGens.includes(`${gen.num}`);
|
|
@@ -527,8 +482,7 @@ var Stats = class {
|
|
|
527
482
|
this.dex = dex;
|
|
528
483
|
}
|
|
529
484
|
calc(stat, base, iv = 31, ev, level = 100, nature) {
|
|
530
|
-
if (ev === void 0)
|
|
531
|
-
ev = this.dex.gen < 3 ? 252 : 0;
|
|
485
|
+
if (ev === void 0) ev = this.dex.gen < 3 ? 252 : 0;
|
|
532
486
|
if (this.dex.gen < 3) {
|
|
533
487
|
iv = this.toDV(iv) * 2;
|
|
534
488
|
nature = void 0;
|
|
@@ -538,10 +492,8 @@ var Stats = class {
|
|
|
538
492
|
} else {
|
|
539
493
|
const val = tr(tr(2 * base + iv + tr(ev / 4)) * level / 100 + 5);
|
|
540
494
|
if (nature !== void 0) {
|
|
541
|
-
if (nature.plus === stat)
|
|
542
|
-
|
|
543
|
-
if (nature.minus === stat)
|
|
544
|
-
return tr(tr(val * 90, 16) / 100);
|
|
495
|
+
if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);
|
|
496
|
+
if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);
|
|
545
497
|
}
|
|
546
498
|
return val;
|
|
547
499
|
}
|
|
@@ -551,16 +503,13 @@ var Stats = class {
|
|
|
551
503
|
}
|
|
552
504
|
display(str, full = false) {
|
|
553
505
|
let s = NAMES[str];
|
|
554
|
-
if (s === void 0)
|
|
555
|
-
|
|
556
|
-
if (this.dex.gen === 1 && s === "spa")
|
|
557
|
-
s = "spc";
|
|
506
|
+
if (s === void 0) return str;
|
|
507
|
+
if (this.dex.gen === 1 && s === "spa") s = "spc";
|
|
558
508
|
return DISPLAY[s][+full];
|
|
559
509
|
}
|
|
560
510
|
fill(stats, val) {
|
|
561
511
|
for (const stat of STATS) {
|
|
562
|
-
if (!(stat in stats))
|
|
563
|
-
stats[stat] = val;
|
|
512
|
+
if (!(stat in stats)) stats[stat] = val;
|
|
564
513
|
}
|
|
565
514
|
return stats;
|
|
566
515
|
}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"names":[],"mappings":";AA6BA,IAAM,iBAAiB,CAAC,MAAY;AAClC,MAAI,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AI,QAAQ,SAAY,KAAK,IAAI,GAAG,IAAI,IAAK,IACvD,KAAK,KAAK,IAAI,QAAQ,SAAY,KAAK,IAAI,GAAG,IAAI,IAAK,IACvD,KAAK,KAAK,IAAI,QAAQ,SAAY,KAAK,IAAI,GAAG,IAAI;AAAA,EAEvD;AAAA,EAEA,EAAE,OAAO,QAAQ,IAA8B;AAC7C,eAAW,KAAK,OAAO;AACrB,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,KAAK,IAAoB;AACvB,WAAO,KAAK,MAAM,KAAK,CAAC;AAAA,EAC1B;AAAA,EAEA,KAAK,IAAoB;AACvB,WAAO,KAAK,IAAI;AAAA,EAClB;AACF","sourcesContent":["import {\n AbilityName,\n Condition,\n Data,\n Dex,\n Species as DexSpecies,\n Type as DexType,\n EggGroup,\n EvoType,\n FormeName,\n GenderName,\n GenerationNum,\n ID,\n ItemName,\n Move,\n MoveCategory,\n MoveName,\n MoveSource,\n Nature,\n Nonstandard,\n SpeciesAbility,\n SpeciesName,\n SpeciesTag,\n StatID,\n StatsTable,\n Tier,\n TypeName,\n} from '@pkmn/dex-types';\n\nconst DEFAULT_EXISTS = (d: Data) => {\n if (!d.exists) return false;\n if ('isNonstandard' in d && d.isNonstandard) return false;\n if (d.kind === 'Ability' && d.id === 'noability') return false;\n return !('tier' in d && ['Illegal', 'Unreleased'].includes(d.tier));\n};\n\nconst tr = (num: number, bits = 0) => bits ? (num >>> 0) % (2 ** bits) : num >>> 0;\n\nexport type ExistsFn = (d: Data, g: GenerationNum) => boolean;\ntype BoundExistsFn = (d: Data) => boolean;\n\nfunction assignWithout(a: {[key: string]: any}, b: {[key: string]: any}, exclude: Set<string>) {\n for (const key in b) {\n if (Object.prototype.hasOwnProperty.call(b, key) && !exclude.has(key)) {\n a[key] = b[key];\n }\n }\n return a;\n}\n\nexport function toID(text: any): ID {\n if (text?.id) text = text.id;\n if (typeof text !== 'string' && typeof text !== 'number') return '';\n return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '') as ID;\n}\n\nexport class Generations {\n /* private */ readonly cache = Object.create(null) as {[num: number]: Generation};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: ExistsFn;\n\n static DEFAULT_EXISTS = DEFAULT_EXISTS;\n\n constructor(dex: Dex, exists = Generations.DEFAULT_EXISTS) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(g: string | number) {\n // May not actually be a GenerationNum, but isNaN and Dex.forGen will validate the rest\n const gen = (typeof g === 'string' ? parseInt(g.slice(g.search(/\\d/))) : g) as GenerationNum;\n if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);\n if (this.cache[gen]) return this.cache[gen];\n return (this.cache[gen] = new Generation(this.dex.forGen(gen), d => this.exists(d, gen)));\n }\n\n *[Symbol.iterator]() {\n for (let gen = 1; gen <= 9; gen++) {\n yield this.get(gen as GenerationNum);\n }\n }\n}\n\nexport class Generation {\n readonly abilities: Abilities;\n readonly items: Items;\n readonly moves: Moves;\n readonly species: Species;\n readonly types: Types;\n readonly natures: Natures;\n readonly learnsets: Learnsets;\n readonly conditions: Conditions;\n readonly stats: Stats;\n\n readonly dex: Dex;\n\n /* private */ readonly exists: BoundExistsFn;\n\n static get(dex: Dex, g: string | number, exists = DEFAULT_EXISTS) {\n return new Generations(dex, exists).get(g);\n }\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n\n this.abilities = new Abilities(this.dex, this.exists);\n this.items = new Items(this.dex, this.exists);\n this.moves = new Moves(this.dex, this.exists);\n this.species = new Species(this.dex, this.exists);\n this.natures = new Natures(this.dex, this.exists);\n this.types = new Types(this.dex, this.exists);\n this.learnsets = new Learnsets(this, this.dex, this.exists);\n this.conditions = new Conditions(this.dex, this.exists);\n this.stats = new Stats(this.dex);\n }\n\n get num() {\n return this.dex.gen;\n }\n\n toString() {\n return `[Generation:${this.num}]`;\n }\n\n toJSON() {\n return this.toString();\n }\n}\n\nexport class Abilities {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const ability = this.dex.abilities.get(name);\n return this.exists(ability) ? ability : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const ability in this.dex.data.Abilities) {\n const a = this.get(ability);\n if (a) yield a;\n }\n }\n}\n\nexport class Items {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const item = this.dex.items.get(name);\n return this.exists(item) ? item : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const item in this.dex.data.Items) {\n const i = this.get(item);\n if (i) yield i;\n }\n }\n}\n\nexport class Moves {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const move = this.dex.moves.get(name);\n return this.exists(move) ? move : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const move in this.dex.data.Moves) {\n const m = this.get(move);\n if (m) yield m;\n }\n }\n}\n\nexport class Species {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Specie};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const species = this.dex.species.get(name);\n if (!this.exists(species)) return undefined;\n const id = (species as any).speciesid || species.id; // FIXME Event-only ability hack\n const cached = this.cache[id];\n if (cached) return cached;\n return (this.cache[id] = new Specie(this.dex, this.exists, species));\n }\n\n *[Symbol.iterator]() {\n for (const species in this.dex.data.Species) {\n const s = this.get(species);\n if (s) yield s;\n }\n }\n}\n\nexport class Specie implements DexSpecies {\n readonly id!: ID;\n readonly name!: SpeciesName;\n readonly fullname!: string;\n readonly exists!: boolean;\n readonly num!: number;\n readonly gen!: GenerationNum;\n readonly shortDesc!: string;\n readonly desc!: string;\n readonly isNonstandard!: Nonstandard | null;\n readonly duration?: number;\n\n readonly effectType!: 'Pokemon';\n readonly kind!: 'Species';\n readonly baseStats!: StatsTable;\n readonly baseSpecies!: SpeciesName;\n readonly baseForme!: FormeName | '';\n readonly forme!: FormeName | '';\n readonly abilities!: SpeciesAbility<AbilityName | ''>;\n readonly types!: [TypeName] | [TypeName, TypeName];\n readonly prevo?: SpeciesName | '';\n readonly evos?: SpeciesName[];\n readonly nfe: boolean;\n readonly eggGroups!: EggGroup[];\n readonly weightkg!: number;\n readonly weighthg!: number;\n readonly tags!: SpeciesTag[];\n readonly unreleasedHidden!: boolean | 'Past';\n readonly maleOnlyHidden!: boolean;\n readonly inheritsFrom!: ID;\n readonly tier!: Tier.Singles | Tier.Other;\n readonly doublesTier!: Tier.Doubles;\n\n readonly changesFrom?: SpeciesName;\n readonly cosmeticFormes?: SpeciesName[];\n readonly otherFormes?: SpeciesName[];\n readonly formeOrder?: SpeciesName[];\n readonly formes?: SpeciesName[];\n readonly genderRatio: {M: number; F: number};\n readonly isMega?: boolean;\n readonly isPrimal?: boolean;\n readonly battleOnly?: SpeciesName | SpeciesName[];\n readonly canGigantamax?: MoveName;\n readonly gmaxUnreleased?: boolean;\n readonly cannotDynamax?: boolean;\n readonly requiredAbility?: AbilityName;\n readonly requiredItem?: ItemName;\n readonly requiredItems?: ItemName[];\n readonly requiredMove?: MoveName;\n readonly gender?: GenderName;\n readonly maxHP?: number;\n readonly evoMove?: MoveName;\n readonly evoItem?: string;\n readonly evoRegion?: 'Alola' | 'Galar';\n readonly evoLevel?: number;\n readonly evoCondition?: string;\n readonly evoType?: EvoType;\n readonly condition?: Partial<Condition>;\n readonly canHatch!: boolean;\n\n /* private */ readonly dex: Dex;\n\n /* private */ static readonly EXCLUDE = new Set([\n 'abilities', 'cosmeticFormes', 'evos', 'formeOrder',\n 'gender', 'genderRatio', 'nfe', 'otherFormes', 'prevo',\n ]);\n\n constructor(dex: Dex, exists: BoundExistsFn, species: DexSpecies) {\n assignWithout(this, species, Specie.EXCLUDE);\n this.dex = dex;\n if (this.dex.gen >= 2) {\n this.gender = species.gender;\n this.genderRatio = species.genderRatio;\n } else {\n this.genderRatio = {M: 0, F: 0};\n }\n if (this.dex.gen >= 3) {\n this.abilities = {0: species.abilities[0]};\n // \"because PS\", Pokemon have the abilities that were added in Gen 4 in Gen 3 :bigthonk:\n if (species.abilities[1] &&\n this.dex.abilities.get(species.abilities[1]).gen <= this.dex.gen) {\n this.abilities[1] = species.abilities[1];\n }\n if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;\n if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;\n } else {\n this.abilities = {0: ''};\n }\n this.evos = species.evos?.filter(s => exists(this.dex.species.get(s)));\n this.nfe = !!this.evos?.length;\n if (!this.nfe) this.evos = undefined;\n this.cosmeticFormes = species.cosmeticFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.cosmeticFormes?.length) this.cosmeticFormes = undefined;\n this.otherFormes = species.otherFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.otherFormes?.length) this.otherFormes = undefined;\n this.formeOrder = species.formeOrder?.filter(s => exists(this.dex.species.get(s)));\n if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = undefined;\n this.formes = this.formeOrder?.filter(s =>\n this.dex.species.get(s).isNonstandard !== 'Gigantamax');\n this.prevo =\n species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : undefined;\n }\n\n get formeNum() {\n return (this.baseSpecies === this.name\n ? this.formeOrder ? this.formeOrder.findIndex(name => name === this.name) : 0\n : this.dex.species.get(this.baseSpecies).formeOrder!.findIndex(\n name => name === (this.isNonstandard === 'Gigantamax' ? this.baseSpecies : this.name)\n ));\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['dex']));\n }\n}\n\nexport class Conditions {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const condition = this.dex.conditions.get(name);\n return this.exists(condition) ? condition : undefined;\n }\n}\n\nexport class Natures {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n if (this.dex.gen < 3) return undefined;\n const nature = this.dex.natures.get(name);\n return this.exists(nature) ? nature : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const nature in this.dex.data.Natures) {\n const n = this.get(nature);\n if (n) yield n;\n }\n }\n}\n\nconst EFFECTIVENESS = {\n '-3': 0.125,\n '-2': 0.25,\n '-1': 0.5,\n '0': 1,\n '1': 2,\n '2': 4,\n '3': 8,\n};\n\ntype TypeTarget = {getTypes: () => TypeName[]} | {types: TypeName[]} | TypeName[] | TypeName;\n\nexport class Types {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Type};\n\n /* private */ readonly unknown: Type;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n // PS doesn't contain data for the '???' type\n this.unknown = new Type({\n effectType: 'Type',\n kind: 'Type',\n // Regrettably PS ID's can't represent '???'\n id: '',\n name: '???',\n // Technically this only exists as a true type in Gens 2-4, but there are moves dealing\n // typeless damage in Gen 1 so we include it there.\n exists: dex.gen <= 4,\n gen: 1,\n // This gets filled in for us by Type's constructor\n damageTaken: {} as {[t in Exclude<TypeName, '???'>]: number},\n HPivs: {},\n HPdvs: {},\n }, dex, this);\n }\n\n get(name: string) {\n if (name === '???') return this.unknown;\n const type = this.dex.types.get(name);\n if (!this.exists(type)) return undefined;\n const cached = this.cache[type.id];\n if (cached) return cached;\n return (this.cache[type.id] = new Type(type, this.dex, this));\n }\n\n *[Symbol.iterator]() {\n for (const type in this.dex.data.Types) {\n const t = this.get(type);\n if (t) yield t;\n }\n if (this.dex.gen >= 2 && this.dex.gen <= 4) {\n yield this.unknown;\n }\n }\n\n getHiddenPower(ivs: StatsTable) {\n return this.dex.getHiddenPower(ivs);\n }\n\n canDamage(source: {type: TypeName} | TypeName, target: TypeTarget) {\n return this.dex.getImmunity(source, target);\n }\n\n totalEffectiveness(source: {type: TypeName} | TypeName, target: TypeTarget) {\n if (!this.canDamage(source, target)) return 0;\n const e = `${this.dex.getEffectiveness(source, target)}`;\n // convert from PS's ridiculous encoding to something usable\n return EFFECTIVENESS[e as keyof typeof EFFECTIVENESS];\n }\n}\n\nexport type TypeEffectiveness = 0 | 0.5 | 1 | 2;\n\nconst DAMAGE_TAKEN = [1, 2, 0.5, 0] as TypeEffectiveness[];\nconst SPECIAL = ['Fire', 'Water', 'Grass', 'Electric', 'Ice', 'Psychic', 'Dark', 'Dragon'];\n\nexport class Type {\n readonly id!: ID;\n readonly name!: TypeName;\n readonly effectType!: 'Type';\n readonly kind!: 'Type';\n readonly exists!: boolean;\n readonly gen!: GenerationNum;\n readonly effectiveness: {[t in TypeName]: TypeEffectiveness};\n readonly HPivs!: Partial<StatsTable>;\n readonly HPdvs!: Partial<StatsTable>;\n readonly category?: Exclude<MoveCategory, 'Status'>;\n\n /* private */ readonly types: Types;\n\n constructor(type: DexType, dex: Dex, types: Types) {\n Object.assign(this, type);\n this.types = types;\n this.category =\n this.name === 'Fairy' ? undefined : SPECIAL.includes(this.name) ? 'Special' : 'Physical';\n // convert from PS's ridiculous encoding to something usable (plus damage taken -> dealt)\n this.effectiveness = {'???': 1} as {[t in TypeName]: TypeEffectiveness};\n for (const k in dex.data.Types) {\n const t = k.charAt(0).toUpperCase() + k.slice(1) as Exclude<TypeName, '???'>;\n this.effectiveness[t] = DAMAGE_TAKEN[dex.data.Types[k].damageTaken[this.name] || 0];\n }\n }\n\n canDamage(target: TypeTarget) {\n return this.types.canDamage(this.name, target);\n }\n\n totalEffectiveness(target: TypeTarget) {\n return this.types.totalEffectiveness(this.name, target);\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['types']));\n }\n}\n\nconst GEN3_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'flash', 'rocksmash', 'waterfall', 'dive'] as ID[]);\n// NOTE: Whirlpool and Defog are Gen 4 HMs but the HMs differ in DPPt vs. HGSS\nconst GEN4_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'rocksmash', 'waterfall', 'rockclimb'] as ID[]);\n\ntype Restriction = 'Pentagon' | 'Plus' | 'Galar' | 'Paldea';\n\nexport class Learnsets {\n /* private */ readonly cache = Object.create(null) as {\n [speciesid: string]: {[moveid: string]: MoveSource[]};\n };\n\n /* private */ readonly gen: Generation;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(gen: Generation, dex: Dex, exists: BoundExistsFn) {\n this.gen = gen;\n this.dex = dex;\n this.exists = exists;\n }\n\n async get(name: string) {\n const learnset = await this.dex.learnsets.get(toID(name));\n return this.exists(learnset) ? learnset : undefined;\n }\n\n async *[Symbol.iterator]() {\n if (!this.dex.data.Learnsets) await this.dex.learnsets.get('LOAD' as ID);\n for (const id in this.dex.data.Learnsets) {\n const l = await this.get(id);\n if (l) yield l;\n }\n }\n\n async* all(species: Specie) {\n let id = species.id;\n let learnset = await this.get(id);\n if (!learnset) {\n id = typeof species.battleOnly === 'string' && species.battleOnly !== species.baseSpecies\n ? toID(species.battleOnly)\n : toID(species.baseSpecies);\n learnset = await this.get(id);\n }\n\n while (learnset) {\n yield learnset;\n\n if (id === 'lycanrocdusk' || (species.id === 'rockruff' && id === 'rockruff')) {\n id = 'rockruffdusk' as ID;\n } else if (species.id === 'gastrodoneast') {\n id = 'gastrodon' as ID;\n } else if (species.id === 'pumpkaboosuper') {\n id = 'pumpkaboo' as ID;\n } else {\n id = toID(species.battleOnly || species.changesFrom || species.prevo);\n }\n\n if (!id) break;\n const s = this.gen.species.get(id);\n if (!s) break;\n species = s;\n learnset = await this.get(id);\n }\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async learnable(name: string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return undefined;\n\n if (!restriction) {\n const cached = this.cache[species.id];\n if (cached) return cached;\n }\n\n const moves: {[moveid: string]: MoveSource[]} = {};\n\n for await (const learnset of this.all(species)) {\n if (learnset.learnset) {\n for (const moveid in learnset.learnset) {\n const move = this.gen.moves.get(moveid);\n if (move) {\n const sources = learnset.learnset[moveid];\n if (this.isLegal(move, sources, restriction || this.gen)) {\n const filtered = sources.filter(s => +s.charAt(0) <= this.gen.num);\n if (!filtered.length) continue;\n if (moves[move.id]) {\n // If we simply add filtered to moves[move.id] we may end up with some duplicates or\n // situations where we have mixed learnset information. We assume that while\n // moves[move.id] and filtered are already deduped, their union might not be, and\n // thus iterate through looking for unique prefixes. For efficiency, instead of\n // appending each deduped source from filtered to moves[move.id] immediately and\n // making each subsequent iteration longer we make a list of the unique sources to\n // add at the end. This is only safe given our assumption that filtered is unique\n // internally to begin with.\n const unique = [];\n // These lists are all expected to be short arrays so this O(n^2) linear searching\n // is still expected to be faster runtime-wise than a more sophisticated approach\n loop: for (const source of filtered) {\n const prefix = source.slice(0, 2);\n // sadly Babel chokes on using an .every(...) here due to throwIfClosureRequired\n for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;\n unique.push(source);\n }\n moves[move.id].push(...unique);\n } else {\n moves[move.id] = filtered;\n }\n }\n }\n }\n }\n }\n\n if (!restriction) this.cache[species.id] = moves;\n return moves;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async canLearn(name: string, move: Move | string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return false;\n\n move = typeof move === 'string' && this.gen.moves.get(move) || move;\n if (typeof move === 'string') return false;\n\n for await (const learnset of this.all(species)) {\n if (this.isLegal(move, learnset.learnset?.[move.id], restriction || this.gen)) {\n return true;\n }\n }\n\n return false;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n isLegal(move: Move, sources: MoveSource[] | undefined, gen: Generation | Restriction) {\n if (!sources) return undefined;\n\n const gens = sources.map(x => Number(x[0]));\n const minGen = Math.min(...gens);\n const vcOnly = (\n minGen === 7 && sources.every(x => x[0] !== '7' || x === '7V') ||\n minGen === 8 && sources.every(x => x[0] !== '8' || x === '8V')\n );\n\n if (gen === 'Pentagon') return gens.includes(6);\n if (gen === 'Plus') return gens.includes(7) && !vcOnly;\n if (gen === 'Galar') return gens.includes(8) && !vcOnly;\n if (gen === 'Paldea') return gens.includes(9);\n\n if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {\n let legalGens = '';\n let available = false;\n\n if (minGen === 3) {\n legalGens += '3';\n available = true;\n }\n if (available) available = !GEN3_HMS.has(move.id);\n\n if (available || gens.includes(4)) {\n legalGens += '4';\n available = true;\n }\n if (available) available = !GEN4_HMS.has(move.id);\n\n const minUpperGen = available ? 5 : Math.min(...gens.filter(g => g > 4));\n legalGens += '0123456789'.slice(minUpperGen);\n return legalGens.includes(`${gen.num}`);\n } else {\n return '0123456789'.slice(minGen).includes(`${gen.num}`);\n }\n }\n}\n\nconst STATS = ['hp', 'atk', 'def', 'spe', 'spa', 'spd'] as const;\n\nconst NAMES: Readonly<{[name: string]: StatID}> = {\n HP: 'hp', hp: 'hp',\n Attack: 'atk', Atk: 'atk', atk: 'atk',\n Defense: 'def', Def: 'def', def: 'def',\n 'Special Attack': 'spa', SpA: 'spa', SAtk: 'spa', SpAtk: 'spa', spa: 'spa',\n Special: 'spa', spc: 'spa', Spc: 'spa',\n 'Special Defense': 'spd', SpD: 'spd', SDef: 'spd', SpDef: 'spd', spd: 'spd',\n Speed: 'spe', Spe: 'spe', Spd: 'spe', spe: 'spe',\n};\n\nconst DISPLAY: Readonly<{[stat: string]: Readonly<[string, string]>}> = {\n hp: ['HP', 'HP'],\n atk: ['Atk', 'Attack'],\n def: ['Def', 'Defense'],\n spa: ['SpA', 'Special Attack'],\n spd: ['SpD', 'Special Defense'],\n spe: ['Spe', 'Speed'],\n spc: ['Spc', 'Special'],\n};\n\nexport class Stats {\n /* private */ readonly dex: Dex;\n\n constructor(dex: Dex) {\n this.dex = dex;\n }\n\n calc(stat: StatID, base: number, iv = 31, ev?: number, level = 100, nature?: Nature) {\n if (ev === undefined) ev = this.dex.gen < 3 ? 252 : 0;\n if (this.dex.gen < 3) {\n iv = this.toDV(iv) * 2;\n nature = undefined;\n }\n if (stat === 'hp') {\n return base === 1 ? base : tr(tr(2 * base + iv + tr(ev / 4) + 100) * level / 100 + 10);\n } else {\n const val = tr(tr(2 * base + iv + tr(ev / 4)) * level / 100 + 5);\n if (nature !== undefined) {\n if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);\n if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);\n }\n return val;\n }\n }\n\n get(s: string): StatID | undefined {\n return NAMES[s];\n }\n\n display(str: string, full = false): string {\n let s: StatID | 'spc' | undefined = NAMES[str];\n if (s === undefined) return str;\n if (this.dex.gen === 1 && s === 'spa') s = 'spc';\n return DISPLAY[s][+full];\n }\n\n fill<T>(stats: Partial<StatsTable<T>>, val: T): StatsTable<T> {\n for (const stat of STATS) {\n if (!(stat in stats)) stats[stat] = val;\n }\n return stats as StatsTable<T>;\n }\n\n getHPDV(ivs: Partial<StatsTable>): number {\n return (\n (this.toDV(ivs.atk === undefined ? 31 : ivs.atk) % 2) * 8 +\n (this.toDV(ivs.def === undefined ? 31 : ivs.def) % 2) * 4 +\n (this.toDV(ivs.spe === undefined ? 31 : ivs.spe) % 2) * 2 +\n (this.toDV(ivs.spa === undefined ? 31 : ivs.spa) % 2)\n );\n }\n\n *[Symbol.iterator](): IterableIterator<StatID> {\n for (const s of STATS) {\n yield s;\n }\n }\n\n toDV(iv: number): number {\n return Math.floor(iv / 2);\n }\n\n toIV(dv: number): number {\n return dv * 2 + 1;\n }\n}\n\nexport type {\n ID,\n As,\n Weather,\n FieldCondition,\n SideCondition,\n GenerationNum,\n GenderName,\n StatID,\n StatsTable,\n BoostID,\n BoostsTable,\n MoveCategory,\n MoveTarget,\n Nonstandard,\n EvoType,\n EggGroup,\n SideID,\n Player,\n GameType,\n HPColor,\n StatusName,\n NatureName,\n TypeName,\n HPTypeName,\n Tier,\n PokemonSet,\n AbilityName,\n ItemName,\n MoveName,\n SpeciesName,\n FormeName,\n EffectType,\n Effect,\n DataKind,\n Data,\n EffectData,\n HitEffect,\n SecondaryEffect,\n ConditionData,\n AbilityData,\n ItemData,\n MoveData,\n SpeciesData,\n MoveSource,\n EventInfoData,\n LearnsetData,\n TypeData,\n NatureData,\n BasicEffect,\n Condition,\n Ability,\n Item,\n Move,\n // Species,\n EventInfo,\n Learnset,\n // Type,\n Nature,\n GenID,\n Dex,\n} from '@pkmn/dex-types';\n"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"names":[],"mappings":";AA6BA,IAAM,iBAAiB,CAAC,MAAY;AAClC,MAAI,CAAC,EAAE,OAAQ,QAAO;AACtB,MAAI,mBAAmB,KAAK,EAAE,cAAe,QAAO;AACpD,MAAI,EAAE,SAAS,aAAa,EAAE,OAAO,YAAa,QAAO;AACzD,SAAO,EAAE,UAAU,KAAK,CAAC,WAAW,YAAY,EAAE,SAAS,EAAE,IAAI;AACnE;AAEA,IAAM,KAAK,CAAC,KAAa,OAAO,MAAM,QAAQ,QAAQ,KAAM,KAAK,OAAQ,QAAQ;AAKjF,SAAS,cAAc,GAAyB,GAAyB,SAAsB;AAC7F,aAAW,OAAO,GAAG;AACnB,QAAI,OAAO,UAAU,eAAe,KAA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,KAAK,IAAoB;AACvB,WAAO,KAAK,IAAI;AAAA,EAClB;AACF","sourcesContent":["import {\n AbilityName,\n Condition,\n Data,\n Dex,\n Species as DexSpecies,\n Type as DexType,\n EggGroup,\n EvoType,\n FormeName,\n GenderName,\n GenerationNum,\n ID,\n ItemName,\n Move,\n MoveCategory,\n MoveName,\n MoveSource,\n Nature,\n Nonstandard,\n SpeciesAbility,\n SpeciesName,\n SpeciesTag,\n StatID,\n StatsTable,\n Tier,\n TypeName,\n} from '@pkmn/dex-types';\n\nconst DEFAULT_EXISTS = (d: Data) => {\n if (!d.exists) return false;\n if ('isNonstandard' in d && d.isNonstandard) return false;\n if (d.kind === 'Ability' && d.id === 'noability') return false;\n return !('tier' in d && ['Illegal', 'Unreleased'].includes(d.tier));\n};\n\nconst tr = (num: number, bits = 0) => bits ? (num >>> 0) % (2 ** bits) : num >>> 0;\n\nexport type ExistsFn = (d: Data, g: GenerationNum) => boolean;\ntype BoundExistsFn = (d: Data) => boolean;\n\nfunction assignWithout(a: {[key: string]: any}, b: {[key: string]: any}, exclude: Set<string>) {\n for (const key in b) {\n if (Object.prototype.hasOwnProperty.call(b, key) && !exclude.has(key)) {\n a[key] = b[key];\n }\n }\n return a;\n}\n\nexport function toID(text: any): ID {\n if (text?.id) text = text.id;\n if (typeof text !== 'string' && typeof text !== 'number') return '';\n return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '') as ID;\n}\n\nexport class Generations {\n /* private */ readonly cache = Object.create(null) as {[num: number]: Generation};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: ExistsFn;\n\n static DEFAULT_EXISTS = DEFAULT_EXISTS;\n\n constructor(dex: Dex, exists = Generations.DEFAULT_EXISTS) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(g: string | number) {\n // May not actually be a GenerationNum, but isNaN and Dex.forGen will validate the rest\n const gen = (typeof g === 'string' ? parseInt(g.slice(g.search(/\\d/))) : g) as GenerationNum;\n if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);\n if (this.cache[gen]) return this.cache[gen];\n return (this.cache[gen] = new Generation(this.dex.forGen(gen), d => this.exists(d, gen)));\n }\n\n *[Symbol.iterator]() {\n for (let gen = 1; gen <= 9; gen++) {\n yield this.get(gen as GenerationNum);\n }\n }\n}\n\nexport class Generation {\n readonly abilities: Abilities;\n readonly items: Items;\n readonly moves: Moves;\n readonly species: Species;\n readonly types: Types;\n readonly natures: Natures;\n readonly learnsets: Learnsets;\n readonly conditions: Conditions;\n readonly stats: Stats;\n\n readonly dex: Dex;\n\n /* private */ readonly exists: BoundExistsFn;\n\n static get(dex: Dex, g: string | number, exists = DEFAULT_EXISTS) {\n return new Generations(dex, exists).get(g);\n }\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n\n this.abilities = new Abilities(this.dex, this.exists);\n this.items = new Items(this.dex, this.exists);\n this.moves = new Moves(this.dex, this.exists);\n this.species = new Species(this.dex, this.exists);\n this.natures = new Natures(this.dex, this.exists);\n this.types = new Types(this.dex, this.exists);\n this.learnsets = new Learnsets(this, this.dex, this.exists);\n this.conditions = new Conditions(this.dex, this.exists);\n this.stats = new Stats(this.dex);\n }\n\n get num() {\n return this.dex.gen;\n }\n\n toString() {\n return `[Generation:${this.num}]`;\n }\n\n toJSON() {\n return this.toString();\n }\n}\n\nexport class Abilities {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const ability = this.dex.abilities.get(name);\n return this.exists(ability) ? ability : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const ability in this.dex.data.Abilities) {\n const a = this.get(ability);\n if (a) yield a;\n }\n }\n}\n\nexport class Items {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const item = this.dex.items.get(name);\n return this.exists(item) ? item : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const item in this.dex.data.Items) {\n const i = this.get(item);\n if (i) yield i;\n }\n }\n}\n\nexport class Moves {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const move = this.dex.moves.get(name);\n return this.exists(move) ? move : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const move in this.dex.data.Moves) {\n const m = this.get(move);\n if (m) yield m;\n }\n }\n}\n\nexport class Species {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Specie};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const species = this.dex.species.get(name);\n if (!this.exists(species)) return undefined;\n const id = (species as any).speciesid || species.id; // FIXME Event-only ability hack\n const cached = this.cache[id];\n if (cached) return cached;\n return (this.cache[id] = new Specie(this.dex, this.exists, species));\n }\n\n *[Symbol.iterator]() {\n for (const species in this.dex.data.Species) {\n const s = this.get(species);\n if (s) yield s;\n }\n }\n}\n\nexport class Specie implements DexSpecies {\n readonly id!: ID;\n readonly name!: SpeciesName;\n readonly fullname!: string;\n readonly exists!: boolean;\n readonly num!: number;\n readonly gen!: GenerationNum;\n readonly shortDesc!: string;\n readonly desc!: string;\n readonly isNonstandard!: Nonstandard | null;\n readonly duration?: number;\n\n readonly effectType!: 'Pokemon';\n readonly kind!: 'Species';\n readonly baseStats!: StatsTable;\n readonly baseSpecies!: SpeciesName;\n readonly baseForme!: FormeName | '';\n readonly forme!: FormeName | '';\n readonly abilities!: SpeciesAbility<AbilityName | ''>;\n readonly types!: [TypeName] | [TypeName, TypeName];\n readonly prevo?: SpeciesName | '';\n readonly evos?: SpeciesName[];\n readonly nfe: boolean;\n readonly eggGroups!: EggGroup[];\n readonly weightkg!: number;\n readonly weighthg!: number;\n readonly tags!: SpeciesTag[];\n readonly unreleasedHidden!: boolean | 'Past';\n readonly maleOnlyHidden!: boolean;\n readonly inheritsFrom!: ID;\n readonly tier!: Tier.Singles | Tier.Other;\n readonly doublesTier!: Tier.Doubles;\n\n readonly changesFrom?: SpeciesName;\n readonly cosmeticFormes?: SpeciesName[];\n readonly otherFormes?: SpeciesName[];\n readonly formeOrder?: SpeciesName[];\n readonly formes?: SpeciesName[];\n readonly genderRatio: {M: number; F: number};\n readonly isMega?: boolean;\n readonly isPrimal?: boolean;\n readonly battleOnly?: SpeciesName | SpeciesName[];\n readonly canGigantamax?: MoveName;\n readonly gmaxUnreleased?: boolean;\n readonly cannotDynamax?: boolean;\n readonly requiredAbility?: AbilityName;\n readonly requiredItem?: ItemName;\n readonly requiredItems?: ItemName[];\n readonly requiredMove?: MoveName;\n readonly gender?: GenderName;\n readonly maxHP?: number;\n readonly evoMove?: MoveName;\n readonly evoItem?: string;\n readonly evoRegion?: 'Alola' | 'Galar';\n readonly evoLevel?: number;\n readonly evoCondition?: string;\n readonly evoType?: EvoType;\n readonly condition?: Partial<Condition>;\n readonly canHatch!: boolean;\n\n /* private */ readonly dex: Dex;\n\n /* private */ static readonly EXCLUDE = new Set([\n 'abilities', 'cosmeticFormes', 'evos', 'formeOrder',\n 'gender', 'genderRatio', 'nfe', 'otherFormes', 'prevo',\n ]);\n\n constructor(dex: Dex, exists: BoundExistsFn, species: DexSpecies) {\n assignWithout(this, species, Specie.EXCLUDE);\n this.dex = dex;\n if (this.dex.gen >= 2) {\n this.gender = species.gender;\n this.genderRatio = species.genderRatio;\n } else {\n this.genderRatio = {M: 0, F: 0};\n }\n if (this.dex.gen >= 3) {\n this.abilities = {0: species.abilities[0]};\n // \"because PS\", Pokemon have the abilities that were added in Gen 4 in Gen 3 :bigthonk:\n if (species.abilities[1] &&\n this.dex.abilities.get(species.abilities[1]).gen <= this.dex.gen) {\n this.abilities[1] = species.abilities[1];\n }\n if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;\n if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;\n } else {\n this.abilities = {0: ''};\n }\n this.evos = species.evos?.filter(s => exists(this.dex.species.get(s)));\n this.nfe = !!this.evos?.length;\n if (!this.nfe) this.evos = undefined;\n this.cosmeticFormes = species.cosmeticFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.cosmeticFormes?.length) this.cosmeticFormes = undefined;\n this.otherFormes = species.otherFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.otherFormes?.length) this.otherFormes = undefined;\n this.formeOrder = species.formeOrder?.filter(s => exists(this.dex.species.get(s)));\n if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = undefined;\n this.formes = this.formeOrder?.filter(s =>\n this.dex.species.get(s).isNonstandard !== 'Gigantamax');\n this.prevo =\n species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : undefined;\n }\n\n get formeNum() {\n return (this.baseSpecies === this.name\n ? this.formeOrder ? this.formeOrder.findIndex(name => name === this.name) : 0\n : this.dex.species.get(this.baseSpecies).formeOrder!.findIndex(\n name => name === (this.isNonstandard === 'Gigantamax' ? this.baseSpecies : this.name)\n ));\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['dex']));\n }\n}\n\nexport class Conditions {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const condition = this.dex.conditions.get(name);\n return this.exists(condition) ? condition : undefined;\n }\n}\n\nexport class Natures {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n if (this.dex.gen < 3) return undefined;\n const nature = this.dex.natures.get(name);\n return this.exists(nature) ? nature : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const nature in this.dex.data.Natures) {\n const n = this.get(nature);\n if (n) yield n;\n }\n }\n}\n\nconst EFFECTIVENESS = {\n '-3': 0.125,\n '-2': 0.25,\n '-1': 0.5,\n '0': 1,\n '1': 2,\n '2': 4,\n '3': 8,\n};\n\ntype TypeTarget = {getTypes: () => TypeName[]} | {types: TypeName[]} | TypeName[] | TypeName;\n\nexport class Types {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Type};\n\n /* private */ readonly unknown: Type;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n // PS doesn't contain data for the '???' type\n this.unknown = new Type({\n effectType: 'Type',\n kind: 'Type',\n // Regrettably PS ID's can't represent '???'\n id: '',\n name: '???',\n // Technically this only exists as a true type in Gens 2-4, but there are moves dealing\n // typeless damage in Gen 1 so we include it there.\n exists: dex.gen <= 4,\n gen: 1,\n // This gets filled in for us by Type's constructor\n damageTaken: {} as {[t in Exclude<TypeName, '???'>]: number},\n HPivs: {},\n HPdvs: {},\n }, dex, this);\n }\n\n get(name: string) {\n if (name === '???') return this.unknown;\n const type = this.dex.types.get(name);\n if (!this.exists(type)) return undefined;\n const cached = this.cache[type.id];\n if (cached) return cached;\n return (this.cache[type.id] = new Type(type, this.dex, this));\n }\n\n *[Symbol.iterator]() {\n for (const type in this.dex.data.Types) {\n const t = this.get(type);\n if (t) yield t;\n }\n if (this.dex.gen >= 2 && this.dex.gen <= 4) {\n yield this.unknown;\n }\n }\n\n getHiddenPower(ivs: StatsTable) {\n return this.dex.getHiddenPower(ivs);\n }\n\n canDamage(source: {type: TypeName} | TypeName, target: TypeTarget) {\n return this.dex.getImmunity(source, target);\n }\n\n totalEffectiveness(source: {type: TypeName} | TypeName, target: TypeTarget) {\n if (!this.canDamage(source, target)) return 0;\n const e = `${this.dex.getEffectiveness(source, target)}`;\n // convert from PS's ridiculous encoding to something usable\n return EFFECTIVENESS[e as keyof typeof EFFECTIVENESS];\n }\n}\n\nexport type TypeEffectiveness = 0 | 0.5 | 1 | 2;\n\nconst DAMAGE_TAKEN = [1, 2, 0.5, 0] as TypeEffectiveness[];\nconst SPECIAL = ['Fire', 'Water', 'Grass', 'Electric', 'Ice', 'Psychic', 'Dark', 'Dragon'];\n\nexport class Type {\n readonly id!: ID;\n readonly name!: TypeName;\n readonly effectType!: 'Type';\n readonly kind!: 'Type';\n readonly exists!: boolean;\n readonly gen!: GenerationNum;\n readonly effectiveness: {[t in TypeName]: TypeEffectiveness};\n readonly HPivs!: Partial<StatsTable>;\n readonly HPdvs!: Partial<StatsTable>;\n readonly category?: Exclude<MoveCategory, 'Status'>;\n\n /* private */ readonly types: Types;\n\n constructor(type: DexType, dex: Dex, types: Types) {\n Object.assign(this, type);\n this.types = types;\n this.category =\n this.name === 'Fairy' ? undefined : SPECIAL.includes(this.name) ? 'Special' : 'Physical';\n // convert from PS's ridiculous encoding to something usable (plus damage taken -> dealt)\n this.effectiveness = {'???': 1} as {[t in TypeName]: TypeEffectiveness};\n for (const k in dex.data.Types) {\n const t = k.charAt(0).toUpperCase() + k.slice(1) as Exclude<TypeName, '???'>;\n const data = dex.data.Types[k as Lowercase<string>];\n this.effectiveness[t] = DAMAGE_TAKEN[data.damageTaken[this.name] || 0];\n }\n }\n\n canDamage(target: TypeTarget) {\n return this.types.canDamage(this.name, target);\n }\n\n totalEffectiveness(target: TypeTarget) {\n return this.types.totalEffectiveness(this.name, target);\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['types']));\n }\n}\n\nconst GEN3_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'flash', 'rocksmash', 'waterfall', 'dive'] as ID[]);\n// NOTE: Whirlpool and Defog are Gen 4 HMs but the HMs differ in DPPt vs. HGSS\nconst GEN4_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'rocksmash', 'waterfall', 'rockclimb'] as ID[]);\n\ntype Restriction = 'Pentagon' | 'Plus' | 'Galar' | 'Paldea';\n\nexport class Learnsets {\n /* private */ readonly cache = Object.create(null) as {\n [speciesid: string]: {[moveid: string]: MoveSource[]};\n };\n\n /* private */ readonly gen: Generation;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(gen: Generation, dex: Dex, exists: BoundExistsFn) {\n this.gen = gen;\n this.dex = dex;\n this.exists = exists;\n }\n\n async get(name: string) {\n const learnset = await this.dex.learnsets.get(toID(name));\n return this.exists(learnset) ? learnset : undefined;\n }\n\n async *[Symbol.iterator]() {\n if (!this.dex.data.Learnsets) await this.dex.learnsets.get('LOAD' as ID);\n for (const id in this.dex.data.Learnsets) {\n const l = await this.get(id);\n if (l) yield l;\n }\n }\n\n async* all(species: Specie) {\n let id = species.id;\n let learnset = await this.get(id);\n if (!learnset) {\n id = typeof species.battleOnly === 'string' && species.battleOnly !== species.baseSpecies\n ? toID(species.battleOnly)\n : toID(species.baseSpecies);\n learnset = await this.get(id);\n }\n\n while (learnset) {\n yield learnset;\n\n if (id === 'lycanrocdusk' || (species.id === 'rockruff' && id === 'rockruff')) {\n id = 'rockruffdusk' as ID;\n } else if (species.id === 'gastrodoneast') {\n id = 'gastrodon' as ID;\n } else if (species.id === 'pumpkaboosuper') {\n id = 'pumpkaboo' as ID;\n } else {\n id = toID(species.battleOnly || species.changesFrom || species.prevo);\n }\n\n if (!id) break;\n const s = this.gen.species.get(id);\n if (!s) break;\n species = s;\n learnset = await this.get(id);\n }\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async learnable(name: string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return undefined;\n\n if (!restriction) {\n const cached = this.cache[species.id];\n if (cached) return cached;\n }\n\n const moves: {[moveid: string]: MoveSource[]} = {};\n\n for await (const learnset of this.all(species)) {\n if (learnset.learnset) {\n for (const moveid in learnset.learnset) {\n const move = this.gen.moves.get(moveid);\n if (move) {\n const sources = learnset.learnset[moveid];\n if (this.isLegal(move, sources, restriction || this.gen)) {\n const filtered = sources.filter(s => +s.charAt(0) <= this.gen.num);\n if (!filtered.length) continue;\n if (moves[move.id]) {\n // If we simply add filtered to moves[move.id] we may end up with some duplicates or\n // situations where we have mixed learnset information. We assume that while\n // moves[move.id] and filtered are already deduped, their union might not be, and\n // thus iterate through looking for unique prefixes. For efficiency, instead of\n // appending each deduped source from filtered to moves[move.id] immediately and\n // making each subsequent iteration longer we make a list of the unique sources to\n // add at the end. This is only safe given our assumption that filtered is unique\n // internally to begin with.\n const unique = [];\n // These lists are all expected to be short arrays so this O(n^2) linear searching\n // is still expected to be faster runtime-wise than a more sophisticated approach\n loop: for (const source of filtered) {\n const prefix = source.slice(0, 2);\n // sadly Babel chokes on using an .every(...) here due to throwIfClosureRequired\n for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;\n unique.push(source);\n }\n moves[move.id].push(...unique);\n } else {\n moves[move.id] = filtered;\n }\n }\n }\n }\n }\n }\n\n if (!restriction) this.cache[species.id] = moves;\n return moves;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async canLearn(name: string, move: Move | string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return false;\n\n move = typeof move === 'string' && this.gen.moves.get(move) || move;\n if (typeof move === 'string') return false;\n\n for await (const learnset of this.all(species)) {\n if (this.isLegal(move, learnset.learnset?.[move.id], restriction || this.gen)) {\n return true;\n }\n }\n\n return false;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n isLegal(move: Move, sources: MoveSource[] | undefined, gen: Generation | Restriction) {\n if (!sources) return undefined;\n\n const gens = sources.map(x => Number(x[0]));\n const minGen = Math.min(...gens);\n const vcOnly = (\n minGen === 7 && sources.every(x => x[0] !== '7' || x === '7V') ||\n minGen === 8 && sources.every(x => x[0] !== '8' || x === '8V')\n );\n\n if (gen === 'Pentagon') return gens.includes(6);\n if (gen === 'Plus') return gens.includes(7) && !vcOnly;\n if (gen === 'Galar') return gens.includes(8) && !vcOnly;\n if (gen === 'Paldea') return gens.includes(9);\n\n if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {\n let legalGens = '';\n let available = false;\n\n if (minGen === 3) {\n legalGens += '3';\n available = true;\n }\n if (available) available = !GEN3_HMS.has(move.id);\n\n if (available || gens.includes(4)) {\n legalGens += '4';\n available = true;\n }\n if (available) available = !GEN4_HMS.has(move.id);\n\n const minUpperGen = available ? 5 : Math.min(...gens.filter(g => g > 4));\n legalGens += '0123456789'.slice(minUpperGen);\n return legalGens.includes(`${gen.num}`);\n } else {\n return '0123456789'.slice(minGen).includes(`${gen.num}`);\n }\n }\n}\n\nconst STATS = ['hp', 'atk', 'def', 'spe', 'spa', 'spd'] as const;\n\nconst NAMES: Readonly<{[name: string]: StatID}> = {\n HP: 'hp', hp: 'hp',\n Attack: 'atk', Atk: 'atk', atk: 'atk',\n Defense: 'def', Def: 'def', def: 'def',\n 'Special Attack': 'spa', SpA: 'spa', SAtk: 'spa', SpAtk: 'spa', spa: 'spa',\n Special: 'spa', spc: 'spa', Spc: 'spa',\n 'Special Defense': 'spd', SpD: 'spd', SDef: 'spd', SpDef: 'spd', spd: 'spd',\n Speed: 'spe', Spe: 'spe', Spd: 'spe', spe: 'spe',\n};\n\nconst DISPLAY: Readonly<{[stat: string]: Readonly<[string, string]>}> = {\n hp: ['HP', 'HP'],\n atk: ['Atk', 'Attack'],\n def: ['Def', 'Defense'],\n spa: ['SpA', 'Special Attack'],\n spd: ['SpD', 'Special Defense'],\n spe: ['Spe', 'Speed'],\n spc: ['Spc', 'Special'],\n};\n\nexport class Stats {\n /* private */ readonly dex: Dex;\n\n constructor(dex: Dex) {\n this.dex = dex;\n }\n\n calc(stat: StatID, base: number, iv = 31, ev?: number, level = 100, nature?: Nature) {\n if (ev === undefined) ev = this.dex.gen < 3 ? 252 : 0;\n if (this.dex.gen < 3) {\n iv = this.toDV(iv) * 2;\n nature = undefined;\n }\n if (stat === 'hp') {\n return base === 1 ? base : tr(tr(2 * base + iv + tr(ev / 4) + 100) * level / 100 + 10);\n } else {\n const val = tr(tr(2 * base + iv + tr(ev / 4)) * level / 100 + 5);\n if (nature !== undefined) {\n if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);\n if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);\n }\n return val;\n }\n }\n\n get(s: string): StatID | undefined {\n return NAMES[s];\n }\n\n display(str: string, full = false): string {\n let s: StatID | 'spc' | undefined = NAMES[str];\n if (s === undefined) return str;\n if (this.dex.gen === 1 && s === 'spa') s = 'spc';\n return DISPLAY[s][+full];\n }\n\n fill<T>(stats: Partial<StatsTable<T>>, val: T): StatsTable<T> {\n for (const stat of STATS) {\n if (!(stat in stats)) stats[stat] = val;\n }\n return stats as StatsTable<T>;\n }\n\n getHPDV(ivs: Partial<StatsTable>): number {\n return (\n (this.toDV(ivs.atk === undefined ? 31 : ivs.atk) % 2) * 8 +\n (this.toDV(ivs.def === undefined ? 31 : ivs.def) % 2) * 4 +\n (this.toDV(ivs.spe === undefined ? 31 : ivs.spe) % 2) * 2 +\n (this.toDV(ivs.spa === undefined ? 31 : ivs.spa) % 2)\n );\n }\n\n *[Symbol.iterator](): IterableIterator<StatID> {\n for (const s of STATS) {\n yield s;\n }\n }\n\n toDV(iv: number): number {\n return Math.floor(iv / 2);\n }\n\n toIV(dv: number): number {\n return dv * 2 + 1;\n }\n}\n\nexport type {\n ID,\n As,\n Weather,\n FieldCondition,\n SideCondition,\n GenerationNum,\n GenderName,\n StatID,\n StatsTable,\n BoostID,\n BoostsTable,\n MoveCategory,\n MoveTarget,\n Nonstandard,\n EvoType,\n EggGroup,\n SideID,\n Player,\n GameType,\n HPColor,\n StatusName,\n NatureName,\n TypeName,\n HPTypeName,\n Tier,\n PokemonSet,\n AbilityName,\n ItemName,\n MoveName,\n SpeciesName,\n FormeName,\n EffectType,\n Effect,\n DataKind,\n Data,\n EffectData,\n HitEffect,\n SecondaryEffect,\n ConditionData,\n AbilityData,\n ItemData,\n MoveData,\n SpeciesData,\n MoveSource,\n EventInfoData,\n LearnsetData,\n TypeData,\n NatureData,\n BasicEffect,\n Condition,\n Ability,\n Item,\n Move,\n // Species,\n EventInfo,\n Learnset,\n // Type,\n Nature,\n GenID,\n Dex,\n} from '@pkmn/dex-types';\n"]}
|
package/build/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.pkmn=window.pkmn||{};window.pkmn.data=(()=>{var F=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
window.pkmn=window.pkmn||{};window.pkmn.data=(()=>{var F=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var R=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!C.call(n,i)&&i!==t&&F(n,i,{get:()=>e[i],enumerable:!(s=H(e,i))||s.enumerable});return n};var U=n=>V(F({},"__esModule",{value:!0}),n);var W={};R(W,{Abilities:()=>m,Conditions:()=>D,Generation:()=>p,Generations:()=>u,Items:()=>x,Learnsets:()=>E,Moves:()=>g,Natures:()=>T,Specie:()=>b,Species:()=>S,Stats:()=>v,Type:()=>f,Types:()=>N,toID:()=>y});var M=n=>!n.exists||"isNonstandard"in n&&n.isNonstandard||n.kind==="Ability"&&n.id==="noability"?!1:!("tier"in n&&["Illegal","Unreleased"].includes(n.tier)),l=(n,e=0)=>e?(n>>>0)%2**e:n>>>0;function I(n,e,t){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&!t.has(s)&&(n[s]=e[s]);return n}function y(n){return n?.id&&(n=n.id),typeof n!="string"&&typeof n!="number"?"":(""+n).toLowerCase().replace(/[^a-z0-9]+/g,"")}var u=class n{constructor(e,t=n.DEFAULT_EXISTS){this.cache=Object.create(null);this.dex=e,this.exists=t}static{this.DEFAULT_EXISTS=M}get(e){let t=typeof e=="string"?parseInt(e.slice(e.search(/\d/))):e;if(isNaN(+t))throw new Error(`Invalid gen ${e}`);return this.cache[t]?this.cache[t]:this.cache[t]=new p(this.dex.forGen(t),s=>this.exists(s,t))}*[Symbol.iterator](){for(let e=1;e<=9;e++)yield this.get(e)}},p=class{static get(e,t,s=M){return new u(e,s).get(t)}constructor(e,t){this.dex=e,this.exists=t,this.abilities=new m(this.dex,this.exists),this.items=new x(this.dex,this.exists),this.moves=new g(this.dex,this.exists),this.species=new S(this.dex,this.exists),this.natures=new T(this.dex,this.exists),this.types=new N(this.dex,this.exists),this.learnsets=new E(this,this.dex,this.exists),this.conditions=new D(this.dex,this.exists),this.stats=new v(this.dex)}get num(){return this.dex.gen}toString(){return`[Generation:${this.num}]`}toJSON(){return this.toString()}},m=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.abilities.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Abilities){let t=this.get(e);t&&(yield t)}}},x=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.items.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Items){let t=this.get(e);t&&(yield t)}}},g=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.moves.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Moves){let t=this.get(e);t&&(yield t)}}},S=class{constructor(e,t){this.cache=Object.create(null);this.dex=e,this.exists=t}get(e){let t=this.dex.species.get(e);if(!this.exists(t))return;let s=t.speciesid||t.id,i=this.cache[s];return i||(this.cache[s]=new b(this.dex,this.exists,t))}*[Symbol.iterator](){for(let e in this.dex.data.Species){let t=this.get(e);t&&(yield t)}}},b=class n{static{this.EXCLUDE=new Set(["abilities","cosmeticFormes","evos","formeOrder","gender","genderRatio","nfe","otherFormes","prevo"])}constructor(e,t,s){I(this,s,n.EXCLUDE),this.dex=e,this.dex.gen>=2?(this.gender=s.gender,this.genderRatio=s.genderRatio):this.genderRatio={M:0,F:0},this.dex.gen>=3?(this.abilities={0:s.abilities[0]},s.abilities[1]&&this.dex.abilities.get(s.abilities[1]).gen<=this.dex.gen&&(this.abilities[1]=s.abilities[1]),this.dex.gen>=5&&s.abilities.H&&(this.abilities.H=s.abilities.H),this.dex.gen>=7&&s.abilities.S&&(this.abilities.S=s.abilities.S)):this.abilities={0:""},this.evos=s.evos?.filter(i=>t(this.dex.species.get(i))),this.nfe=!!this.evos?.length,this.nfe||(this.evos=void 0),this.cosmeticFormes=s.cosmeticFormes?.filter(i=>t(this.dex.species.get(i))),this.cosmeticFormes?.length||(this.cosmeticFormes=void 0),this.otherFormes=s.otherFormes?.filter(i=>t(this.dex.species.get(i))),this.otherFormes?.length||(this.otherFormes=void 0),this.formeOrder=s.formeOrder?.filter(i=>t(this.dex.species.get(i))),(!this.formeOrder||this.formeOrder.length<=1)&&(this.formeOrder=void 0),this.formes=this.formeOrder?.filter(i=>this.dex.species.get(i).isNonstandard!=="Gigantamax"),this.prevo=s.prevo&&t(this.dex.species.get(s.prevo))?s.prevo:void 0}get formeNum(){return this.baseSpecies===this.name?this.formeOrder?this.formeOrder.findIndex(e=>e===this.name):0:this.dex.species.get(this.baseSpecies).formeOrder.findIndex(e=>e===(this.isNonstandard==="Gigantamax"?this.baseSpecies:this.name))}toString(){return this.name}toJSON(){return I({},this,new Set(["dex"]))}},D=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.conditions.get(e);return this.exists(t)?t:void 0}},T=class{constructor(e,t){this.dex=e,this.exists=t}get(e){if(this.dex.gen<3)return;let t=this.dex.natures.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Natures){let t=this.get(e);t&&(yield t)}}},j={"-3":.125,"-2":.25,"-1":.5,0:1,1:2,2:4,3:8},N=class{constructor(e,t){this.cache=Object.create(null);this.dex=e,this.exists=t,this.unknown=new f({effectType:"Type",kind:"Type",id:"",name:"???",exists:e.gen<=4,gen:1,damageTaken:{},HPivs:{},HPdvs:{}},e,this)}get(e){if(e==="???")return this.unknown;let t=this.dex.types.get(e);if(!this.exists(t))return;let s=this.cache[t.id];return s||(this.cache[t.id]=new f(t,this.dex,this))}*[Symbol.iterator](){for(let e in this.dex.data.Types){let t=this.get(e);t&&(yield t)}this.dex.gen>=2&&this.dex.gen<=4&&(yield this.unknown)}getHiddenPower(e){return this.dex.getHiddenPower(e)}canDamage(e,t){return this.dex.getImmunity(e,t)}totalEffectiveness(e,t){if(!this.canDamage(e,t))return 0;let s=`${this.dex.getEffectiveness(e,t)}`;return j[s]}},q=[1,2,.5,0],X=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],f=class{constructor(e,t,s){Object.assign(this,e),this.types=s,this.category=this.name==="Fairy"?void 0:X.includes(this.name)?"Special":"Physical",this.effectiveness={"???":1};for(let i in t.data.Types){let r=i.charAt(0).toUpperCase()+i.slice(1),o=t.data.Types[i];this.effectiveness[r]=q[o.damageTaken[this.name]||0]}}canDamage(e){return this.types.canDamage(this.name,e)}totalEffectiveness(e){return this.types.totalEffectiveness(this.name,e)}toString(){return this.name}toJSON(){return I({},this,new Set(["types"]))}},w=new Set(["cut","fly","surf","strength","flash","rocksmash","waterfall","dive"]),A=new Set(["cut","fly","surf","strength","rocksmash","waterfall","rockclimb"]),E=class{constructor(e,t,s){this.cache=Object.create(null);this.gen=e,this.dex=t,this.exists=s}async get(e){let t=await this.dex.learnsets.get(y(e));return this.exists(t)?t:void 0}async*[Symbol.iterator](){this.dex.data.Learnsets||await this.dex.learnsets.get("LOAD");for(let e in this.dex.data.Learnsets){let t=await this.get(e);t&&(yield t)}}async*all(e){let t=e.id,s=await this.get(t);for(s||(t=typeof e.battleOnly=="string"&&e.battleOnly!==e.baseSpecies?y(e.battleOnly):y(e.baseSpecies),s=await this.get(t));s&&(yield s,t==="lycanrocdusk"||e.id==="rockruff"&&t==="rockruff"?t="rockruffdusk":e.id==="gastrodoneast"?t="gastrodon":e.id==="pumpkaboosuper"?t="pumpkaboo":t=y(e.battleOnly||e.changesFrom||e.prevo),!!t);){let i=this.gen.species.get(t);if(!i)break;e=i,s=await this.get(t)}}async learnable(e,t){let s=this.gen.species.get(e);if(!s)return;if(!t){let r=this.cache[s.id];if(r)return r}let i={};for await(let r of this.all(s))if(r.learnset)for(let o in r.learnset){let a=this.gen.moves.get(o);if(a){let d=r.learnset[o];if(this.isLegal(a,d,t||this.gen)){let h=d.filter(c=>+c.charAt(0)<=this.gen.num);if(!h.length)continue;if(i[a.id]){let c=[];e:for(let k of h){let O=k.slice(0,2);for(let B of i[a.id])if(B.startsWith(O))continue e;c.push(k)}i[a.id].push(...c)}else i[a.id]=h}}}return t||(this.cache[s.id]=i),i}async canLearn(e,t,s){let i=this.gen.species.get(e);if(!i||(t=typeof t=="string"&&this.gen.moves.get(t)||t,typeof t=="string"))return!1;for await(let r of this.all(i))if(this.isLegal(t,r.learnset?.[t.id],s||this.gen))return!0;return!1}isLegal(e,t,s){if(!t)return;let i=t.map(a=>Number(a[0])),r=Math.min(...i),o=r===7&&t.every(a=>a[0]!=="7"||a==="7V")||r===8&&t.every(a=>a[0]!=="8"||a==="8V");if(s==="Pentagon")return i.includes(6);if(s==="Plus")return i.includes(7)&&!o;if(s==="Galar")return i.includes(8)&&!o;if(s==="Paldea")return i.includes(9);if(this.gen.num>=3&&r<=4&&(w.has(e.id)||A.has(e.id))){let a="",d=!1;r===3&&(a+="3",d=!0),d&&(d=!w.has(e.id)),(d||i.includes(4))&&(a+="4",d=!0),d&&(d=!A.has(e.id));let h=d?5:Math.min(...i.filter(c=>c>4));return a+="0123456789".slice(h),a.includes(`${s.num}`)}else return"0123456789".slice(r).includes(`${s.num}`)}},P=["hp","atk","def","spe","spa","spd"],G={HP:"hp",hp:"hp",Attack:"atk",Atk:"atk",atk:"atk",Defense:"def",Def:"def",def:"def","Special Attack":"spa",SpA:"spa",SAtk:"spa",SpAtk:"spa",spa:"spa",Special:"spa",spc:"spa",Spc:"spa","Special Defense":"spd",SpD:"spd",SDef:"spd",SpDef:"spd",spd:"spd",Speed:"spe",Spe:"spe",Spd:"spe",spe:"spe"},$={hp:["HP","HP"],atk:["Atk","Attack"],def:["Def","Defense"],spa:["SpA","Special Attack"],spd:["SpD","Special Defense"],spe:["Spe","Speed"],spc:["Spc","Special"]},v=class{constructor(e){this.dex=e}calc(e,t,s=31,i,r=100,o){if(i===void 0&&(i=this.dex.gen<3?252:0),this.dex.gen<3&&(s=this.toDV(s)*2,o=void 0),e==="hp")return t===1?t:l(l(2*t+s+l(i/4)+100)*r/100+10);{let a=l(l(2*t+s+l(i/4))*r/100+5);if(o!==void 0){if(o.plus===e)return l(l(a*110,16)/100);if(o.minus===e)return l(l(a*90,16)/100)}return a}}get(e){return G[e]}display(e,t=!1){let s=G[e];return s===void 0?e:(this.dex.gen===1&&s==="spa"&&(s="spc"),$[s][+t])}fill(e,t){for(let s of P)s in e||(e[s]=t);return e}getHPDV(e){return this.toDV(e.atk===void 0?31:e.atk)%2*8+this.toDV(e.def===void 0?31:e.def)%2*4+this.toDV(e.spe===void 0?31:e.spe)%2*2+this.toDV(e.spa===void 0?31:e.spa)%2}*[Symbol.iterator](){for(let e of P)yield e}toDV(e){return Math.floor(e/2)}toIV(e){return e*2+1}};return U(W);})();
|
package/build/index.mjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
var DEFAULT_EXISTS = (d) => {
|
|
3
|
-
if (!d.exists)
|
|
4
|
-
|
|
5
|
-
if ("
|
|
6
|
-
return false;
|
|
7
|
-
if (d.kind === "Ability" && d.id === "noability")
|
|
8
|
-
return false;
|
|
3
|
+
if (!d.exists) return false;
|
|
4
|
+
if ("isNonstandard" in d && d.isNonstandard) return false;
|
|
5
|
+
if (d.kind === "Ability" && d.id === "noability") return false;
|
|
9
6
|
return !("tier" in d && ["Illegal", "Unreleased"].includes(d.tier));
|
|
10
7
|
};
|
|
11
8
|
var tr = (num, bits = 0) => bits ? (num >>> 0) % 2 ** bits : num >>> 0;
|
|
@@ -18,10 +15,8 @@ function assignWithout(a, b, exclude) {
|
|
|
18
15
|
return a;
|
|
19
16
|
}
|
|
20
17
|
function toID(text) {
|
|
21
|
-
if (text == null ? void 0 : text.id)
|
|
22
|
-
|
|
23
|
-
if (typeof text !== "string" && typeof text !== "number")
|
|
24
|
-
return "";
|
|
18
|
+
if (text == null ? void 0 : text.id) text = text.id;
|
|
19
|
+
if (typeof text !== "string" && typeof text !== "number") return "";
|
|
25
20
|
return ("" + text).toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
26
21
|
}
|
|
27
22
|
var _Generations = class _Generations {
|
|
@@ -33,10 +28,8 @@ var _Generations = class _Generations {
|
|
|
33
28
|
}
|
|
34
29
|
get(g) {
|
|
35
30
|
const gen = typeof g === "string" ? parseInt(g.slice(g.search(/\d/))) : g;
|
|
36
|
-
if (isNaN(+gen))
|
|
37
|
-
|
|
38
|
-
if (this.cache[gen])
|
|
39
|
-
return this.cache[gen];
|
|
31
|
+
if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);
|
|
32
|
+
if (this.cache[gen]) return this.cache[gen];
|
|
40
33
|
return this.cache[gen] = new Generation(this.dex.forGen(gen), (d) => this.exists(d, gen));
|
|
41
34
|
}
|
|
42
35
|
*[Symbol.iterator]() {
|
|
@@ -86,8 +79,7 @@ var Abilities = class {
|
|
|
86
79
|
*[Symbol.iterator]() {
|
|
87
80
|
for (const ability in this.dex.data.Abilities) {
|
|
88
81
|
const a = this.get(ability);
|
|
89
|
-
if (a)
|
|
90
|
-
yield a;
|
|
82
|
+
if (a) yield a;
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
};
|
|
@@ -103,8 +95,7 @@ var Items = class {
|
|
|
103
95
|
*[Symbol.iterator]() {
|
|
104
96
|
for (const item in this.dex.data.Items) {
|
|
105
97
|
const i = this.get(item);
|
|
106
|
-
if (i)
|
|
107
|
-
yield i;
|
|
98
|
+
if (i) yield i;
|
|
108
99
|
}
|
|
109
100
|
}
|
|
110
101
|
};
|
|
@@ -120,8 +111,7 @@ var Moves = class {
|
|
|
120
111
|
*[Symbol.iterator]() {
|
|
121
112
|
for (const move in this.dex.data.Moves) {
|
|
122
113
|
const m = this.get(move);
|
|
123
|
-
if (m)
|
|
124
|
-
yield m;
|
|
114
|
+
if (m) yield m;
|
|
125
115
|
}
|
|
126
116
|
}
|
|
127
117
|
};
|
|
@@ -134,19 +124,16 @@ var Species = class {
|
|
|
134
124
|
}
|
|
135
125
|
get(name) {
|
|
136
126
|
const species = this.dex.species.get(name);
|
|
137
|
-
if (!this.exists(species))
|
|
138
|
-
return void 0;
|
|
127
|
+
if (!this.exists(species)) return void 0;
|
|
139
128
|
const id = species.speciesid || species.id;
|
|
140
129
|
const cached = this.cache[id];
|
|
141
|
-
if (cached)
|
|
142
|
-
return cached;
|
|
130
|
+
if (cached) return cached;
|
|
143
131
|
return this.cache[id] = new Specie(this.dex, this.exists, species);
|
|
144
132
|
}
|
|
145
133
|
*[Symbol.iterator]() {
|
|
146
134
|
for (const species in this.dex.data.Species) {
|
|
147
135
|
const s = this.get(species);
|
|
148
|
-
if (s)
|
|
149
|
-
yield s;
|
|
136
|
+
if (s) yield s;
|
|
150
137
|
}
|
|
151
138
|
}
|
|
152
139
|
};
|
|
@@ -166,26 +153,20 @@ var _Specie = class _Specie {
|
|
|
166
153
|
if (species.abilities[1] && this.dex.abilities.get(species.abilities[1]).gen <= this.dex.gen) {
|
|
167
154
|
this.abilities[1] = species.abilities[1];
|
|
168
155
|
}
|
|
169
|
-
if (this.dex.gen >= 5 && species.abilities.H)
|
|
170
|
-
|
|
171
|
-
if (this.dex.gen >= 7 && species.abilities.S)
|
|
172
|
-
this.abilities.S = species.abilities.S;
|
|
156
|
+
if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;
|
|
157
|
+
if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;
|
|
173
158
|
} else {
|
|
174
159
|
this.abilities = { 0: "" };
|
|
175
160
|
}
|
|
176
161
|
this.evos = (_a = species.evos) == null ? void 0 : _a.filter((s) => exists(this.dex.species.get(s)));
|
|
177
162
|
this.nfe = !!((_b = this.evos) == null ? void 0 : _b.length);
|
|
178
|
-
if (!this.nfe)
|
|
179
|
-
this.evos = void 0;
|
|
163
|
+
if (!this.nfe) this.evos = void 0;
|
|
180
164
|
this.cosmeticFormes = (_c = species.cosmeticFormes) == null ? void 0 : _c.filter((s) => exists(this.dex.species.get(s)));
|
|
181
|
-
if (!((_d = this.cosmeticFormes) == null ? void 0 : _d.length))
|
|
182
|
-
this.cosmeticFormes = void 0;
|
|
165
|
+
if (!((_d = this.cosmeticFormes) == null ? void 0 : _d.length)) this.cosmeticFormes = void 0;
|
|
183
166
|
this.otherFormes = (_e = species.otherFormes) == null ? void 0 : _e.filter((s) => exists(this.dex.species.get(s)));
|
|
184
|
-
if (!((_f = this.otherFormes) == null ? void 0 : _f.length))
|
|
185
|
-
this.otherFormes = void 0;
|
|
167
|
+
if (!((_f = this.otherFormes) == null ? void 0 : _f.length)) this.otherFormes = void 0;
|
|
186
168
|
this.formeOrder = (_g = species.formeOrder) == null ? void 0 : _g.filter((s) => exists(this.dex.species.get(s)));
|
|
187
|
-
if (!this.formeOrder || this.formeOrder.length <= 1)
|
|
188
|
-
this.formeOrder = void 0;
|
|
169
|
+
if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = void 0;
|
|
189
170
|
this.formes = (_h = this.formeOrder) == null ? void 0 : _h.filter((s) => this.dex.species.get(s).isNonstandard !== "Gigantamax");
|
|
190
171
|
this.prevo = species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : void 0;
|
|
191
172
|
}
|
|
@@ -230,16 +211,14 @@ var Natures = class {
|
|
|
230
211
|
this.exists = exists;
|
|
231
212
|
}
|
|
232
213
|
get(name) {
|
|
233
|
-
if (this.dex.gen < 3)
|
|
234
|
-
return void 0;
|
|
214
|
+
if (this.dex.gen < 3) return void 0;
|
|
235
215
|
const nature = this.dex.natures.get(name);
|
|
236
216
|
return this.exists(nature) ? nature : void 0;
|
|
237
217
|
}
|
|
238
218
|
*[Symbol.iterator]() {
|
|
239
219
|
for (const nature in this.dex.data.Natures) {
|
|
240
220
|
const n = this.get(nature);
|
|
241
|
-
if (n)
|
|
242
|
-
yield n;
|
|
221
|
+
if (n) yield n;
|
|
243
222
|
}
|
|
244
223
|
}
|
|
245
224
|
};
|
|
@@ -275,21 +254,17 @@ var Types = class {
|
|
|
275
254
|
}, dex, this);
|
|
276
255
|
}
|
|
277
256
|
get(name) {
|
|
278
|
-
if (name === "???")
|
|
279
|
-
return this.unknown;
|
|
257
|
+
if (name === "???") return this.unknown;
|
|
280
258
|
const type = this.dex.types.get(name);
|
|
281
|
-
if (!this.exists(type))
|
|
282
|
-
return void 0;
|
|
259
|
+
if (!this.exists(type)) return void 0;
|
|
283
260
|
const cached = this.cache[type.id];
|
|
284
|
-
if (cached)
|
|
285
|
-
return cached;
|
|
261
|
+
if (cached) return cached;
|
|
286
262
|
return this.cache[type.id] = new Type(type, this.dex, this);
|
|
287
263
|
}
|
|
288
264
|
*[Symbol.iterator]() {
|
|
289
265
|
for (const type in this.dex.data.Types) {
|
|
290
266
|
const t = this.get(type);
|
|
291
|
-
if (t)
|
|
292
|
-
yield t;
|
|
267
|
+
if (t) yield t;
|
|
293
268
|
}
|
|
294
269
|
if (this.dex.gen >= 2 && this.dex.gen <= 4) {
|
|
295
270
|
yield this.unknown;
|
|
@@ -302,8 +277,7 @@ var Types = class {
|
|
|
302
277
|
return this.dex.getImmunity(source, target);
|
|
303
278
|
}
|
|
304
279
|
totalEffectiveness(source, target) {
|
|
305
|
-
if (!this.canDamage(source, target))
|
|
306
|
-
return 0;
|
|
280
|
+
if (!this.canDamage(source, target)) return 0;
|
|
307
281
|
const e = `${this.dex.getEffectiveness(source, target)}`;
|
|
308
282
|
return EFFECTIVENESS[e];
|
|
309
283
|
}
|
|
@@ -318,7 +292,8 @@ var Type = class {
|
|
|
318
292
|
this.effectiveness = { "???": 1 };
|
|
319
293
|
for (const k in dex.data.Types) {
|
|
320
294
|
const t = k.charAt(0).toUpperCase() + k.slice(1);
|
|
321
|
-
|
|
295
|
+
const data = dex.data.Types[k];
|
|
296
|
+
this.effectiveness[t] = DAMAGE_TAKEN[data.damageTaken[this.name] || 0];
|
|
322
297
|
}
|
|
323
298
|
}
|
|
324
299
|
canDamage(target) {
|
|
@@ -349,12 +324,10 @@ var Learnsets = class {
|
|
|
349
324
|
return this.exists(learnset) ? learnset : void 0;
|
|
350
325
|
}
|
|
351
326
|
async *[Symbol.iterator]() {
|
|
352
|
-
if (!this.dex.data.Learnsets)
|
|
353
|
-
await this.dex.learnsets.get("LOAD");
|
|
327
|
+
if (!this.dex.data.Learnsets) await this.dex.learnsets.get("LOAD");
|
|
354
328
|
for (const id in this.dex.data.Learnsets) {
|
|
355
329
|
const l = await this.get(id);
|
|
356
|
-
if (l)
|
|
357
|
-
yield l;
|
|
330
|
+
if (l) yield l;
|
|
358
331
|
}
|
|
359
332
|
}
|
|
360
333
|
async *all(species) {
|
|
@@ -375,11 +348,9 @@ var Learnsets = class {
|
|
|
375
348
|
} else {
|
|
376
349
|
id = toID(species.battleOnly || species.changesFrom || species.prevo);
|
|
377
350
|
}
|
|
378
|
-
if (!id)
|
|
379
|
-
break;
|
|
351
|
+
if (!id) break;
|
|
380
352
|
const s = this.gen.species.get(id);
|
|
381
|
-
if (!s)
|
|
382
|
-
break;
|
|
353
|
+
if (!s) break;
|
|
383
354
|
species = s;
|
|
384
355
|
learnset = await this.get(id);
|
|
385
356
|
}
|
|
@@ -388,12 +359,10 @@ var Learnsets = class {
|
|
|
388
359
|
// checks/restriction enforcement requires @pkmn/sim's TeamValidator.
|
|
389
360
|
async learnable(name, restriction) {
|
|
390
361
|
const species = this.gen.species.get(name);
|
|
391
|
-
if (!species)
|
|
392
|
-
return void 0;
|
|
362
|
+
if (!species) return void 0;
|
|
393
363
|
if (!restriction) {
|
|
394
364
|
const cached = this.cache[species.id];
|
|
395
|
-
if (cached)
|
|
396
|
-
return cached;
|
|
365
|
+
if (cached) return cached;
|
|
397
366
|
}
|
|
398
367
|
const moves = {};
|
|
399
368
|
for await (const learnset of this.all(species)) {
|
|
@@ -404,18 +373,14 @@ var Learnsets = class {
|
|
|
404
373
|
const sources = learnset.learnset[moveid];
|
|
405
374
|
if (this.isLegal(move, sources, restriction || this.gen)) {
|
|
406
375
|
const filtered = sources.filter((s) => +s.charAt(0) <= this.gen.num);
|
|
407
|
-
if (!filtered.length)
|
|
408
|
-
continue;
|
|
376
|
+
if (!filtered.length) continue;
|
|
409
377
|
if (moves[move.id]) {
|
|
410
378
|
const unique = [];
|
|
411
|
-
loop:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
continue loop;
|
|
417
|
-
unique.push(source);
|
|
418
|
-
}
|
|
379
|
+
loop: for (const source of filtered) {
|
|
380
|
+
const prefix = source.slice(0, 2);
|
|
381
|
+
for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;
|
|
382
|
+
unique.push(source);
|
|
383
|
+
}
|
|
419
384
|
moves[move.id].push(...unique);
|
|
420
385
|
} else {
|
|
421
386
|
moves[move.id] = filtered;
|
|
@@ -425,8 +390,7 @@ var Learnsets = class {
|
|
|
425
390
|
}
|
|
426
391
|
}
|
|
427
392
|
}
|
|
428
|
-
if (!restriction)
|
|
429
|
-
this.cache[species.id] = moves;
|
|
393
|
+
if (!restriction) this.cache[species.id] = moves;
|
|
430
394
|
return moves;
|
|
431
395
|
}
|
|
432
396
|
// BUG: this only covers what Pokémon Showdown deems "teambuilder legality" - proper legality
|
|
@@ -434,11 +398,9 @@ var Learnsets = class {
|
|
|
434
398
|
async canLearn(name, move, restriction) {
|
|
435
399
|
var _a;
|
|
436
400
|
const species = this.gen.species.get(name);
|
|
437
|
-
if (!species)
|
|
438
|
-
return false;
|
|
401
|
+
if (!species) return false;
|
|
439
402
|
move = typeof move === "string" && this.gen.moves.get(move) || move;
|
|
440
|
-
if (typeof move === "string")
|
|
441
|
-
return false;
|
|
403
|
+
if (typeof move === "string") return false;
|
|
442
404
|
for await (const learnset of this.all(species)) {
|
|
443
405
|
if (this.isLegal(move, (_a = learnset.learnset) == null ? void 0 : _a[move.id], restriction || this.gen)) {
|
|
444
406
|
return true;
|
|
@@ -449,19 +411,14 @@ var Learnsets = class {
|
|
|
449
411
|
// BUG: this only covers what Pokémon Showdown deems "teambuilder legality" - proper legality
|
|
450
412
|
// checks/restriction enforcement requires @pkmn/sim's TeamValidator.
|
|
451
413
|
isLegal(move, sources, gen) {
|
|
452
|
-
if (!sources)
|
|
453
|
-
return void 0;
|
|
414
|
+
if (!sources) return void 0;
|
|
454
415
|
const gens = sources.map((x) => Number(x[0]));
|
|
455
416
|
const minGen = Math.min(...gens);
|
|
456
417
|
const vcOnly = minGen === 7 && sources.every((x) => x[0] !== "7" || x === "7V") || minGen === 8 && sources.every((x) => x[0] !== "8" || x === "8V");
|
|
457
|
-
if (gen === "Pentagon")
|
|
458
|
-
|
|
459
|
-
if (gen === "
|
|
460
|
-
|
|
461
|
-
if (gen === "Galar")
|
|
462
|
-
return gens.includes(8) && !vcOnly;
|
|
463
|
-
if (gen === "Paldea")
|
|
464
|
-
return gens.includes(9);
|
|
418
|
+
if (gen === "Pentagon") return gens.includes(6);
|
|
419
|
+
if (gen === "Plus") return gens.includes(7) && !vcOnly;
|
|
420
|
+
if (gen === "Galar") return gens.includes(8) && !vcOnly;
|
|
421
|
+
if (gen === "Paldea") return gens.includes(9);
|
|
465
422
|
if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {
|
|
466
423
|
let legalGens = "";
|
|
467
424
|
let available = false;
|
|
@@ -469,14 +426,12 @@ var Learnsets = class {
|
|
|
469
426
|
legalGens += "3";
|
|
470
427
|
available = true;
|
|
471
428
|
}
|
|
472
|
-
if (available)
|
|
473
|
-
available = !GEN3_HMS.has(move.id);
|
|
429
|
+
if (available) available = !GEN3_HMS.has(move.id);
|
|
474
430
|
if (available || gens.includes(4)) {
|
|
475
431
|
legalGens += "4";
|
|
476
432
|
available = true;
|
|
477
433
|
}
|
|
478
|
-
if (available)
|
|
479
|
-
available = !GEN4_HMS.has(move.id);
|
|
434
|
+
if (available) available = !GEN4_HMS.has(move.id);
|
|
480
435
|
const minUpperGen = available ? 5 : Math.min(...gens.filter((g) => g > 4));
|
|
481
436
|
legalGens += "0123456789".slice(minUpperGen);
|
|
482
437
|
return legalGens.includes(`${gen.num}`);
|
|
@@ -527,8 +482,7 @@ var Stats = class {
|
|
|
527
482
|
this.dex = dex;
|
|
528
483
|
}
|
|
529
484
|
calc(stat, base, iv = 31, ev, level = 100, nature) {
|
|
530
|
-
if (ev === void 0)
|
|
531
|
-
ev = this.dex.gen < 3 ? 252 : 0;
|
|
485
|
+
if (ev === void 0) ev = this.dex.gen < 3 ? 252 : 0;
|
|
532
486
|
if (this.dex.gen < 3) {
|
|
533
487
|
iv = this.toDV(iv) * 2;
|
|
534
488
|
nature = void 0;
|
|
@@ -538,10 +492,8 @@ var Stats = class {
|
|
|
538
492
|
} else {
|
|
539
493
|
const val = tr(tr(2 * base + iv + tr(ev / 4)) * level / 100 + 5);
|
|
540
494
|
if (nature !== void 0) {
|
|
541
|
-
if (nature.plus === stat)
|
|
542
|
-
|
|
543
|
-
if (nature.minus === stat)
|
|
544
|
-
return tr(tr(val * 90, 16) / 100);
|
|
495
|
+
if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);
|
|
496
|
+
if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);
|
|
545
497
|
}
|
|
546
498
|
return val;
|
|
547
499
|
}
|
|
@@ -551,16 +503,13 @@ var Stats = class {
|
|
|
551
503
|
}
|
|
552
504
|
display(str, full = false) {
|
|
553
505
|
let s = NAMES[str];
|
|
554
|
-
if (s === void 0)
|
|
555
|
-
|
|
556
|
-
if (this.dex.gen === 1 && s === "spa")
|
|
557
|
-
s = "spc";
|
|
506
|
+
if (s === void 0) return str;
|
|
507
|
+
if (this.dex.gen === 1 && s === "spa") s = "spc";
|
|
558
508
|
return DISPLAY[s][+full];
|
|
559
509
|
}
|
|
560
510
|
fill(stats, val) {
|
|
561
511
|
for (const stat of STATS) {
|
|
562
|
-
if (!(stat in stats))
|
|
563
|
-
stats[stat] = val;
|
|
512
|
+
if (!(stat in stats)) stats[stat] = val;
|
|
564
513
|
}
|
|
565
514
|
return stats;
|
|
566
515
|
}
|
package/build/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n AbilityName,\n Condition,\n Data,\n Dex,\n Species as DexSpecies,\n Type as DexType,\n EggGroup,\n EvoType,\n FormeName,\n GenderName,\n GenerationNum,\n ID,\n ItemName,\n Move,\n MoveCategory,\n MoveName,\n MoveSource,\n Nature,\n Nonstandard,\n SpeciesAbility,\n SpeciesName,\n SpeciesTag,\n StatID,\n StatsTable,\n Tier,\n TypeName,\n} from '@pkmn/dex-types';\n\nconst DEFAULT_EXISTS = (d: Data) => {\n if (!d.exists) return false;\n if ('isNonstandard' in d && d.isNonstandard) return false;\n if (d.kind === 'Ability' && d.id === 'noability') return false;\n return !('tier' in d && ['Illegal', 'Unreleased'].includes(d.tier));\n};\n\nconst tr = (num: number, bits = 0) => bits ? (num >>> 0) % (2 ** bits) : num >>> 0;\n\nexport type ExistsFn = (d: Data, g: GenerationNum) => boolean;\ntype BoundExistsFn = (d: Data) => boolean;\n\nfunction assignWithout(a: {[key: string]: any}, b: {[key: string]: any}, exclude: Set<string>) {\n for (const key in b) {\n if (Object.prototype.hasOwnProperty.call(b, key) && !exclude.has(key)) {\n a[key] = b[key];\n }\n }\n return a;\n}\n\nexport function toID(text: any): ID {\n if (text?.id) text = text.id;\n if (typeof text !== 'string' && typeof text !== 'number') return '';\n return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '') as ID;\n}\n\nexport class Generations {\n /* private */ readonly cache = Object.create(null) as {[num: number]: Generation};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: ExistsFn;\n\n static DEFAULT_EXISTS = DEFAULT_EXISTS;\n\n constructor(dex: Dex, exists = Generations.DEFAULT_EXISTS) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(g: string | number) {\n // May not actually be a GenerationNum, but isNaN and Dex.forGen will validate the rest\n const gen = (typeof g === 'string' ? parseInt(g.slice(g.search(/\\d/))) : g) as GenerationNum;\n if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);\n if (this.cache[gen]) return this.cache[gen];\n return (this.cache[gen] = new Generation(this.dex.forGen(gen), d => this.exists(d, gen)));\n }\n\n *[Symbol.iterator]() {\n for (let gen = 1; gen <= 9; gen++) {\n yield this.get(gen as GenerationNum);\n }\n }\n}\n\nexport class Generation {\n readonly abilities: Abilities;\n readonly items: Items;\n readonly moves: Moves;\n readonly species: Species;\n readonly types: Types;\n readonly natures: Natures;\n readonly learnsets: Learnsets;\n readonly conditions: Conditions;\n readonly stats: Stats;\n\n readonly dex: Dex;\n\n /* private */ readonly exists: BoundExistsFn;\n\n static get(dex: Dex, g: string | number, exists = DEFAULT_EXISTS) {\n return new Generations(dex, exists).get(g);\n }\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n\n this.abilities = new Abilities(this.dex, this.exists);\n this.items = new Items(this.dex, this.exists);\n this.moves = new Moves(this.dex, this.exists);\n this.species = new Species(this.dex, this.exists);\n this.natures = new Natures(this.dex, this.exists);\n this.types = new Types(this.dex, this.exists);\n this.learnsets = new Learnsets(this, this.dex, this.exists);\n this.conditions = new Conditions(this.dex, this.exists);\n this.stats = new Stats(this.dex);\n }\n\n get num() {\n return this.dex.gen;\n }\n\n toString() {\n return `[Generation:${this.num}]`;\n }\n\n toJSON() {\n return this.toString();\n }\n}\n\nexport class Abilities {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const ability = this.dex.abilities.get(name);\n return this.exists(ability) ? ability : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const ability in this.dex.data.Abilities) {\n const a = this.get(ability);\n if (a) yield a;\n }\n }\n}\n\nexport class Items {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const item = this.dex.items.get(name);\n return this.exists(item) ? item : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const item in this.dex.data.Items) {\n const i = this.get(item);\n if (i) yield i;\n }\n }\n}\n\nexport class Moves {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const move = this.dex.moves.get(name);\n return this.exists(move) ? move : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const move in this.dex.data.Moves) {\n const m = this.get(move);\n if (m) yield m;\n }\n }\n}\n\nexport class Species {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Specie};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const species = this.dex.species.get(name);\n if (!this.exists(species)) return undefined;\n const id = (species as any).speciesid || species.id; // FIXME Event-only ability hack\n const cached = this.cache[id];\n if (cached) return cached;\n return (this.cache[id] = new Specie(this.dex, this.exists, species));\n }\n\n *[Symbol.iterator]() {\n for (const species in this.dex.data.Species) {\n const s = this.get(species);\n if (s) yield s;\n }\n }\n}\n\nexport class Specie implements DexSpecies {\n readonly id!: ID;\n readonly name!: SpeciesName;\n readonly fullname!: string;\n readonly exists!: boolean;\n readonly num!: number;\n readonly gen!: GenerationNum;\n readonly shortDesc!: string;\n readonly desc!: string;\n readonly isNonstandard!: Nonstandard | null;\n readonly duration?: number;\n\n readonly effectType!: 'Pokemon';\n readonly kind!: 'Species';\n readonly baseStats!: StatsTable;\n readonly baseSpecies!: SpeciesName;\n readonly baseForme!: FormeName | '';\n readonly forme!: FormeName | '';\n readonly abilities!: SpeciesAbility<AbilityName | ''>;\n readonly types!: [TypeName] | [TypeName, TypeName];\n readonly prevo?: SpeciesName | '';\n readonly evos?: SpeciesName[];\n readonly nfe: boolean;\n readonly eggGroups!: EggGroup[];\n readonly weightkg!: number;\n readonly weighthg!: number;\n readonly tags!: SpeciesTag[];\n readonly unreleasedHidden!: boolean | 'Past';\n readonly maleOnlyHidden!: boolean;\n readonly inheritsFrom!: ID;\n readonly tier!: Tier.Singles | Tier.Other;\n readonly doublesTier!: Tier.Doubles;\n\n readonly changesFrom?: SpeciesName;\n readonly cosmeticFormes?: SpeciesName[];\n readonly otherFormes?: SpeciesName[];\n readonly formeOrder?: SpeciesName[];\n readonly formes?: SpeciesName[];\n readonly genderRatio: {M: number; F: number};\n readonly isMega?: boolean;\n readonly isPrimal?: boolean;\n readonly battleOnly?: SpeciesName | SpeciesName[];\n readonly canGigantamax?: MoveName;\n readonly gmaxUnreleased?: boolean;\n readonly cannotDynamax?: boolean;\n readonly requiredAbility?: AbilityName;\n readonly requiredItem?: ItemName;\n readonly requiredItems?: ItemName[];\n readonly requiredMove?: MoveName;\n readonly gender?: GenderName;\n readonly maxHP?: number;\n readonly evoMove?: MoveName;\n readonly evoItem?: string;\n readonly evoRegion?: 'Alola' | 'Galar';\n readonly evoLevel?: number;\n readonly evoCondition?: string;\n readonly evoType?: EvoType;\n readonly condition?: Partial<Condition>;\n readonly canHatch!: boolean;\n\n /* private */ readonly dex: Dex;\n\n /* private */ static readonly EXCLUDE = new Set([\n 'abilities', 'cosmeticFormes', 'evos', 'formeOrder',\n 'gender', 'genderRatio', 'nfe', 'otherFormes', 'prevo',\n ]);\n\n constructor(dex: Dex, exists: BoundExistsFn, species: DexSpecies) {\n assignWithout(this, species, Specie.EXCLUDE);\n this.dex = dex;\n if (this.dex.gen >= 2) {\n this.gender = species.gender;\n this.genderRatio = species.genderRatio;\n } else {\n this.genderRatio = {M: 0, F: 0};\n }\n if (this.dex.gen >= 3) {\n this.abilities = {0: species.abilities[0]};\n // \"because PS\", Pokemon have the abilities that were added in Gen 4 in Gen 3 :bigthonk:\n if (species.abilities[1] &&\n this.dex.abilities.get(species.abilities[1]).gen <= this.dex.gen) {\n this.abilities[1] = species.abilities[1];\n }\n if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;\n if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;\n } else {\n this.abilities = {0: ''};\n }\n this.evos = species.evos?.filter(s => exists(this.dex.species.get(s)));\n this.nfe = !!this.evos?.length;\n if (!this.nfe) this.evos = undefined;\n this.cosmeticFormes = species.cosmeticFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.cosmeticFormes?.length) this.cosmeticFormes = undefined;\n this.otherFormes = species.otherFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.otherFormes?.length) this.otherFormes = undefined;\n this.formeOrder = species.formeOrder?.filter(s => exists(this.dex.species.get(s)));\n if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = undefined;\n this.formes = this.formeOrder?.filter(s =>\n this.dex.species.get(s).isNonstandard !== 'Gigantamax');\n this.prevo =\n species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : undefined;\n }\n\n get formeNum() {\n return (this.baseSpecies === this.name\n ? this.formeOrder ? this.formeOrder.findIndex(name => name === this.name) : 0\n : this.dex.species.get(this.baseSpecies).formeOrder!.findIndex(\n name => name === (this.isNonstandard === 'Gigantamax' ? this.baseSpecies : this.name)\n ));\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['dex']));\n }\n}\n\nexport class Conditions {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const condition = this.dex.conditions.get(name);\n return this.exists(condition) ? condition : undefined;\n }\n}\n\nexport class Natures {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n if (this.dex.gen < 3) return undefined;\n const nature = this.dex.natures.get(name);\n return this.exists(nature) ? nature : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const nature in this.dex.data.Natures) {\n const n = this.get(nature);\n if (n) yield n;\n }\n }\n}\n\nconst EFFECTIVENESS = {\n '-3': 0.125,\n '-2': 0.25,\n '-1': 0.5,\n '0': 1,\n '1': 2,\n '2': 4,\n '3': 8,\n};\n\ntype TypeTarget = {getTypes: () => TypeName[]} | {types: TypeName[]} | TypeName[] | TypeName;\n\nexport class Types {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Type};\n\n /* private */ readonly unknown: Type;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n // PS doesn't contain data for the '???' type\n this.unknown = new Type({\n effectType: 'Type',\n kind: 'Type',\n // Regrettably PS ID's can't represent '???'\n id: '',\n name: '???',\n // Technically this only exists as a true type in Gens 2-4, but there are moves dealing\n // typeless damage in Gen 1 so we include it there.\n exists: dex.gen <= 4,\n gen: 1,\n // This gets filled in for us by Type's constructor\n damageTaken: {} as {[t in Exclude<TypeName, '???'>]: number},\n HPivs: {},\n HPdvs: {},\n }, dex, this);\n }\n\n get(name: string) {\n if (name === '???') return this.unknown;\n const type = this.dex.types.get(name);\n if (!this.exists(type)) return undefined;\n const cached = this.cache[type.id];\n if (cached) return cached;\n return (this.cache[type.id] = new Type(type, this.dex, this));\n }\n\n *[Symbol.iterator]() {\n for (const type in this.dex.data.Types) {\n const t = this.get(type);\n if (t) yield t;\n }\n if (this.dex.gen >= 2 && this.dex.gen <= 4) {\n yield this.unknown;\n }\n }\n\n getHiddenPower(ivs: StatsTable) {\n return this.dex.getHiddenPower(ivs);\n }\n\n canDamage(source: {type: TypeName} | TypeName, target: TypeTarget) {\n return this.dex.getImmunity(source, target);\n }\n\n totalEffectiveness(source: {type: TypeName} | TypeName, target: TypeTarget) {\n if (!this.canDamage(source, target)) return 0;\n const e = `${this.dex.getEffectiveness(source, target)}`;\n // convert from PS's ridiculous encoding to something usable\n return EFFECTIVENESS[e as keyof typeof EFFECTIVENESS];\n }\n}\n\nexport type TypeEffectiveness = 0 | 0.5 | 1 | 2;\n\nconst DAMAGE_TAKEN = [1, 2, 0.5, 0] as TypeEffectiveness[];\nconst SPECIAL = ['Fire', 'Water', 'Grass', 'Electric', 'Ice', 'Psychic', 'Dark', 'Dragon'];\n\nexport class Type {\n readonly id!: ID;\n readonly name!: TypeName;\n readonly effectType!: 'Type';\n readonly kind!: 'Type';\n readonly exists!: boolean;\n readonly gen!: GenerationNum;\n readonly effectiveness: {[t in TypeName]: TypeEffectiveness};\n readonly HPivs!: Partial<StatsTable>;\n readonly HPdvs!: Partial<StatsTable>;\n readonly category?: Exclude<MoveCategory, 'Status'>;\n\n /* private */ readonly types: Types;\n\n constructor(type: DexType, dex: Dex, types: Types) {\n Object.assign(this, type);\n this.types = types;\n this.category =\n this.name === 'Fairy' ? undefined : SPECIAL.includes(this.name) ? 'Special' : 'Physical';\n // convert from PS's ridiculous encoding to something usable (plus damage taken -> dealt)\n this.effectiveness = {'???': 1} as {[t in TypeName]: TypeEffectiveness};\n for (const k in dex.data.Types) {\n const t = k.charAt(0).toUpperCase() + k.slice(1) as Exclude<TypeName, '???'>;\n this.effectiveness[t] = DAMAGE_TAKEN[dex.data.Types[k].damageTaken[this.name] || 0];\n }\n }\n\n canDamage(target: TypeTarget) {\n return this.types.canDamage(this.name, target);\n }\n\n totalEffectiveness(target: TypeTarget) {\n return this.types.totalEffectiveness(this.name, target);\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['types']));\n }\n}\n\nconst GEN3_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'flash', 'rocksmash', 'waterfall', 'dive'] as ID[]);\n// NOTE: Whirlpool and Defog are Gen 4 HMs but the HMs differ in DPPt vs. HGSS\nconst GEN4_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'rocksmash', 'waterfall', 'rockclimb'] as ID[]);\n\ntype Restriction = 'Pentagon' | 'Plus' | 'Galar' | 'Paldea';\n\nexport class Learnsets {\n /* private */ readonly cache = Object.create(null) as {\n [speciesid: string]: {[moveid: string]: MoveSource[]};\n };\n\n /* private */ readonly gen: Generation;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(gen: Generation, dex: Dex, exists: BoundExistsFn) {\n this.gen = gen;\n this.dex = dex;\n this.exists = exists;\n }\n\n async get(name: string) {\n const learnset = await this.dex.learnsets.get(toID(name));\n return this.exists(learnset) ? learnset : undefined;\n }\n\n async *[Symbol.iterator]() {\n if (!this.dex.data.Learnsets) await this.dex.learnsets.get('LOAD' as ID);\n for (const id in this.dex.data.Learnsets) {\n const l = await this.get(id);\n if (l) yield l;\n }\n }\n\n async* all(species: Specie) {\n let id = species.id;\n let learnset = await this.get(id);\n if (!learnset) {\n id = typeof species.battleOnly === 'string' && species.battleOnly !== species.baseSpecies\n ? toID(species.battleOnly)\n : toID(species.baseSpecies);\n learnset = await this.get(id);\n }\n\n while (learnset) {\n yield learnset;\n\n if (id === 'lycanrocdusk' || (species.id === 'rockruff' && id === 'rockruff')) {\n id = 'rockruffdusk' as ID;\n } else if (species.id === 'gastrodoneast') {\n id = 'gastrodon' as ID;\n } else if (species.id === 'pumpkaboosuper') {\n id = 'pumpkaboo' as ID;\n } else {\n id = toID(species.battleOnly || species.changesFrom || species.prevo);\n }\n\n if (!id) break;\n const s = this.gen.species.get(id);\n if (!s) break;\n species = s;\n learnset = await this.get(id);\n }\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async learnable(name: string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return undefined;\n\n if (!restriction) {\n const cached = this.cache[species.id];\n if (cached) return cached;\n }\n\n const moves: {[moveid: string]: MoveSource[]} = {};\n\n for await (const learnset of this.all(species)) {\n if (learnset.learnset) {\n for (const moveid in learnset.learnset) {\n const move = this.gen.moves.get(moveid);\n if (move) {\n const sources = learnset.learnset[moveid];\n if (this.isLegal(move, sources, restriction || this.gen)) {\n const filtered = sources.filter(s => +s.charAt(0) <= this.gen.num);\n if (!filtered.length) continue;\n if (moves[move.id]) {\n // If we simply add filtered to moves[move.id] we may end up with some duplicates or\n // situations where we have mixed learnset information. We assume that while\n // moves[move.id] and filtered are already deduped, their union might not be, and\n // thus iterate through looking for unique prefixes. For efficiency, instead of\n // appending each deduped source from filtered to moves[move.id] immediately and\n // making each subsequent iteration longer we make a list of the unique sources to\n // add at the end. This is only safe given our assumption that filtered is unique\n // internally to begin with.\n const unique = [];\n // These lists are all expected to be short arrays so this O(n^2) linear searching\n // is still expected to be faster runtime-wise than a more sophisticated approach\n loop: for (const source of filtered) {\n const prefix = source.slice(0, 2);\n // sadly Babel chokes on using an .every(...) here due to throwIfClosureRequired\n for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;\n unique.push(source);\n }\n moves[move.id].push(...unique);\n } else {\n moves[move.id] = filtered;\n }\n }\n }\n }\n }\n }\n\n if (!restriction) this.cache[species.id] = moves;\n return moves;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async canLearn(name: string, move: Move | string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return false;\n\n move = typeof move === 'string' && this.gen.moves.get(move) || move;\n if (typeof move === 'string') return false;\n\n for await (const learnset of this.all(species)) {\n if (this.isLegal(move, learnset.learnset?.[move.id], restriction || this.gen)) {\n return true;\n }\n }\n\n return false;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n isLegal(move: Move, sources: MoveSource[] | undefined, gen: Generation | Restriction) {\n if (!sources) return undefined;\n\n const gens = sources.map(x => Number(x[0]));\n const minGen = Math.min(...gens);\n const vcOnly = (\n minGen === 7 && sources.every(x => x[0] !== '7' || x === '7V') ||\n minGen === 8 && sources.every(x => x[0] !== '8' || x === '8V')\n );\n\n if (gen === 'Pentagon') return gens.includes(6);\n if (gen === 'Plus') return gens.includes(7) && !vcOnly;\n if (gen === 'Galar') return gens.includes(8) && !vcOnly;\n if (gen === 'Paldea') return gens.includes(9);\n\n if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {\n let legalGens = '';\n let available = false;\n\n if (minGen === 3) {\n legalGens += '3';\n available = true;\n }\n if (available) available = !GEN3_HMS.has(move.id);\n\n if (available || gens.includes(4)) {\n legalGens += '4';\n available = true;\n }\n if (available) available = !GEN4_HMS.has(move.id);\n\n const minUpperGen = available ? 5 : Math.min(...gens.filter(g => g > 4));\n legalGens += '0123456789'.slice(minUpperGen);\n return legalGens.includes(`${gen.num}`);\n } else {\n return '0123456789'.slice(minGen).includes(`${gen.num}`);\n }\n }\n}\n\nconst STATS = ['hp', 'atk', 'def', 'spe', 'spa', 'spd'] as const;\n\nconst NAMES: Readonly<{[name: string]: StatID}> = {\n HP: 'hp', hp: 'hp',\n Attack: 'atk', Atk: 'atk', atk: 'atk',\n Defense: 'def', Def: 'def', def: 'def',\n 'Special Attack': 'spa', SpA: 'spa', SAtk: 'spa', SpAtk: 'spa', spa: 'spa',\n Special: 'spa', spc: 'spa', Spc: 'spa',\n 'Special Defense': 'spd', SpD: 'spd', SDef: 'spd', SpDef: 'spd', spd: 'spd',\n Speed: 'spe', Spe: 'spe', Spd: 'spe', spe: 'spe',\n};\n\nconst DISPLAY: Readonly<{[stat: string]: Readonly<[string, string]>}> = {\n hp: ['HP', 'HP'],\n atk: ['Atk', 'Attack'],\n def: ['Def', 'Defense'],\n spa: ['SpA', 'Special Attack'],\n spd: ['SpD', 'Special Defense'],\n spe: ['Spe', 'Speed'],\n spc: ['Spc', 'Special'],\n};\n\nexport class Stats {\n /* private */ readonly dex: Dex;\n\n constructor(dex: Dex) {\n this.dex = dex;\n }\n\n calc(stat: StatID, base: number, iv = 31, ev?: number, level = 100, nature?: Nature) {\n if (ev === undefined) ev = this.dex.gen < 3 ? 252 : 0;\n if (this.dex.gen < 3) {\n iv = this.toDV(iv) * 2;\n nature = undefined;\n }\n if (stat === 'hp') {\n return base === 1 ? base : tr(tr(2 * base + iv + tr(ev / 4) + 100) * level / 100 + 10);\n } else {\n const val = tr(tr(2 * base + iv + tr(ev / 4)) * level / 100 + 5);\n if (nature !== undefined) {\n if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);\n if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);\n }\n return val;\n }\n }\n\n get(s: string): StatID | undefined {\n return NAMES[s];\n }\n\n display(str: string, full = false): string {\n let s: StatID | 'spc' | undefined = NAMES[str];\n if (s === undefined) return str;\n if (this.dex.gen === 1 && s === 'spa') s = 'spc';\n return DISPLAY[s][+full];\n }\n\n fill<T>(stats: Partial<StatsTable<T>>, val: T): StatsTable<T> {\n for (const stat of STATS) {\n if (!(stat in stats)) stats[stat] = val;\n }\n return stats as StatsTable<T>;\n }\n\n getHPDV(ivs: Partial<StatsTable>): number {\n return (\n (this.toDV(ivs.atk === undefined ? 31 : ivs.atk) % 2) * 8 +\n (this.toDV(ivs.def === undefined ? 31 : ivs.def) % 2) * 4 +\n (this.toDV(ivs.spe === undefined ? 31 : ivs.spe) % 2) * 2 +\n (this.toDV(ivs.spa === undefined ? 31 : ivs.spa) % 2)\n );\n }\n\n *[Symbol.iterator](): IterableIterator<StatID> {\n for (const s of STATS) {\n yield s;\n }\n }\n\n toDV(iv: number): number {\n return Math.floor(iv / 2);\n }\n\n toIV(dv: number): number {\n return dv * 2 + 1;\n }\n}\n\nexport type {\n ID,\n As,\n Weather,\n FieldCondition,\n SideCondition,\n GenerationNum,\n GenderName,\n StatID,\n StatsTable,\n BoostID,\n BoostsTable,\n MoveCategory,\n MoveTarget,\n Nonstandard,\n EvoType,\n EggGroup,\n SideID,\n Player,\n GameType,\n HPColor,\n StatusName,\n NatureName,\n TypeName,\n HPTypeName,\n Tier,\n PokemonSet,\n AbilityName,\n ItemName,\n MoveName,\n SpeciesName,\n FormeName,\n EffectType,\n Effect,\n DataKind,\n Data,\n EffectData,\n HitEffect,\n SecondaryEffect,\n ConditionData,\n AbilityData,\n ItemData,\n MoveData,\n SpeciesData,\n MoveSource,\n EventInfoData,\n LearnsetData,\n TypeData,\n NatureData,\n BasicEffect,\n Condition,\n Ability,\n Item,\n Move,\n // Species,\n EventInfo,\n Learnset,\n // Type,\n Nature,\n GenID,\n Dex,\n} from '@pkmn/dex-types';\n"],"mappings":";AA6BA,IAAM,iBAAiB,CAAC,MAAY;AAClC,MAAI,CAAC,EAAE;AAAQ,WAAO;AACtB,MAAI,mBAAmB,KAAK,EAAE;AAAe,WAAO;AACpD,MAAI,EAAE,SAAS,aAAa,EAAE,OAAO;AAAa,WAAO;AACzD,SAAO,EAAE,UAAU,KAAK,CAAC,WAAW,YAAY,EAAE,SAAS,EAAE,IAAI;AACnE;AAEA,IAAM,KAAK,CAAC,KAAa,OAAO,MAA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AAK,OAAO;AACrB,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,KAAK,IAAoB;AACvB,WAAO,KAAK,MAAM,KAAK,CAAC;AAAA,EAC1B;AAAA,EAEA,KAAK,IAAoB;AACvB,WAAO,KAAK,IAAI;AAAA,EAClB;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import {\n AbilityName,\n Condition,\n Data,\n Dex,\n Species as DexSpecies,\n Type as DexType,\n EggGroup,\n EvoType,\n FormeName,\n GenderName,\n GenerationNum,\n ID,\n ItemName,\n Move,\n MoveCategory,\n MoveName,\n MoveSource,\n Nature,\n Nonstandard,\n SpeciesAbility,\n SpeciesName,\n SpeciesTag,\n StatID,\n StatsTable,\n Tier,\n TypeName,\n} from '@pkmn/dex-types';\n\nconst DEFAULT_EXISTS = (d: Data) => {\n if (!d.exists) return false;\n if ('isNonstandard' in d && d.isNonstandard) return false;\n if (d.kind === 'Ability' && d.id === 'noability') return false;\n return !('tier' in d && ['Illegal', 'Unreleased'].includes(d.tier));\n};\n\nconst tr = (num: number, bits = 0) => bits ? (num >>> 0) % (2 ** bits) : num >>> 0;\n\nexport type ExistsFn = (d: Data, g: GenerationNum) => boolean;\ntype BoundExistsFn = (d: Data) => boolean;\n\nfunction assignWithout(a: {[key: string]: any}, b: {[key: string]: any}, exclude: Set<string>) {\n for (const key in b) {\n if (Object.prototype.hasOwnProperty.call(b, key) && !exclude.has(key)) {\n a[key] = b[key];\n }\n }\n return a;\n}\n\nexport function toID(text: any): ID {\n if (text?.id) text = text.id;\n if (typeof text !== 'string' && typeof text !== 'number') return '';\n return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '') as ID;\n}\n\nexport class Generations {\n /* private */ readonly cache = Object.create(null) as {[num: number]: Generation};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: ExistsFn;\n\n static DEFAULT_EXISTS = DEFAULT_EXISTS;\n\n constructor(dex: Dex, exists = Generations.DEFAULT_EXISTS) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(g: string | number) {\n // May not actually be a GenerationNum, but isNaN and Dex.forGen will validate the rest\n const gen = (typeof g === 'string' ? parseInt(g.slice(g.search(/\\d/))) : g) as GenerationNum;\n if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);\n if (this.cache[gen]) return this.cache[gen];\n return (this.cache[gen] = new Generation(this.dex.forGen(gen), d => this.exists(d, gen)));\n }\n\n *[Symbol.iterator]() {\n for (let gen = 1; gen <= 9; gen++) {\n yield this.get(gen as GenerationNum);\n }\n }\n}\n\nexport class Generation {\n readonly abilities: Abilities;\n readonly items: Items;\n readonly moves: Moves;\n readonly species: Species;\n readonly types: Types;\n readonly natures: Natures;\n readonly learnsets: Learnsets;\n readonly conditions: Conditions;\n readonly stats: Stats;\n\n readonly dex: Dex;\n\n /* private */ readonly exists: BoundExistsFn;\n\n static get(dex: Dex, g: string | number, exists = DEFAULT_EXISTS) {\n return new Generations(dex, exists).get(g);\n }\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n\n this.abilities = new Abilities(this.dex, this.exists);\n this.items = new Items(this.dex, this.exists);\n this.moves = new Moves(this.dex, this.exists);\n this.species = new Species(this.dex, this.exists);\n this.natures = new Natures(this.dex, this.exists);\n this.types = new Types(this.dex, this.exists);\n this.learnsets = new Learnsets(this, this.dex, this.exists);\n this.conditions = new Conditions(this.dex, this.exists);\n this.stats = new Stats(this.dex);\n }\n\n get num() {\n return this.dex.gen;\n }\n\n toString() {\n return `[Generation:${this.num}]`;\n }\n\n toJSON() {\n return this.toString();\n }\n}\n\nexport class Abilities {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const ability = this.dex.abilities.get(name);\n return this.exists(ability) ? ability : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const ability in this.dex.data.Abilities) {\n const a = this.get(ability);\n if (a) yield a;\n }\n }\n}\n\nexport class Items {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const item = this.dex.items.get(name);\n return this.exists(item) ? item : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const item in this.dex.data.Items) {\n const i = this.get(item);\n if (i) yield i;\n }\n }\n}\n\nexport class Moves {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const move = this.dex.moves.get(name);\n return this.exists(move) ? move : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const move in this.dex.data.Moves) {\n const m = this.get(move);\n if (m) yield m;\n }\n }\n}\n\nexport class Species {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Specie};\n\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const species = this.dex.species.get(name);\n if (!this.exists(species)) return undefined;\n const id = (species as any).speciesid || species.id; // FIXME Event-only ability hack\n const cached = this.cache[id];\n if (cached) return cached;\n return (this.cache[id] = new Specie(this.dex, this.exists, species));\n }\n\n *[Symbol.iterator]() {\n for (const species in this.dex.data.Species) {\n const s = this.get(species);\n if (s) yield s;\n }\n }\n}\n\nexport class Specie implements DexSpecies {\n readonly id!: ID;\n readonly name!: SpeciesName;\n readonly fullname!: string;\n readonly exists!: boolean;\n readonly num!: number;\n readonly gen!: GenerationNum;\n readonly shortDesc!: string;\n readonly desc!: string;\n readonly isNonstandard!: Nonstandard | null;\n readonly duration?: number;\n\n readonly effectType!: 'Pokemon';\n readonly kind!: 'Species';\n readonly baseStats!: StatsTable;\n readonly baseSpecies!: SpeciesName;\n readonly baseForme!: FormeName | '';\n readonly forme!: FormeName | '';\n readonly abilities!: SpeciesAbility<AbilityName | ''>;\n readonly types!: [TypeName] | [TypeName, TypeName];\n readonly prevo?: SpeciesName | '';\n readonly evos?: SpeciesName[];\n readonly nfe: boolean;\n readonly eggGroups!: EggGroup[];\n readonly weightkg!: number;\n readonly weighthg!: number;\n readonly tags!: SpeciesTag[];\n readonly unreleasedHidden!: boolean | 'Past';\n readonly maleOnlyHidden!: boolean;\n readonly inheritsFrom!: ID;\n readonly tier!: Tier.Singles | Tier.Other;\n readonly doublesTier!: Tier.Doubles;\n\n readonly changesFrom?: SpeciesName;\n readonly cosmeticFormes?: SpeciesName[];\n readonly otherFormes?: SpeciesName[];\n readonly formeOrder?: SpeciesName[];\n readonly formes?: SpeciesName[];\n readonly genderRatio: {M: number; F: number};\n readonly isMega?: boolean;\n readonly isPrimal?: boolean;\n readonly battleOnly?: SpeciesName | SpeciesName[];\n readonly canGigantamax?: MoveName;\n readonly gmaxUnreleased?: boolean;\n readonly cannotDynamax?: boolean;\n readonly requiredAbility?: AbilityName;\n readonly requiredItem?: ItemName;\n readonly requiredItems?: ItemName[];\n readonly requiredMove?: MoveName;\n readonly gender?: GenderName;\n readonly maxHP?: number;\n readonly evoMove?: MoveName;\n readonly evoItem?: string;\n readonly evoRegion?: 'Alola' | 'Galar';\n readonly evoLevel?: number;\n readonly evoCondition?: string;\n readonly evoType?: EvoType;\n readonly condition?: Partial<Condition>;\n readonly canHatch!: boolean;\n\n /* private */ readonly dex: Dex;\n\n /* private */ static readonly EXCLUDE = new Set([\n 'abilities', 'cosmeticFormes', 'evos', 'formeOrder',\n 'gender', 'genderRatio', 'nfe', 'otherFormes', 'prevo',\n ]);\n\n constructor(dex: Dex, exists: BoundExistsFn, species: DexSpecies) {\n assignWithout(this, species, Specie.EXCLUDE);\n this.dex = dex;\n if (this.dex.gen >= 2) {\n this.gender = species.gender;\n this.genderRatio = species.genderRatio;\n } else {\n this.genderRatio = {M: 0, F: 0};\n }\n if (this.dex.gen >= 3) {\n this.abilities = {0: species.abilities[0]};\n // \"because PS\", Pokemon have the abilities that were added in Gen 4 in Gen 3 :bigthonk:\n if (species.abilities[1] &&\n this.dex.abilities.get(species.abilities[1]).gen <= this.dex.gen) {\n this.abilities[1] = species.abilities[1];\n }\n if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;\n if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;\n } else {\n this.abilities = {0: ''};\n }\n this.evos = species.evos?.filter(s => exists(this.dex.species.get(s)));\n this.nfe = !!this.evos?.length;\n if (!this.nfe) this.evos = undefined;\n this.cosmeticFormes = species.cosmeticFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.cosmeticFormes?.length) this.cosmeticFormes = undefined;\n this.otherFormes = species.otherFormes?.filter(s => exists(this.dex.species.get(s)));\n if (!this.otherFormes?.length) this.otherFormes = undefined;\n this.formeOrder = species.formeOrder?.filter(s => exists(this.dex.species.get(s)));\n if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = undefined;\n this.formes = this.formeOrder?.filter(s =>\n this.dex.species.get(s).isNonstandard !== 'Gigantamax');\n this.prevo =\n species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : undefined;\n }\n\n get formeNum() {\n return (this.baseSpecies === this.name\n ? this.formeOrder ? this.formeOrder.findIndex(name => name === this.name) : 0\n : this.dex.species.get(this.baseSpecies).formeOrder!.findIndex(\n name => name === (this.isNonstandard === 'Gigantamax' ? this.baseSpecies : this.name)\n ));\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['dex']));\n }\n}\n\nexport class Conditions {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n const condition = this.dex.conditions.get(name);\n return this.exists(condition) ? condition : undefined;\n }\n}\n\nexport class Natures {\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n }\n\n get(name: string) {\n if (this.dex.gen < 3) return undefined;\n const nature = this.dex.natures.get(name);\n return this.exists(nature) ? nature : undefined;\n }\n\n *[Symbol.iterator]() {\n for (const nature in this.dex.data.Natures) {\n const n = this.get(nature);\n if (n) yield n;\n }\n }\n}\n\nconst EFFECTIVENESS = {\n '-3': 0.125,\n '-2': 0.25,\n '-1': 0.5,\n '0': 1,\n '1': 2,\n '2': 4,\n '3': 8,\n};\n\ntype TypeTarget = {getTypes: () => TypeName[]} | {types: TypeName[]} | TypeName[] | TypeName;\n\nexport class Types {\n /* private */ readonly cache = Object.create(null) as {[id: string]: Type};\n\n /* private */ readonly unknown: Type;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(dex: Dex, exists: BoundExistsFn) {\n this.dex = dex;\n this.exists = exists;\n // PS doesn't contain data for the '???' type\n this.unknown = new Type({\n effectType: 'Type',\n kind: 'Type',\n // Regrettably PS ID's can't represent '???'\n id: '',\n name: '???',\n // Technically this only exists as a true type in Gens 2-4, but there are moves dealing\n // typeless damage in Gen 1 so we include it there.\n exists: dex.gen <= 4,\n gen: 1,\n // This gets filled in for us by Type's constructor\n damageTaken: {} as {[t in Exclude<TypeName, '???'>]: number},\n HPivs: {},\n HPdvs: {},\n }, dex, this);\n }\n\n get(name: string) {\n if (name === '???') return this.unknown;\n const type = this.dex.types.get(name);\n if (!this.exists(type)) return undefined;\n const cached = this.cache[type.id];\n if (cached) return cached;\n return (this.cache[type.id] = new Type(type, this.dex, this));\n }\n\n *[Symbol.iterator]() {\n for (const type in this.dex.data.Types) {\n const t = this.get(type);\n if (t) yield t;\n }\n if (this.dex.gen >= 2 && this.dex.gen <= 4) {\n yield this.unknown;\n }\n }\n\n getHiddenPower(ivs: StatsTable) {\n return this.dex.getHiddenPower(ivs);\n }\n\n canDamage(source: {type: TypeName} | TypeName, target: TypeTarget) {\n return this.dex.getImmunity(source, target);\n }\n\n totalEffectiveness(source: {type: TypeName} | TypeName, target: TypeTarget) {\n if (!this.canDamage(source, target)) return 0;\n const e = `${this.dex.getEffectiveness(source, target)}`;\n // convert from PS's ridiculous encoding to something usable\n return EFFECTIVENESS[e as keyof typeof EFFECTIVENESS];\n }\n}\n\nexport type TypeEffectiveness = 0 | 0.5 | 1 | 2;\n\nconst DAMAGE_TAKEN = [1, 2, 0.5, 0] as TypeEffectiveness[];\nconst SPECIAL = ['Fire', 'Water', 'Grass', 'Electric', 'Ice', 'Psychic', 'Dark', 'Dragon'];\n\nexport class Type {\n readonly id!: ID;\n readonly name!: TypeName;\n readonly effectType!: 'Type';\n readonly kind!: 'Type';\n readonly exists!: boolean;\n readonly gen!: GenerationNum;\n readonly effectiveness: {[t in TypeName]: TypeEffectiveness};\n readonly HPivs!: Partial<StatsTable>;\n readonly HPdvs!: Partial<StatsTable>;\n readonly category?: Exclude<MoveCategory, 'Status'>;\n\n /* private */ readonly types: Types;\n\n constructor(type: DexType, dex: Dex, types: Types) {\n Object.assign(this, type);\n this.types = types;\n this.category =\n this.name === 'Fairy' ? undefined : SPECIAL.includes(this.name) ? 'Special' : 'Physical';\n // convert from PS's ridiculous encoding to something usable (plus damage taken -> dealt)\n this.effectiveness = {'???': 1} as {[t in TypeName]: TypeEffectiveness};\n for (const k in dex.data.Types) {\n const t = k.charAt(0).toUpperCase() + k.slice(1) as Exclude<TypeName, '???'>;\n const data = dex.data.Types[k as Lowercase<string>];\n this.effectiveness[t] = DAMAGE_TAKEN[data.damageTaken[this.name] || 0];\n }\n }\n\n canDamage(target: TypeTarget) {\n return this.types.canDamage(this.name, target);\n }\n\n totalEffectiveness(target: TypeTarget) {\n return this.types.totalEffectiveness(this.name, target);\n }\n\n toString() {\n return this.name;\n }\n\n toJSON() {\n return assignWithout({}, this, new Set(['types']));\n }\n}\n\nconst GEN3_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'flash', 'rocksmash', 'waterfall', 'dive'] as ID[]);\n// NOTE: Whirlpool and Defog are Gen 4 HMs but the HMs differ in DPPt vs. HGSS\nconst GEN4_HMS =\n new Set(['cut', 'fly', 'surf', 'strength', 'rocksmash', 'waterfall', 'rockclimb'] as ID[]);\n\ntype Restriction = 'Pentagon' | 'Plus' | 'Galar' | 'Paldea';\n\nexport class Learnsets {\n /* private */ readonly cache = Object.create(null) as {\n [speciesid: string]: {[moveid: string]: MoveSource[]};\n };\n\n /* private */ readonly gen: Generation;\n /* private */ readonly dex: Dex;\n /* private */ readonly exists: BoundExistsFn;\n\n constructor(gen: Generation, dex: Dex, exists: BoundExistsFn) {\n this.gen = gen;\n this.dex = dex;\n this.exists = exists;\n }\n\n async get(name: string) {\n const learnset = await this.dex.learnsets.get(toID(name));\n return this.exists(learnset) ? learnset : undefined;\n }\n\n async *[Symbol.iterator]() {\n if (!this.dex.data.Learnsets) await this.dex.learnsets.get('LOAD' as ID);\n for (const id in this.dex.data.Learnsets) {\n const l = await this.get(id);\n if (l) yield l;\n }\n }\n\n async* all(species: Specie) {\n let id = species.id;\n let learnset = await this.get(id);\n if (!learnset) {\n id = typeof species.battleOnly === 'string' && species.battleOnly !== species.baseSpecies\n ? toID(species.battleOnly)\n : toID(species.baseSpecies);\n learnset = await this.get(id);\n }\n\n while (learnset) {\n yield learnset;\n\n if (id === 'lycanrocdusk' || (species.id === 'rockruff' && id === 'rockruff')) {\n id = 'rockruffdusk' as ID;\n } else if (species.id === 'gastrodoneast') {\n id = 'gastrodon' as ID;\n } else if (species.id === 'pumpkaboosuper') {\n id = 'pumpkaboo' as ID;\n } else {\n id = toID(species.battleOnly || species.changesFrom || species.prevo);\n }\n\n if (!id) break;\n const s = this.gen.species.get(id);\n if (!s) break;\n species = s;\n learnset = await this.get(id);\n }\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async learnable(name: string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return undefined;\n\n if (!restriction) {\n const cached = this.cache[species.id];\n if (cached) return cached;\n }\n\n const moves: {[moveid: string]: MoveSource[]} = {};\n\n for await (const learnset of this.all(species)) {\n if (learnset.learnset) {\n for (const moveid in learnset.learnset) {\n const move = this.gen.moves.get(moveid);\n if (move) {\n const sources = learnset.learnset[moveid];\n if (this.isLegal(move, sources, restriction || this.gen)) {\n const filtered = sources.filter(s => +s.charAt(0) <= this.gen.num);\n if (!filtered.length) continue;\n if (moves[move.id]) {\n // If we simply add filtered to moves[move.id] we may end up with some duplicates or\n // situations where we have mixed learnset information. We assume that while\n // moves[move.id] and filtered are already deduped, their union might not be, and\n // thus iterate through looking for unique prefixes. For efficiency, instead of\n // appending each deduped source from filtered to moves[move.id] immediately and\n // making each subsequent iteration longer we make a list of the unique sources to\n // add at the end. This is only safe given our assumption that filtered is unique\n // internally to begin with.\n const unique = [];\n // These lists are all expected to be short arrays so this O(n^2) linear searching\n // is still expected to be faster runtime-wise than a more sophisticated approach\n loop: for (const source of filtered) {\n const prefix = source.slice(0, 2);\n // sadly Babel chokes on using an .every(...) here due to throwIfClosureRequired\n for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;\n unique.push(source);\n }\n moves[move.id].push(...unique);\n } else {\n moves[move.id] = filtered;\n }\n }\n }\n }\n }\n }\n\n if (!restriction) this.cache[species.id] = moves;\n return moves;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n async canLearn(name: string, move: Move | string, restriction?: Restriction) {\n const species = this.gen.species.get(name);\n if (!species) return false;\n\n move = typeof move === 'string' && this.gen.moves.get(move) || move;\n if (typeof move === 'string') return false;\n\n for await (const learnset of this.all(species)) {\n if (this.isLegal(move, learnset.learnset?.[move.id], restriction || this.gen)) {\n return true;\n }\n }\n\n return false;\n }\n\n // BUG: this only covers what Pokémon Showdown deems \"teambuilder legality\" - proper legality\n // checks/restriction enforcement requires @pkmn/sim's TeamValidator.\n isLegal(move: Move, sources: MoveSource[] | undefined, gen: Generation | Restriction) {\n if (!sources) return undefined;\n\n const gens = sources.map(x => Number(x[0]));\n const minGen = Math.min(...gens);\n const vcOnly = (\n minGen === 7 && sources.every(x => x[0] !== '7' || x === '7V') ||\n minGen === 8 && sources.every(x => x[0] !== '8' || x === '8V')\n );\n\n if (gen === 'Pentagon') return gens.includes(6);\n if (gen === 'Plus') return gens.includes(7) && !vcOnly;\n if (gen === 'Galar') return gens.includes(8) && !vcOnly;\n if (gen === 'Paldea') return gens.includes(9);\n\n if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {\n let legalGens = '';\n let available = false;\n\n if (minGen === 3) {\n legalGens += '3';\n available = true;\n }\n if (available) available = !GEN3_HMS.has(move.id);\n\n if (available || gens.includes(4)) {\n legalGens += '4';\n available = true;\n }\n if (available) available = !GEN4_HMS.has(move.id);\n\n const minUpperGen = available ? 5 : Math.min(...gens.filter(g => g > 4));\n legalGens += '0123456789'.slice(minUpperGen);\n return legalGens.includes(`${gen.num}`);\n } else {\n return '0123456789'.slice(minGen).includes(`${gen.num}`);\n }\n }\n}\n\nconst STATS = ['hp', 'atk', 'def', 'spe', 'spa', 'spd'] as const;\n\nconst NAMES: Readonly<{[name: string]: StatID}> = {\n HP: 'hp', hp: 'hp',\n Attack: 'atk', Atk: 'atk', atk: 'atk',\n Defense: 'def', Def: 'def', def: 'def',\n 'Special Attack': 'spa', SpA: 'spa', SAtk: 'spa', SpAtk: 'spa', spa: 'spa',\n Special: 'spa', spc: 'spa', Spc: 'spa',\n 'Special Defense': 'spd', SpD: 'spd', SDef: 'spd', SpDef: 'spd', spd: 'spd',\n Speed: 'spe', Spe: 'spe', Spd: 'spe', spe: 'spe',\n};\n\nconst DISPLAY: Readonly<{[stat: string]: Readonly<[string, string]>}> = {\n hp: ['HP', 'HP'],\n atk: ['Atk', 'Attack'],\n def: ['Def', 'Defense'],\n spa: ['SpA', 'Special Attack'],\n spd: ['SpD', 'Special Defense'],\n spe: ['Spe', 'Speed'],\n spc: ['Spc', 'Special'],\n};\n\nexport class Stats {\n /* private */ readonly dex: Dex;\n\n constructor(dex: Dex) {\n this.dex = dex;\n }\n\n calc(stat: StatID, base: number, iv = 31, ev?: number, level = 100, nature?: Nature) {\n if (ev === undefined) ev = this.dex.gen < 3 ? 252 : 0;\n if (this.dex.gen < 3) {\n iv = this.toDV(iv) * 2;\n nature = undefined;\n }\n if (stat === 'hp') {\n return base === 1 ? base : tr(tr(2 * base + iv + tr(ev / 4) + 100) * level / 100 + 10);\n } else {\n const val = tr(tr(2 * base + iv + tr(ev / 4)) * level / 100 + 5);\n if (nature !== undefined) {\n if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);\n if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);\n }\n return val;\n }\n }\n\n get(s: string): StatID | undefined {\n return NAMES[s];\n }\n\n display(str: string, full = false): string {\n let s: StatID | 'spc' | undefined = NAMES[str];\n if (s === undefined) return str;\n if (this.dex.gen === 1 && s === 'spa') s = 'spc';\n return DISPLAY[s][+full];\n }\n\n fill<T>(stats: Partial<StatsTable<T>>, val: T): StatsTable<T> {\n for (const stat of STATS) {\n if (!(stat in stats)) stats[stat] = val;\n }\n return stats as StatsTable<T>;\n }\n\n getHPDV(ivs: Partial<StatsTable>): number {\n return (\n (this.toDV(ivs.atk === undefined ? 31 : ivs.atk) % 2) * 8 +\n (this.toDV(ivs.def === undefined ? 31 : ivs.def) % 2) * 4 +\n (this.toDV(ivs.spe === undefined ? 31 : ivs.spe) % 2) * 2 +\n (this.toDV(ivs.spa === undefined ? 31 : ivs.spa) % 2)\n );\n }\n\n *[Symbol.iterator](): IterableIterator<StatID> {\n for (const s of STATS) {\n yield s;\n }\n }\n\n toDV(iv: number): number {\n return Math.floor(iv / 2);\n }\n\n toIV(dv: number): number {\n return dv * 2 + 1;\n }\n}\n\nexport type {\n ID,\n As,\n Weather,\n FieldCondition,\n SideCondition,\n GenerationNum,\n GenderName,\n StatID,\n StatsTable,\n BoostID,\n BoostsTable,\n MoveCategory,\n MoveTarget,\n Nonstandard,\n EvoType,\n EggGroup,\n SideID,\n Player,\n GameType,\n HPColor,\n StatusName,\n NatureName,\n TypeName,\n HPTypeName,\n Tier,\n PokemonSet,\n AbilityName,\n ItemName,\n MoveName,\n SpeciesName,\n FormeName,\n EffectType,\n Effect,\n DataKind,\n Data,\n EffectData,\n HitEffect,\n SecondaryEffect,\n ConditionData,\n AbilityData,\n ItemData,\n MoveData,\n SpeciesData,\n MoveSource,\n EventInfoData,\n LearnsetData,\n TypeData,\n NatureData,\n BasicEffect,\n Condition,\n Ability,\n Item,\n Move,\n // Species,\n EventInfo,\n Learnset,\n // Type,\n Nature,\n GenID,\n Dex,\n} from '@pkmn/dex-types';\n"],"mappings":";AA6BA,IAAM,iBAAiB,CAAC,MAAY;AAClC,MAAI,CAAC,EAAE,OAAQ,QAAO;AACtB,MAAI,mBAAmB,KAAK,EAAE,cAAe,QAAO;AACpD,MAAI,EAAE,SAAS,aAAa,EAAE,OAAO,YAAa,QAAO;AACzD,SAAO,EAAE,UAAU,KAAK,CAAC,WAAW,YAAY,EAAE,SAAS,EAAE,IAAI;AACnE;AAEA,IAAM,KAAK,CAAC,KAAa,OAAO,MAAM,QAAQ,QAAQ,KAAM,KAAK,OAAQ,QAAQ;AAKjF,SAAS,cAAc,GAAyB,GAAyB,SAAsB;AAC7F,aAAW,OAAO,GAAG;AACnB,QAAI,OAAO,UAAU,eAAe,KAAK,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,GAAG,GAAG;AACrE,QAAE,GAAG,IAAI,EAAE,GAAG;AAAA,IAChB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,KAAK,MAAe;AAClC,MAAI,6BAAM,GAAI,QAAO,KAAK;AAC1B,MAAI,OAAO,SAAS,YAAY,OA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Pokémon Showdown client's data layer",
|
|
5
5
|
"repository": "github:pkmn/ps",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"build"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@pkmn/dex-types": "^0.9.
|
|
19
|
+
"@pkmn/dex-types": "^0.9.9"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@pkmn/dex": "^0.9.
|
|
23
|
-
"@pkmn/mods": "^0.9.
|
|
24
|
-
"@pkmn/sim": "^0.9.
|
|
22
|
+
"@pkmn/dex": "^0.9.9",
|
|
23
|
+
"@pkmn/mods": "^0.9.9",
|
|
24
|
+
"@pkmn/sim": "^0.9.9",
|
|
25
25
|
"@smogon/calc": "^0.10.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|