@pkmn/randoms 0.7.5 → 0.7.6
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.js +18 -5
- package/build/index.js.map +1 -1
- package/build/index.mjs +21 -8
- package/build/index.mjs.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -377,16 +377,20 @@ var RandomTeams = class {
|
|
|
377
377
|
const team = [];
|
|
378
378
|
const natures = this.dex.natures.all();
|
|
379
379
|
const items = this.dex.items.all();
|
|
380
|
-
const randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype);
|
|
380
|
+
const randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype, void 0, void 0, true);
|
|
381
381
|
for (let forme of randomN) {
|
|
382
382
|
let species = dex.species.get(forme);
|
|
383
383
|
if (species.isNonstandard)
|
|
384
384
|
species = dex.species.get(species.baseSpecies);
|
|
385
385
|
let item = "";
|
|
386
|
+
let isIllegalItem;
|
|
387
|
+
let isBadItem;
|
|
386
388
|
if (this.gen >= 2) {
|
|
387
389
|
do {
|
|
388
390
|
item = this.sample(items).name;
|
|
389
|
-
|
|
391
|
+
isIllegalItem = this.dex.items.get(item).gen > this.gen || this.dex.items.get(item).isNonstandard;
|
|
392
|
+
isBadItem = item.startsWith("TR") || this.dex.items.get(item).isPokeball;
|
|
393
|
+
} while (isIllegalItem || isBadItem && this.randomChance(19, 20));
|
|
390
394
|
}
|
|
391
395
|
if (species.battleOnly) {
|
|
392
396
|
if (typeof species.battleOnly === "string") {
|
|
@@ -501,7 +505,7 @@ var RandomTeams = class {
|
|
|
501
505
|
}
|
|
502
506
|
return team;
|
|
503
507
|
}
|
|
504
|
-
randomNPokemon(n, requiredType, minSourceGen, ruleTable) {
|
|
508
|
+
randomNPokemon(n, requiredType, minSourceGen, ruleTable, requireMoves = false) {
|
|
505
509
|
const last = [0, 151, 251, 386, 493, 649, 721, 807, 898, 1010][this.gen];
|
|
506
510
|
if (n <= 0 || n > last)
|
|
507
511
|
throw new Error(`n must be a number between 1 and ${last} (got ${n})`);
|
|
@@ -516,6 +520,11 @@ var RandomTeams = class {
|
|
|
516
520
|
for (const species of speciesPool) {
|
|
517
521
|
if (species.isNonstandard && species.isNonstandard !== "Unobtainable")
|
|
518
522
|
continue;
|
|
523
|
+
if (requireMoves) {
|
|
524
|
+
const hasMovesInCurrentGen = Object.values(this.dex.species.getLearnset(species.id) || {}).some((sources) => sources.some((source) => source.startsWith("9")));
|
|
525
|
+
if (!hasMovesInCurrentGen)
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
519
528
|
if (requiredType && !species.types.includes(requiredType))
|
|
520
529
|
continue;
|
|
521
530
|
if (minSourceGen && species.gen < minSourceGen)
|
|
@@ -753,9 +762,13 @@ var RandomTeams = class {
|
|
|
753
762
|
const species = this.dex.species.get(forme);
|
|
754
763
|
let item = "";
|
|
755
764
|
let itemData;
|
|
765
|
+
let isBadItem;
|
|
756
766
|
if (doItemsExist) {
|
|
757
|
-
|
|
758
|
-
|
|
767
|
+
do {
|
|
768
|
+
itemData = this.sampleNoReplace(itemPool);
|
|
769
|
+
item = itemData == null ? void 0 : itemData.name;
|
|
770
|
+
isBadItem = item.startsWith("TR") || itemData.isPokeball;
|
|
771
|
+
} while (isBadItem && this.randomChance(19, 20) && itemPool.length > this.maxTeamSize);
|
|
759
772
|
}
|
|
760
773
|
let ability = "No Ability";
|
|
761
774
|
let abilityData;
|