@pkmn/randoms 0.7.57 → 0.7.58

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 CHANGED
@@ -446,21 +446,35 @@ var RandomGen8Teams = class {
446
446
  } else {
447
447
  const formes = ["gastrodoneast", "pumpkaboosuper", "zygarde10"];
448
448
  let learnset = this.dex.species.getLearnset(species.id);
449
+ let learnsetSpecies = species;
449
450
  if (formes.includes(species.id) || !learnset) {
450
- learnset = this.dex.species.getLearnset(this.dex.species.get(species.baseSpecies).id);
451
+ learnsetSpecies = this.dex.species.get(species.baseSpecies);
452
+ learnset = this.dex.species.getLearnset(learnsetSpecies.id);
451
453
  }
452
454
  if (learnset) {
453
455
  pool = Object.keys(learnset).filter(
454
456
  (moveid) => learnset[moveid].find((learned) => learned.startsWith(String(this.gen)))
455
457
  );
456
458
  }
457
- if (species.changesFrom) {
459
+ if (learnset && learnsetSpecies === species && species.changesFrom) {
458
460
  learnset = this.dex.species.getLearnset(_sim.toID.call(void 0, species.changesFrom));
459
461
  const basePool = Object.keys(learnset).filter(
460
462
  (moveid) => learnset[moveid].find((learned) => learned.startsWith(String(this.gen)))
461
463
  );
462
464
  pool = [...new Set(pool.concat(basePool))];
463
465
  }
466
+ const evoRegion = learnsetSpecies.evoRegion && learnsetSpecies.gen !== this.gen;
467
+ for (let i = 0; i < 2 && learnsetSpecies.prevo; i++) {
468
+ learnsetSpecies = this.dex.species.get(learnsetSpecies.prevo);
469
+ learnset = this.dex.species.getLearnset(learnsetSpecies.id);
470
+ for (const moveid in learnset) {
471
+ if (!pool.includes(moveid) && !evoRegion || learnset[moveid].some(
472
+ (source) => !source.startsWith(`${learnsetSpecies.gen}`) || source.charAt(1) === "E"
473
+ )) {
474
+ pool.push(moveid);
475
+ }
476
+ }
477
+ }
464
478
  }
465
479
  const moves = this.multipleSamplesNoReplace(pool, this.maxMoveCount);
466
480
  const evs = { hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0 };
@@ -9347,7 +9361,7 @@ var RandomGen1Teams = class extends RandomGen2Teams {
9347
9361
  const randomN = this.randomNPokemon(this.maxTeamSize, this.forceMonotype);
9348
9362
  for (const pokemon of randomN) {
9349
9363
  const species = this.dex.species.get(pokemon);
9350
- const learnset = this.dex.species.getLearnset(species.id);
9364
+ let learnset = this.dex.species.getLearnset(species.id);
9351
9365
  const mbstmin = 1307;
9352
9366
  const stats = species.baseStats;
9353
9367
  let mbst = stats["hp"] * 2 + 30 + 63 + 100 + 10;
@@ -9398,6 +9412,18 @@ var RandomGen1Teams = class extends RandomGen2Teams {
9398
9412
  }
9399
9413
  }
9400
9414
  }
9415
+ let learnsetSpecies = species;
9416
+ for (let i = 0; i < 2 && learnsetSpecies.prevo; i++) {
9417
+ learnsetSpecies = this.dex.species.get(learnsetSpecies.prevo);
9418
+ learnset = this.dex.species.getLearnset(learnsetSpecies.id);
9419
+ for (const move in learnset) {
9420
+ if (this.dex.moves.get(move).gen !== 1)
9421
+ continue;
9422
+ if (learnset[move].some((learned) => learned.startsWith("1"))) {
9423
+ pool.push(move);
9424
+ }
9425
+ }
9426
+ }
9401
9427
  team.push({
9402
9428
  name: species.baseSpecies,
9403
9429
  species: species.name,
@@ -11779,10 +11805,13 @@ var RandomTeams = class {
11779
11805
  }
11780
11806
  }
11781
11807
  const evoRegion = learnsetSpecies.evoRegion && learnsetSpecies.gen !== this.gen;
11782
- while (learnsetSpecies.prevo) {
11808
+ for (let i = 0; i < 2 && learnsetSpecies.prevo; i++) {
11783
11809
  learnsetSpecies = this.dex.species.get(learnsetSpecies.prevo);
11810
+ learnset = this.dex.species.getLearnset(learnsetSpecies.id);
11784
11811
  for (const moveid in learnset) {
11785
- if (!pool.includes(moveid) && learnset[moveid].some((source) => source.startsWith(String(this.gen)) && !evoRegion)) {
11812
+ if (!pool.includes(moveid) && learnset[moveid].some(
11813
+ (source) => source.startsWith(String(this.gen)) && (!evoRegion || source.charAt(1) === "E")
11814
+ )) {
11786
11815
  pool.push(moveid);
11787
11816
  }
11788
11817
  }