@pkmn/sim 0.5.9 → 0.5.12

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 (73) hide show
  1. package/README.md +5 -0
  2. package/build/config/formats.js +364 -296
  3. package/build/config/formats.js.map +1 -1
  4. package/build/data/abilities.js +7 -7
  5. package/build/data/abilities.js.map +1 -1
  6. package/build/data/aliases.js +3 -0
  7. package/build/data/aliases.js.map +1 -1
  8. package/build/data/conditions.js +8 -12
  9. package/build/data/conditions.js.map +1 -1
  10. package/build/data/formats-data.js +36 -35
  11. package/build/data/formats-data.js.map +1 -1
  12. package/build/data/items.js +1 -1
  13. package/build/data/items.js.map +1 -1
  14. package/build/data/learnsets.js +5 -4
  15. package/build/data/learnsets.js.map +1 -1
  16. package/build/data/mods/gen1/moves.js +2 -4
  17. package/build/data/mods/gen1/moves.js.map +1 -1
  18. package/build/data/mods/gen3/formats-data.js +2 -2
  19. package/build/data/mods/gen3/formats-data.js.map +1 -1
  20. package/build/data/mods/gen7/formats-data.js +1 -1
  21. package/build/data/mods/gen7/formats-data.js.map +1 -1
  22. package/build/data/moves.js +14 -12
  23. package/build/data/moves.js.map +1 -1
  24. package/build/data/pokedex.js +2 -2
  25. package/build/data/pokedex.js.map +1 -1
  26. package/build/data/tags.js +4 -4
  27. package/build/data/tags.js.map +1 -1
  28. package/build/data/text/moves.js +1 -0
  29. package/build/data/text/moves.js.map +1 -1
  30. package/build/lib/index.js +5 -1
  31. package/build/lib/index.js.map +1 -1
  32. package/build/lib/streams.js +5 -1
  33. package/build/lib/streams.js.map +1 -1
  34. package/build/sim/battle-actions.js +0 -6
  35. package/build/sim/battle-actions.js.map +1 -1
  36. package/build/sim/battle-queue.js +1 -3
  37. package/build/sim/battle-queue.js.map +1 -1
  38. package/build/sim/battle.js +13 -11
  39. package/build/sim/battle.js.map +1 -1
  40. package/build/sim/dex-conditions.js +10 -3
  41. package/build/sim/dex-conditions.js.map +1 -1
  42. package/build/sim/dex.js +5 -1
  43. package/build/sim/dex.js.map +1 -1
  44. package/build/sim/index.js +5 -1
  45. package/build/sim/index.js.map +1 -1
  46. package/build/sim/team-validator.js +1 -1
  47. package/build/sim/team-validator.js.map +1 -1
  48. package/build/sim/teams.js +5 -1
  49. package/build/sim/teams.js.map +1 -1
  50. package/build/sim/tools/index.js +5 -1
  51. package/build/sim/tools/index.js.map +1 -1
  52. package/build/sim/tools/runner.js +5 -1
  53. package/build/sim/tools/runner.js.map +1 -1
  54. package/config/formats.ts +350 -280
  55. package/data/abilities.ts +7 -7
  56. package/data/aliases.ts +3 -0
  57. package/data/conditions.ts +8 -10
  58. package/data/formats-data.ts +36 -35
  59. package/data/items.ts +1 -1
  60. package/data/learnsets.ts +5 -4
  61. package/data/mods/gen1/moves.ts +2 -4
  62. package/data/mods/gen3/formats-data.ts +2 -2
  63. package/data/mods/gen7/formats-data.ts +1 -1
  64. package/data/moves.ts +13 -12
  65. package/data/pokedex.ts +2 -2
  66. package/data/tags.ts +4 -4
  67. package/data/text/moves.ts +2 -0
  68. package/package.json +2 -2
  69. package/sim/battle-actions.ts +0 -7
  70. package/sim/battle-queue.ts +1 -3
  71. package/sim/battle.ts +4 -1
  72. package/sim/dex-conditions.ts +9 -3
  73. package/sim/team-validator.ts +1 -1
@@ -900,6 +900,8 @@ export const MovesText: {[k: string]: MoveText} = {
900
900
  desc: "Causes the user's types to become the same as the current types of the target.",
901
901
  shortDesc: "User becomes the same type as the target.",
902
902
  },
903
+
904
+ typeChange: " Converted type to [SOURCE]'s!", // gen 1 only
903
905
  },
904
906
  conversion2: {
905
907
  name: "Conversion 2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/sim",
3
- "version": "0.5.9",
3
+ "version": "0.5.12",
4
4
  "description": "An automatically generated extraction of just the simulator portion of Pokémon Showdown",
5
5
  "homepage": "https://psim.us",
6
6
  "main": "build/sim/index.js",
@@ -31,7 +31,7 @@
31
31
  "@pkmn/streams": "^1.0.0"
32
32
  },
33
33
  "devDependencies": {
34
- "mocha": "^9.2.1"
34
+ "mocha": "^9.2.2"
35
35
  },
36
36
  "scripts": {
37
37
  "compile": "tsc -p .",
@@ -1779,13 +1779,6 @@ export class BattleActions {
1779
1779
  const speciesid = pokemon.canMegaEvo || pokemon.canUltraBurst;
1780
1780
  if (!speciesid) return false;
1781
1781
 
1782
- // Pokémon affected by Sky Drop cannot mega evolve. Enforce it here for now.
1783
- for (const foeActive of pokemon.foes()) {
1784
- if (foeActive.volatiles['skydrop']?.source === pokemon) {
1785
- return false;
1786
- }
1787
- }
1788
-
1789
1782
  pokemon.formeChange(speciesid, pokemon.getItem(), true);
1790
1783
 
1791
1784
  // Limit one mega evolution
@@ -203,9 +203,7 @@ export class BattleQueue {
203
203
  choice: 'beforeTurnMove', pokemon: action.pokemon, move: action.move, targetLoc: action.targetLoc,
204
204
  }));
205
205
  }
206
- if (action.mega) {
207
- // TODO: Check that the Pokémon is not affected by Sky Drop.
208
- // (This is currently being done in `runMegaEvo`).
206
+ if (action.mega && !action.pokemon.isSkyDropped()) {
209
207
  actions.unshift(...this.resolveAction({
210
208
  choice: 'megaEvo',
211
209
  pokemon: action.pokemon,
package/sim/battle.ts CHANGED
@@ -479,6 +479,7 @@ export class Battle {
479
479
  if (!handler.state.duration) {
480
480
  const endCallArgs = handler.endCallArgs || [handler.effectHolder, effect.id];
481
481
  handler.end.call(...endCallArgs as [any, ...any[]]);
482
+ if (this.ended) return;
482
483
  continue;
483
484
  }
484
485
  }
@@ -1557,8 +1558,9 @@ export class Battle {
1557
1558
  // These are checked before the 100 turn minimum as the battle cannot progress if they are true
1558
1559
  if (this.gen <= 1) {
1559
1560
  const noProgressPossible = this.sides.every(side => {
1560
- const foeAllGhosts = side.foe.pokemon.every(pokemon => pokemon.types.includes('Ghost'));
1561
+ const foeAllGhosts = side.foe.pokemon.every(pokemon => pokemon.fainted || pokemon.types.includes('Ghost'));
1561
1562
  const foeAllTransform = side.foe.pokemon.every(pokemon => (
1563
+ pokemon.fainted ||
1562
1564
  // true if transforming into this pokemon would lead to an endless battle
1563
1565
  // Transform will fail (depleting PP) if used against Ditto in Stadium 1
1564
1566
  (this.dex.currentMod !== 'gen1stadium' || pokemon.species.id !== 'ditto') &&
@@ -1567,6 +1569,7 @@ export class Battle {
1567
1569
  pokemon.moves.every(moveid => moveid === 'transform')
1568
1570
  ));
1569
1571
  return side.pokemon.every(pokemon => (
1572
+ pokemon.fainted ||
1570
1573
  // frozen pokemon can't thaw in gen 1 without outside help
1571
1574
  pokemon.status === 'frz' ||
1572
1575
  // a pokemon can't lose PP if it Transforms into a pokemon with only Transform
@@ -659,7 +659,10 @@ export class DexConditions {
659
659
  if (!name) return EMPTY_CONDITION;
660
660
  if (typeof name !== 'string') return name as Condition;
661
661
 
662
- return this.getByID(name.startsWith('item:') || name.startsWith('ability:') ? name as ID : toID(name));
662
+ const special = name.startsWith('item:') ? `item:${toID(name.slice(5))}` as ID :
663
+ name.startsWith('ability:') ? `ability:${toID(name.slice(8))}` as ID :
664
+ name.startsWith('move:') ? `move:${toID(name.slice(5))}` as ID : undefined;
665
+ return this.getByID(special || toID(name));
663
666
  }
664
667
 
665
668
  getByID(id: ID): Condition {
@@ -671,10 +674,13 @@ export class DexConditions {
671
674
  let found;
672
675
  if (id.startsWith('item:')) {
673
676
  const item = this.dex.items.getByID(id.slice(5) as ID);
674
- condition = {...item, id: 'item:' + item.id as ID} as any as Condition;
677
+ condition = item as any as Condition;
675
678
  } else if (id.startsWith('ability:')) {
676
679
  const ability = this.dex.abilities.getByID(id.slice(8) as ID);
677
- condition = {...ability, id: 'ability:' + ability.id as ID} as any as Condition;
680
+ condition = ability as any as Condition;
681
+ } else if (id.startsWith('move:')) {
682
+ const move = this.dex.moves.getByID(id.slice(5) as ID);
683
+ condition = move as any as Condition;
678
684
  } else if (this.dex.data.Rulesets.hasOwnProperty(id)) {
679
685
  condition = this.dex.formats.get(id) as any as Condition;
680
686
  } else if (this.dex.data.Conditions.hasOwnProperty(id)) {
@@ -712,7 +712,7 @@ export class TeamValidator {
712
712
  }
713
713
 
714
714
  let isFromRBYEncounter = false;
715
- if (this.gen === 1 && !this.ruleTable.has('allowtradeback')) {
715
+ if (this.gen === 1 && ruleTable.has('obtainablemisc') && !this.ruleTable.has('allowtradeback')) {
716
716
  let lowestEncounterLevel;
717
717
  for (const encounter of learnsetSpecies.encounters || []) {
718
718
  if (encounter.generation !== 1) continue;