@pkmn/sim 0.9.23 → 0.9.25

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.
Files changed (119) hide show
  1. package/build/cjs/config/formats.js +74 -84
  2. package/build/cjs/config/formats.js.map +1 -1
  3. package/build/cjs/data/abilities.js +5 -4
  4. package/build/cjs/data/abilities.js.map +1 -1
  5. package/build/cjs/data/aliases.js +215 -2
  6. package/build/cjs/data/aliases.js.map +1 -1
  7. package/build/cjs/data/conditions.js +11 -1
  8. package/build/cjs/data/conditions.js.map +1 -1
  9. package/build/cjs/data/formats-data.js +22 -13
  10. package/build/cjs/data/formats-data.js.map +1 -1
  11. package/build/cjs/data/items.js +1 -0
  12. package/build/cjs/data/items.js.map +1 -1
  13. package/build/cjs/data/learnsets.js +28 -1
  14. package/build/cjs/data/learnsets.js.map +1 -1
  15. package/build/cjs/data/mods/gen3/scripts.js +3 -1
  16. package/build/cjs/data/mods/gen3/scripts.js.map +1 -1
  17. package/build/cjs/data/mods/gen4/abilities.js +1 -1
  18. package/build/cjs/data/mods/gen4/abilities.js.map +1 -1
  19. package/build/cjs/data/mods/gen4/items.js +64 -0
  20. package/build/cjs/data/mods/gen4/items.js.map +1 -1
  21. package/build/cjs/data/mods/gen4/moves.js +47 -0
  22. package/build/cjs/data/mods/gen4/moves.js.map +1 -1
  23. package/build/cjs/data/mods/gen5/abilities.js +1 -1
  24. package/build/cjs/data/mods/gen5/abilities.js.map +1 -1
  25. package/build/cjs/data/moves.js +17 -7
  26. package/build/cjs/data/moves.js.map +1 -1
  27. package/build/cjs/data/pokedex.js +12 -0
  28. package/build/cjs/data/pokedex.js.map +1 -1
  29. package/build/cjs/data/rulesets.js +1 -25
  30. package/build/cjs/data/rulesets.js.map +1 -1
  31. package/build/cjs/data/text/abilities.js +2 -2
  32. package/build/cjs/data/text/abilities.js.map +1 -1
  33. package/build/cjs/data/text/items.js +6 -2
  34. package/build/cjs/data/text/items.js.map +1 -1
  35. package/build/cjs/data/text/moves.js +59 -23
  36. package/build/cjs/data/text/moves.js.map +1 -1
  37. package/build/cjs/lib/index.js +17 -7
  38. package/build/cjs/lib/index.js.map +1 -1
  39. package/build/cjs/sim/battle.d.ts +6 -0
  40. package/build/cjs/sim/battle.js +11 -0
  41. package/build/cjs/sim/battle.js.map +1 -1
  42. package/build/cjs/sim/dex-conditions.d.ts +1 -0
  43. package/build/cjs/sim/dex-conditions.js.map +1 -1
  44. package/build/cjs/sim/dex-items.js +12 -0
  45. package/build/cjs/sim/dex-items.js.map +1 -1
  46. package/build/cjs/sim/dex.js +17 -7
  47. package/build/cjs/sim/dex.js.map +1 -1
  48. package/build/cjs/sim/exported-global-types.d.ts +18 -0
  49. package/build/cjs/sim/global-types.d.ts +18 -0
  50. package/build/cjs/sim/index.js +17 -7
  51. package/build/cjs/sim/index.js.map +1 -1
  52. package/build/cjs/sim/pokemon.d.ts +1 -1
  53. package/build/cjs/sim/pokemon.js +7 -4
  54. package/build/cjs/sim/pokemon.js.map +1 -1
  55. package/build/cjs/sim/side.js +3 -2
  56. package/build/cjs/sim/side.js.map +1 -1
  57. package/build/cjs/sim/team-validator.d.ts +5 -2
  58. package/build/cjs/sim/team-validator.js +33 -33
  59. package/build/cjs/sim/team-validator.js.map +1 -1
  60. package/build/cjs/sim/teams.d.ts +1 -1
  61. package/build/cjs/sim/teams.js +17 -7
  62. package/build/cjs/sim/teams.js.map +1 -1
  63. package/build/cjs/sim/tools/runner.js +17 -7
  64. package/build/cjs/sim/tools/runner.js.map +1 -1
  65. package/build/esm/config/formats.mjs +74 -84
  66. package/build/esm/config/formats.mjs.map +1 -1
  67. package/build/esm/data/abilities.mjs +5 -4
  68. package/build/esm/data/abilities.mjs.map +1 -1
  69. package/build/esm/data/aliases.mjs +215 -2
  70. package/build/esm/data/aliases.mjs.map +1 -1
  71. package/build/esm/data/conditions.mjs +11 -1
  72. package/build/esm/data/conditions.mjs.map +1 -1
  73. package/build/esm/data/formats-data.mjs +22 -13
  74. package/build/esm/data/formats-data.mjs.map +1 -1
  75. package/build/esm/data/items.mjs +1 -0
  76. package/build/esm/data/items.mjs.map +1 -1
  77. package/build/esm/data/learnsets.mjs +28 -1
  78. package/build/esm/data/learnsets.mjs.map +1 -1
  79. package/build/esm/data/mods/gen3/scripts.mjs +3 -1
  80. package/build/esm/data/mods/gen3/scripts.mjs.map +1 -1
  81. package/build/esm/data/mods/gen4/abilities.mjs +1 -1
  82. package/build/esm/data/mods/gen4/abilities.mjs.map +1 -1
  83. package/build/esm/data/mods/gen4/items.mjs +64 -0
  84. package/build/esm/data/mods/gen4/items.mjs.map +1 -1
  85. package/build/esm/data/mods/gen4/moves.mjs +47 -0
  86. package/build/esm/data/mods/gen4/moves.mjs.map +1 -1
  87. package/build/esm/data/mods/gen5/abilities.mjs +1 -1
  88. package/build/esm/data/mods/gen5/abilities.mjs.map +1 -1
  89. package/build/esm/data/moves.mjs +17 -7
  90. package/build/esm/data/moves.mjs.map +1 -1
  91. package/build/esm/data/pokedex.mjs +12 -0
  92. package/build/esm/data/pokedex.mjs.map +1 -1
  93. package/build/esm/data/rulesets.mjs +1 -25
  94. package/build/esm/data/rulesets.mjs.map +1 -1
  95. package/build/esm/data/text/abilities.mjs +2 -2
  96. package/build/esm/data/text/abilities.mjs.map +1 -1
  97. package/build/esm/data/text/items.mjs +6 -2
  98. package/build/esm/data/text/items.mjs.map +1 -1
  99. package/build/esm/data/text/moves.mjs +59 -23
  100. package/build/esm/data/text/moves.mjs.map +1 -1
  101. package/build/esm/sim/battle.d.mts +6 -0
  102. package/build/esm/sim/battle.mjs +11 -0
  103. package/build/esm/sim/battle.mjs.map +1 -1
  104. package/build/esm/sim/dex-conditions.d.mts +1 -0
  105. package/build/esm/sim/dex-conditions.mjs.map +1 -1
  106. package/build/esm/sim/dex-items.mjs +12 -0
  107. package/build/esm/sim/dex-items.mjs.map +1 -1
  108. package/build/esm/sim/exported-global-types.d.mts +18 -0
  109. package/build/esm/sim/global-types.d.mts +18 -0
  110. package/build/esm/sim/pokemon.d.mts +1 -1
  111. package/build/esm/sim/pokemon.mjs +7 -4
  112. package/build/esm/sim/pokemon.mjs.map +1 -1
  113. package/build/esm/sim/side.mjs +3 -2
  114. package/build/esm/sim/side.mjs.map +1 -1
  115. package/build/esm/sim/team-validator.d.mts +5 -2
  116. package/build/esm/sim/team-validator.mjs +33 -33
  117. package/build/esm/sim/team-validator.mjs.map +1 -1
  118. package/build/esm/sim/teams.d.mts +1 -1
  119. package/package.json +2 -2
@@ -440,7 +440,7 @@ class TeamValidator {
440
440
  tierSpecies = dex.species.get('Zamazenta-Crowned');
441
441
  }
442
442
  }
443
- return [outOfBattleSpecies, tierSpecies];
443
+ return { outOfBattleSpecies, tierSpecies };
444
444
  }
445
445
  validateSet(set, teamHas) {
446
446
  const format = this.format;
@@ -529,7 +529,7 @@ class TeamValidator {
529
529
  species = dex.species.get(set.species);
530
530
  item = dex.items.get(set.item);
531
531
  ability = dex.abilities.get(set.ability);
532
- const [outOfBattleSpecies, tierSpecies] = this.getValidationSpecies(set);
532
+ const { outOfBattleSpecies, tierSpecies } = this.getValidationSpecies(set);
533
533
  if (ability.id === 'battlebond' && (0, dex_1.toID)(species.baseSpecies) === 'greninja') {
534
534
  if (ruleTable.has('obtainablemisc')) {
535
535
  if (set.gender && set.gender !== 'M') {
@@ -573,7 +573,7 @@ class TeamValidator {
573
573
  }
574
574
  if (set.hpType) {
575
575
  const type = dex.types.get(set.hpType);
576
- if (!type.exists || ['normal', 'fairy'].includes(type.id)) {
576
+ if (!type.exists || ['normal', 'fairy', 'stellar'].includes(type.id)) {
577
577
  problems.push(`${name}'s Hidden Power type (${set.hpType}) is invalid.`);
578
578
  }
579
579
  else {
@@ -683,6 +683,10 @@ class TeamValidator {
683
683
  problems.push(`${name} has ${set.moves.length} moves, which is more than the limit of ${ruleTable.maxMoveCount}.`);
684
684
  return problems;
685
685
  }
686
+ const pokemonGoProblems = this.validatePokemonGo(outOfBattleSpecies, set, setSources);
687
+ if (ruleTable.isBanned('nonexistent')) {
688
+ problems.push(...this.validateStats(set, species, setSources, pokemonGoProblems));
689
+ }
686
690
  const moveLegalityWhitelist = {};
687
691
  for (const moveName of set.moves) {
688
692
  if (!moveName)
@@ -706,7 +710,6 @@ class TeamValidator {
706
710
  }
707
711
  }
708
712
  }
709
- const pokemonGoProblems = this.validatePokemonGo(outOfBattleSpecies, set, setSources);
710
713
  const learnsetSpecies = dex.species.getLearnsetData(outOfBattleSpecies.id);
711
714
  let isFromRBYEncounter = false;
712
715
  if (this.gen === 1 && ruleTable.has('obtainablemisc') && !this.ruleTable.has('allowtradeback')) {
@@ -899,9 +902,6 @@ class TeamValidator {
899
902
  }
900
903
  }
901
904
  }
902
- if (ruleTable.isBanned('nonexistent')) {
903
- problems.push(...this.validateStats(set, species, setSources, pokemonGoProblems));
904
- }
905
905
  // Attempt move validation again after verifying Pokemon GO origin
906
906
  if (ruleTable.has('obtainablemoves') && setSources.isFromPokemonGo) {
907
907
  setSources.restrictiveMoves = [];
@@ -1081,24 +1081,6 @@ class TeamValidator {
1081
1081
  problems.push(`${name} has Hidden Power ${set.hpType}, but its IVs don't allow this even with (Bottle Cap) Hyper Training.`);
1082
1082
  }
1083
1083
  }
1084
- if (setSources.isFromPokemonGo) {
1085
- // Pokemon from Pokemon GO must have odd IVs in non-Spe stats
1086
- // Since the set can be fixed while making minimal changes, it does not force the IVs to be manually fixed
1087
- for (const stat in set.ivs) {
1088
- if (set.ivs[stat] % 2 === 0 && stat !== 'spe') {
1089
- set.ivs[stat]++;
1090
- }
1091
- }
1092
- if (set.ivs.atk !== set.ivs.spa && !(canBottleCap && (set.ivs.atk === 31 || set.ivs.spa === 31))) {
1093
- problems.push(`${name}'s Atk and Spa IVs must match because it is from Pokemon GO.`);
1094
- }
1095
- if (set.ivs.def !== set.ivs.spd && !(canBottleCap && (set.ivs.def === 31 || set.ivs.spd === 31))) {
1096
- problems.push(`${name}'s Def and Spd IVs must match because it is from Pokemon GO.`);
1097
- }
1098
- if (set.hpType && set.hpType !== 'Dark' && set.hpType !== 'Ice') {
1099
- problems.push(`${name} must have Hidden Power Dark or Ice because it is from Pokemon GO.`);
1100
- }
1101
- }
1102
1084
  if (dex.gen <= 2) {
1103
1085
  // validate DVs
1104
1086
  const ivs = set.ivs;
@@ -2252,7 +2234,7 @@ class TeamValidator {
2252
2234
  minLevel = Math.min(minLevel, 20);
2253
2235
  minIVs = Math.min(minIVs, 10);
2254
2236
  }
2255
- if (species.id === 'mewtwo' && set.level && set.level >= 20) {
2237
+ if (species.id === 'mewtwo' && set.level >= 20) {
2256
2238
  // A bug allowed Mewtwo to be encountered with an IV floor of 0 from GO Battle League
2257
2239
  minIVs = Math.min(minIVs, 0);
2258
2240
  }
@@ -2267,7 +2249,7 @@ class TeamValidator {
2267
2249
  */
2268
2250
  minLevel = Math.min(minLevel, 8);
2269
2251
  minIVs = Math.min(minIVs, 1);
2270
- if (set.level && set.level < 12)
2252
+ if (set.level < 12)
2271
2253
  setSources.pokemonGoSource = "purified";
2272
2254
  }
2273
2255
  // Attempt to trade the Pokemon to reduce level and IVs
@@ -2281,16 +2263,34 @@ class TeamValidator {
2281
2263
  minIVs = Math.min(minIVs, specialTrade ? 1 : 0);
2282
2264
  }
2283
2265
  }
2284
- if (set.level && set.level < minLevel) {
2266
+ if (set.level < minLevel) {
2285
2267
  problems.push(`${name} must be at least level ${minLevel} to be from Pokemon GO.`);
2286
2268
  }
2287
2269
  const ivs = set.ivs || TeamValidator.fillStats(null, 31);
2270
+ const postTransferMinIVs = minIVs * 2 + 1;
2271
+ let IVsTooLow = false;
2272
+ let hasEvenIVs = false;
2288
2273
  for (const stat in ivs) {
2289
- if (Math.floor(ivs[stat] / 2) < minIVs && stat !== 'spe') {
2290
- problems.push(`${name} must have at least ${minIVs} ` +
2291
- (minIVs === 1 ? `IV` : `IVs`) + ` in non-Speed stats to be from Pokemon GO.`);
2292
- break;
2293
- }
2274
+ if (stat === 'spe')
2275
+ continue;
2276
+ if (ivs[stat] < postTransferMinIVs)
2277
+ IVsTooLow = true;
2278
+ if (ivs[stat] % 2 === 0)
2279
+ hasEvenIVs = true;
2280
+ }
2281
+ if (IVsTooLow) {
2282
+ problems.push(`${name} must have at least ${postTransferMinIVs} ` +
2283
+ (postTransferMinIVs === 1 ? `IV` : `IVs`) + ` in non-Speed stats to be from Pokemon GO.`);
2284
+ }
2285
+ if (hasEvenIVs) {
2286
+ problems.push(`${name} must have odd non-Speed IVs to be from Pokemon GO.`);
2287
+ }
2288
+ const canBottleCap = dex.gen >= 7 && set.level >= (dex.gen < 9 ? 100 : 50);
2289
+ if (ivs.atk !== ivs.spa && !(canBottleCap && (ivs.atk === 31 || ivs.spa === 31))) {
2290
+ problems.push(`${name}'s Atk and Sp. Atk IVs must match to be from Pokemon GO.`);
2291
+ }
2292
+ if (ivs.def !== ivs.spd && !(canBottleCap && (ivs.def === 31 || ivs.spd === 31))) {
2293
+ problems.push(`${name}'s Def and Sp. Def IVs must match to be from Pokemon GO.`);
2294
2294
  }
2295
2295
  }
2296
2296
  }