@pkmn/sim 0.5.19 → 0.5.22

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 (91) hide show
  1. package/build/config/formats.js +354 -294
  2. package/build/config/formats.js.map +1 -1
  3. package/build/data/abilities.js +1 -3
  4. package/build/data/abilities.js.map +1 -1
  5. package/build/data/aliases.js +2 -2
  6. package/build/data/aliases.js.map +1 -1
  7. package/build/data/conditions.js +4 -1
  8. package/build/data/conditions.js.map +1 -1
  9. package/build/data/formats-data.js +16 -12
  10. package/build/data/formats-data.js.map +1 -1
  11. package/build/data/learnsets.js +29 -0
  12. package/build/data/learnsets.js.map +1 -1
  13. package/build/data/mods/gen1/conditions.js +7 -0
  14. package/build/data/mods/gen1/conditions.js.map +1 -1
  15. package/build/data/mods/gen1/formats-data.js +3 -3
  16. package/build/data/mods/gen1/formats-data.js.map +1 -1
  17. package/build/data/mods/gen1/moves.js +0 -6
  18. package/build/data/mods/gen1/moves.js.map +1 -1
  19. package/build/data/mods/gen2/conditions.js +3 -0
  20. package/build/data/mods/gen2/conditions.js.map +1 -1
  21. package/build/data/mods/gen2/learnsets.js +2 -2
  22. package/build/data/mods/gen2/learnsets.js.map +1 -1
  23. package/build/data/mods/gen2/scripts.js +16 -0
  24. package/build/data/mods/gen2/scripts.js.map +1 -1
  25. package/build/data/mods/gen3/conditions.js +3 -0
  26. package/build/data/mods/gen3/conditions.js.map +1 -1
  27. package/build/data/mods/gen4/abilities.js +1 -1
  28. package/build/data/mods/gen4/abilities.js.map +1 -1
  29. package/build/data/mods/gen4/conditions.js +3 -0
  30. package/build/data/mods/gen4/conditions.js.map +1 -1
  31. package/build/data/mods/gen4/formats-data.js +1 -1
  32. package/build/data/mods/gen4/formats-data.js.map +1 -1
  33. package/build/data/mods/gen4/moves.js +9 -2
  34. package/build/data/mods/gen4/moves.js.map +1 -1
  35. package/build/data/mods/gen5/moves.js +4 -7
  36. package/build/data/mods/gen5/moves.js.map +1 -1
  37. package/build/data/mods/gen5/pokedex.js +24 -0
  38. package/build/data/mods/gen5/pokedex.js.map +1 -1
  39. package/build/data/mods/gen6/formats-data.js +1 -1
  40. package/build/data/mods/gen6/formats-data.js.map +1 -1
  41. package/build/data/mods/gen6/learnsets.js +0 -75
  42. package/build/data/mods/gen6/learnsets.js.map +1 -1
  43. package/build/data/mods/gen7/abilities.js +8 -0
  44. package/build/data/mods/gen7/abilities.js.map +1 -1
  45. package/build/data/mods/gen7/moves.js +2 -2
  46. package/build/data/mods/gen7/moves.js.map +1 -1
  47. package/build/data/moves.js +8 -3
  48. package/build/data/moves.js.map +1 -1
  49. package/build/data/pokedex.js +12 -0
  50. package/build/data/pokedex.js.map +1 -1
  51. package/build/data/rulesets.js +68 -0
  52. package/build/data/rulesets.js.map +1 -1
  53. package/build/data/tags.js +2 -2
  54. package/build/data/tags.js.map +1 -1
  55. package/build/sim/battle.js +1 -7
  56. package/build/sim/battle.js.map +1 -1
  57. package/build/sim/pokemon.js +8 -2
  58. package/build/sim/pokemon.js.map +1 -1
  59. package/build/sim/side.js +21 -0
  60. package/build/sim/side.js.map +1 -1
  61. package/config/formats.ts +346 -291
  62. package/data/abilities.ts +1 -3
  63. package/data/aliases.ts +2 -2
  64. package/data/conditions.ts +5 -1
  65. package/data/formats-data.ts +16 -12
  66. package/data/learnsets.ts +29 -0
  67. package/data/mods/gen1/conditions.ts +8 -0
  68. package/data/mods/gen1/formats-data.ts +3 -3
  69. package/data/mods/gen1/moves.ts +0 -4
  70. package/data/mods/gen2/conditions.ts +4 -0
  71. package/data/mods/gen2/learnsets.ts +2 -2
  72. package/data/mods/gen2/scripts.ts +16 -0
  73. package/data/mods/gen3/conditions.ts +4 -0
  74. package/data/mods/gen4/abilities.ts +1 -1
  75. package/data/mods/gen4/conditions.ts +4 -0
  76. package/data/mods/gen4/formats-data.ts +1 -1
  77. package/data/mods/gen4/moves.ts +9 -2
  78. package/data/mods/gen5/moves.ts +4 -7
  79. package/data/mods/gen5/pokedex.ts +24 -0
  80. package/data/mods/gen6/formats-data.ts +1 -1
  81. package/data/mods/gen6/learnsets.ts +0 -75
  82. package/data/mods/gen7/abilities.ts +8 -0
  83. package/data/mods/gen7/moves.ts +2 -2
  84. package/data/moves.ts +8 -3
  85. package/data/pokedex.ts +12 -0
  86. package/data/rulesets.ts +64 -0
  87. package/data/tags.ts +2 -2
  88. package/package.json +1 -1
  89. package/sim/battle.ts +1 -7
  90. package/sim/pokemon.ts +7 -2
  91. package/sim/side.ts +20 -0
package/data/rulesets.ts CHANGED
@@ -399,6 +399,29 @@ export const Rulesets: {[k: string]: FormatData} = {
399
399
  }
400
400
  },
401
401
  },
402
+ forceselect: {
403
+ effectType: 'ValidatorRule',
404
+ name: 'Force Select',
405
+ desc: `Forces a Pokemon to be on the team and selected at Team Preview. Usage: Force Select = [Pokemon], e.g. "Force Select = Magikarp"`,
406
+ hasValue: true,
407
+ onValidateRule(value) {
408
+ if (!this.dex.species.get(value).exists) throw new Error(`Misspelled Pokemon "${value}"`);
409
+ },
410
+ onValidateTeam(team) {
411
+ let hasSelection = false;
412
+ const species = this.dex.species.get(this.ruleTable.valueRules.get('forceselect'));
413
+ for (const set of team) {
414
+ if (species.name === set.species) {
415
+ hasSelection = true;
416
+ break;
417
+ }
418
+ }
419
+ if (!hasSelection) {
420
+ return [`Your team must contain ${species.name}.`];
421
+ }
422
+ },
423
+ // hardcoded in sim/side
424
+ },
402
425
  evlimits: {
403
426
  effectType: 'ValidatorRule',
404
427
  name: 'EV Limits',
@@ -1262,6 +1285,19 @@ export const Rulesets: {[k: string]: FormatData} = {
1262
1285
  }
1263
1286
  },
1264
1287
  },
1288
+ gemsclause: {
1289
+ effectType: 'ValidatorRule',
1290
+ name: 'Gems Clause',
1291
+ desc: "Bans all Gems",
1292
+ onValidateSet(set) {
1293
+ if (!set.item) return;
1294
+ const item = this.dex.items.get(set.item);
1295
+ if (item.isGem) {
1296
+ if (this.ruleTable.has(`+item:${item.id}`)) return;
1297
+ return [`${item.name} is banned due to Gems Clause.`];
1298
+ }
1299
+ },
1300
+ },
1265
1301
  'sketchgen8moves': {
1266
1302
  effectType: 'ValidatorRule',
1267
1303
  name: 'Sketch Gen 8 Moves',
@@ -1585,6 +1621,12 @@ export const Rulesets: {[k: string]: FormatData} = {
1585
1621
  desc: "Prevents Pok\u00e9mon from having moves that would only be obtainable in Pok\u00e9mon Crystal.",
1586
1622
  // Implemented in mods/gen2/rulesets.ts
1587
1623
  },
1624
+ aptclause: {
1625
+ effectType: 'ValidatorRule',
1626
+ name: 'APT Clause',
1627
+ desc: "Bans the combination of Agility and partial trapping moves like Wrap.",
1628
+ banlist: ['Agility + Wrap', 'Agility + Fire Spin', 'Agility + Bind', 'Agility + Clamp'],
1629
+ },
1588
1630
  nintendocup1997movelegality: {
1589
1631
  effectType: 'ValidatorRule',
1590
1632
  name: "Nintendo Cup 1997 Move Legality",
@@ -1824,4 +1866,26 @@ export const Rulesets: {[k: string]: FormatData} = {
1824
1866
  }
1825
1867
  },
1826
1868
  },
1869
+ reevolutionmod: {
1870
+ effectType: "Rule",
1871
+ name: "Re-Evolution Mod",
1872
+ desc: "Pokémon gain the boosts they would gain from evolving again",
1873
+ ruleset: ['Overflow Stat Mod'],
1874
+ onBegin() {
1875
+ this.add('rule', 'Re-Evolution Mod: Pok\u00e9mon gain the boosts they would gain from evolving again');
1876
+ },
1877
+ onModifySpecies(species, target) {
1878
+ const newSpecies = this.dex.deepClone(species);
1879
+ if (!newSpecies.prevo) return;
1880
+ const prevoSpecies = this.dex.species.get(newSpecies.prevo);
1881
+ let statid: StatID;
1882
+ newSpecies.bst = 0;
1883
+ for (statid in prevoSpecies.baseStats) {
1884
+ const change = newSpecies.baseStats[statid] - prevoSpecies.baseStats[statid];
1885
+ newSpecies.baseStats[statid] = this.clampIntRange(newSpecies.baseStats[statid] + change, 1, 255);
1886
+ newSpecies.bst += newSpecies.baseStats[statid];
1887
+ }
1888
+ return newSpecies;
1889
+ },
1890
+ },
1827
1891
  };
package/data/tags.ts CHANGED
@@ -199,8 +199,8 @@ export const Tags: {[id: string]: TagData} = {
199
199
  speciesFilter: species => [
200
200
  'Aerodactyl-Mega', 'Alakazam', 'Blacephalon', 'Blaziken', 'Diancie-Mega', 'Gallade-Mega', 'Gardevoir-Mega', 'Gengar', 'Gyarados',
201
201
  'Gyarados-Mega', 'Hawlucha', 'Heracross-Mega', 'Hoopa-Unbound', 'Hydreigon', 'Jirachi', 'Latias', 'Latias-Mega', 'Latios',
202
- 'Latios-Mega', 'Manaphy', 'Medicham-Mega', 'Melmetal', 'Mew', 'Pinsir-Mega', 'Sableye-Mega', 'Slowbro-Mega', 'Slowking-Galar',
203
- 'Thundurus', 'Thundurus-Therian', 'Venusaur-Mega', 'Xurkitree', 'Zapdos-Galar',
202
+ 'Latios-Mega', 'Manaphy', 'Medicham-Mega', 'Melmetal', 'Mew', 'Moltres-Galar', 'Pinsir-Mega', 'Sableye-Mega', 'Slowbro-Mega',
203
+ 'Slowking-Galar', 'Thundurus', 'Venusaur-Mega', 'Xurkitree', 'Zapdos-Galar',
204
204
  ].includes(species.name),
205
205
  },
206
206
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/sim",
3
- "version": "0.5.19",
3
+ "version": "0.5.22",
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",
package/sim/battle.ts CHANGED
@@ -2078,13 +2078,7 @@ export class Battle {
2078
2078
  denominator = numerator[1];
2079
2079
  numerator = numerator[0];
2080
2080
  }
2081
- let nextMod = 0;
2082
- if (this.event.ceilModifier) {
2083
- nextMod = Math.ceil(numerator * 4096 / (denominator || 1));
2084
- } else {
2085
- nextMod = this.trunc(numerator * 4096 / (denominator || 1));
2086
- }
2087
-
2081
+ const nextMod = this.trunc(numerator * 4096 / (denominator || 1));
2088
2082
  this.event.modifier = ((previousMod * nextMod + 2048) >> 12) / 4096;
2089
2083
  }
2090
2084
 
package/sim/pokemon.ts CHANGED
@@ -1522,7 +1522,7 @@ export class Pokemon {
1522
1522
  cureStatus(silent = false) {
1523
1523
  if (!this.hp || !this.status) return false;
1524
1524
  this.battle.add('-curestatus', this, this.status, silent ? '[silent]' : '[msg]');
1525
- if (this.status === 'slp' && !this.hasAbility('comatose') && this.removeVolatile('nightmare')) {
1525
+ if (this.status === 'slp' && this.removeVolatile('nightmare')) {
1526
1526
  this.battle.add('-end', this, 'Nightmare', '[silent]');
1527
1527
  }
1528
1528
  this.setStatus('');
@@ -1599,7 +1599,12 @@ export class Pokemon {
1599
1599
  * Unlike cureStatus, does not give cure message
1600
1600
  */
1601
1601
  clearStatus() {
1602
- return this.setStatus('');
1602
+ if (!this.hp || !this.status) return false;
1603
+ if (this.status === 'slp' && this.removeVolatile('nightmare')) {
1604
+ this.battle.add('-end', this, 'Nightmare', '[silent]');
1605
+ }
1606
+ this.setStatus('');
1607
+ return true;
1603
1608
  }
1604
1609
 
1605
1610
  getStatus() {
package/sim/side.ts CHANGED
@@ -796,6 +796,26 @@ export class Side {
796
796
  }
797
797
  }
798
798
  }
799
+ if (ruleTable.valueRules.has('forceselect')) {
800
+ const species = this.battle.dex.species.get(ruleTable.valueRules.get('forceselect'));
801
+ if (!data) {
802
+ // autoChoose
803
+ positions = [...this.pokemon.keys()].filter(pos => this.pokemon[pos].species.name === species.name)
804
+ .concat([...this.pokemon.keys()].filter(pos => this.pokemon[pos].species.name !== species.name))
805
+ .slice(0, pickedTeamSize);
806
+ } else {
807
+ let hasSelection = false;
808
+ for (const pos of positions) {
809
+ if (this.pokemon[pos].species.name === species.name) {
810
+ hasSelection = true;
811
+ break;
812
+ }
813
+ }
814
+ if (!hasSelection) {
815
+ return this.emitChoiceError(`You must bring ${species.name} to the battle.`);
816
+ }
817
+ }
818
+ }
799
819
  for (const [index, pos] of positions.entries()) {
800
820
  this.choice.switchIns.add(pos);
801
821
  this.choice.actions.push({