@pkmn/sim 0.5.22 → 0.5.23

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 (42) hide show
  1. package/build/config/formats.js +296 -325
  2. package/build/config/formats.js.map +1 -1
  3. package/build/data/aliases.js +4 -4
  4. package/build/data/aliases.js.map +1 -1
  5. package/build/data/conditions.js +1 -1
  6. package/build/data/conditions.js.map +1 -1
  7. package/build/data/formats-data.js +7 -8
  8. package/build/data/formats-data.js.map +1 -1
  9. package/build/data/mods/gen1/formats-data.js +1 -1
  10. package/build/data/mods/gen1/formats-data.js.map +1 -1
  11. package/build/data/mods/gen1/moves.js +5 -0
  12. package/build/data/mods/gen1/moves.js.map +1 -1
  13. package/build/data/mods/gen1/scripts.js +4 -2
  14. package/build/data/mods/gen1/scripts.js.map +1 -1
  15. package/build/data/mods/gen3/formats-data.js +3 -3
  16. package/build/data/mods/gen3/formats-data.js.map +1 -1
  17. package/build/data/mods/gen6/formats-data.js +64 -64
  18. package/build/data/mods/gen6/formats-data.js.map +1 -1
  19. package/build/data/rulesets.js +108 -1
  20. package/build/data/rulesets.js.map +1 -1
  21. package/build/sim/battle-stream.js +3 -0
  22. package/build/sim/battle-stream.js.map +1 -1
  23. package/build/sim/exported-global-types.d.ts +2 -0
  24. package/build/sim/global-types.d.ts +2 -0
  25. package/build/sim/pokemon.d.ts +1 -0
  26. package/build/sim/pokemon.js +1 -0
  27. package/build/sim/pokemon.js.map +1 -1
  28. package/config/formats.ts +294 -318
  29. package/data/aliases.ts +4 -4
  30. package/data/conditions.ts +1 -1
  31. package/data/formats-data.ts +7 -8
  32. package/data/mods/gen1/formats-data.ts +1 -1
  33. package/data/mods/gen1/moves.ts +5 -0
  34. package/data/mods/gen1/scripts.ts +3 -2
  35. package/data/mods/gen3/formats-data.ts +3 -3
  36. package/data/mods/gen6/formats-data.ts +64 -64
  37. package/data/rulesets.ts +92 -1
  38. package/package.json +2 -2
  39. package/sim/battle-stream.ts +3 -0
  40. package/sim/exported-global-types.ts +2 -0
  41. package/sim/global-types.ts +2 -0
  42. package/sim/pokemon.ts +2 -0
package/data/rulesets.ts CHANGED
@@ -1869,7 +1869,7 @@ export const Rulesets: {[k: string]: FormatData} = {
1869
1869
  reevolutionmod: {
1870
1870
  effectType: "Rule",
1871
1871
  name: "Re-Evolution Mod",
1872
- desc: "Pokémon gain the boosts they would gain from evolving again",
1872
+ desc: "Pokémon gain the stat changes they would gain from evolving again.",
1873
1873
  ruleset: ['Overflow Stat Mod'],
1874
1874
  onBegin() {
1875
1875
  this.add('rule', 'Re-Evolution Mod: Pok\u00e9mon gain the boosts they would gain from evolving again');
@@ -1888,4 +1888,95 @@ export const Rulesets: {[k: string]: FormatData} = {
1888
1888
  return newSpecies;
1889
1889
  },
1890
1890
  },
1891
+ brokenrecordmod: {
1892
+ effectType: "Rule",
1893
+ name: "Broken Record Mod",
1894
+ desc: `Pokémon can hold a TR to use that move in battle.`,
1895
+ onValidateSet(set) {
1896
+ if (!set.item) return;
1897
+ const item = this.dex.items.get(set.item);
1898
+ if (!/^tr\d\d/i.test(item.name)) return;
1899
+ const moveName = item.desc.split('move ')[1].split('.')[0];
1900
+ if (set.moves.map(this.toID).includes(this.toID(moveName))) {
1901
+ return [
1902
+ `${set.species} can't run ${item.name} (${moveName}) as its item because it already has that move in its moveset.`,
1903
+ ];
1904
+ }
1905
+ },
1906
+ onValidateTeam(team) {
1907
+ const trs = new Set<string>();
1908
+ for (const set of team) {
1909
+ if (!set.item) continue;
1910
+ const item = this.dex.items.get(set.item).name;
1911
+ if (!/^tr\d\d/i.test(item)) continue;
1912
+ if (trs.has(item)) {
1913
+ return [`Your team already has a Pok\u00e9mon with ${item}.`];
1914
+ }
1915
+ trs.add(item);
1916
+ }
1917
+ },
1918
+ onTakeItem(item) {
1919
+ return !/^tr\d\d/i.test(item.name);
1920
+ },
1921
+ onModifyMove(move) {
1922
+ if (move.id === 'knockoff') {
1923
+ move.onBasePower = function (basePower, source, target, m) {
1924
+ const item = target.getItem();
1925
+ if (!this.singleEvent('TakeItem', item, target.itemState, target, target, m, item)) return;
1926
+ // Very hardcode but I'd prefer to not make a mod for one damage calculation change
1927
+ if (item.id && !/^tr\d\d/i.test(item.id)) {
1928
+ return this.chainModify(1.5);
1929
+ }
1930
+ };
1931
+ } else if (move.id === 'fling') {
1932
+ move.onPrepareHit = function (target, source, m) {
1933
+ if (source.ignoringItem()) return false;
1934
+ const item = source.getItem();
1935
+ if (!this.singleEvent('TakeItem', item, source.itemState, source, source, m, item)) return false;
1936
+ if (!item.fling) return false;
1937
+ if (/^tr\d\d/i.test(item.id)) return false;
1938
+ m.basePower = item.fling.basePower;
1939
+ if (item.isBerry) {
1940
+ m.onHit = function (foe) {
1941
+ if (this.singleEvent('Eat', item, null, foe, null, null)) {
1942
+ this.runEvent('EatItem', foe, null, null, item);
1943
+ if (item.id === 'leppaberry') foe.staleness = 'external';
1944
+ }
1945
+ if (item.onEat) foe.ateBerry = true;
1946
+ };
1947
+ } else if (item.fling.effect) {
1948
+ m.onHit = item.fling.effect;
1949
+ } else {
1950
+ if (!m.secondaries) m.secondaries = [];
1951
+ if (item.fling.status) {
1952
+ m.secondaries.push({status: item.fling.status});
1953
+ } else if (item.fling.volatileStatus) {
1954
+ m.secondaries.push({volatileStatus: item.fling.volatileStatus});
1955
+ }
1956
+ }
1957
+ source.addVolatile('fling');
1958
+ };
1959
+ }
1960
+ },
1961
+ onBegin() {
1962
+ for (const pokemon of this.getAllPokemon()) {
1963
+ const item = pokemon.getItem();
1964
+ if (/^tr\d\d/i.test(item.name)) {
1965
+ const move = this.dex.moves.get(item.desc.split('move ')[1].split('.')[0]);
1966
+ pokemon.moveSlots = (pokemon as any).baseMoveSlots = [
1967
+ ...pokemon.baseMoveSlots, {
1968
+ id: move.id,
1969
+ move: move.name,
1970
+ pp: move.pp * 8 / 5,
1971
+ maxpp: move.pp * 8 / 5,
1972
+ target: move.target,
1973
+ disabled: false,
1974
+ disabledSource: '',
1975
+ used: false,
1976
+ },
1977
+ ];
1978
+ }
1979
+ }
1980
+ },
1981
+ },
1891
1982
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/sim",
3
- "version": "0.5.22",
3
+ "version": "0.5.23",
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",
@@ -27,7 +27,7 @@
27
27
  "sim"
28
28
  ],
29
29
  "dependencies": {
30
- "@pkmn/sets": "^3.0.0",
30
+ "@pkmn/sets": "^3.1.0",
31
31
  "@pkmn/streams": "^1.0.0"
32
32
  },
33
33
  "devDependencies": {
@@ -211,6 +211,9 @@ export class BattleStream extends Streams.ObjectReadWriteStream<string> {
211
211
  case 'requestlog':
212
212
  this.push(`requesteddata\n${this.battle!.inputLog.join('\n')}`);
213
213
  break;
214
+ case 'requestexport':
215
+ this.push(`requesteddata\n${this.battle!.prngSeed}\n${this.battle!.inputLog.join('\n')}`);
216
+ break;
214
217
  case 'requestteam':
215
218
  message = message.trim();
216
219
  const slotNum = parseInt(message.slice(1)) - 1;
@@ -515,6 +515,7 @@ export namespace RandomTeamsTypes {
515
515
  shiny: boolean;
516
516
  nature?: string;
517
517
  happiness?: number;
518
+ dynamaxLevel?: number;
518
519
  gigantamax?: boolean;
519
520
  }
520
521
  export interface RandomFactorySet {
@@ -530,6 +531,7 @@ export namespace RandomTeamsTypes {
530
531
  ivs: SparseStatsTable;
531
532
  nature: string;
532
533
  moves: string[];
534
+ dynamaxLevel?: number;
533
535
  gigantamax?: boolean;
534
536
  }
535
537
  }
@@ -515,6 +515,7 @@ namespace RandomTeamsTypes {
515
515
  shiny: boolean;
516
516
  nature?: string;
517
517
  happiness?: number;
518
+ dynamaxLevel?: number;
518
519
  gigantamax?: boolean;
519
520
  }
520
521
  export interface RandomFactorySet {
@@ -530,6 +531,7 @@ namespace RandomTeamsTypes {
530
531
  ivs: SparseStatsTable;
531
532
  nature: string;
532
533
  moves: string[];
534
+ dynamaxLevel?: number;
533
535
  gigantamax?: boolean;
534
536
  }
535
537
  }
package/sim/pokemon.ts CHANGED
@@ -77,6 +77,7 @@ export class Pokemon {
77
77
  readonly gender: GenderName;
78
78
  readonly happiness: number;
79
79
  readonly pokeball: string;
80
+ readonly dynamaxLevel: number;
80
81
  readonly gigantamax: boolean;
81
82
 
82
83
  /** Transform keeps the original pre-transformed Hidden Power in Gen 2-4. */
@@ -326,6 +327,7 @@ export class Pokemon {
326
327
  if (this.gender === 'N') this.gender = '';
327
328
  this.happiness = typeof set.happiness === 'number' ? this.battle.clampIntRange(set.happiness, 0, 255) : 255;
328
329
  this.pokeball = this.set.pokeball || 'pokeball';
330
+ this.dynamaxLevel = typeof set.dynamaxLevel === 'number' ? this.battle.clampIntRange(set.dynamaxLevel, 0, 10) : 10;
329
331
  this.gigantamax = this.set.gigantamax || false;
330
332
 
331
333
  this.baseMoveSlots = [];