@pkmn/sim 0.5.4 → 0.5.5

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/data/pokedex.ts CHANGED
@@ -16917,7 +16917,7 @@ export const Pokedex: {[speciesid: string]: SpeciesData} = {
16917
16917
  types: ["Poison", "Flying"],
16918
16918
  gender: "N",
16919
16919
  baseStats: {hp: 85, atk: 70, def: 113, spa: 118, spd: 90, spe: 64},
16920
- abilities: {0: "Stamina"},
16920
+ abilities: {0: "Stamina", H: "Power of Alchemy"},
16921
16921
  heightm: 0.8,
16922
16922
  weightkg: 11.5,
16923
16923
  color: "Purple",
package/data/tags.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import {Ability, Item, Move, Species} from '../sim/exported-global-types';
2
+
1
3
  interface TagData {
2
4
  name: string;
3
5
  desc?: string;
@@ -195,7 +197,7 @@ export const Tags: {[id: string]: TagData} = {
195
197
  nduubl: {
196
198
  name: "ND UUBL",
197
199
  speciesFilter: species => [
198
- 'Aerodactyl-Mega', 'Azumarill', 'Blacephalon', 'Diancie-Mega', 'Gallade-Mega', 'Gardevoir-Mega', 'Gengar', 'Gyarados', 'Gyarados-Mega',
200
+ 'Aerodactyl-Mega', 'Blacephalon', 'Diancie-Mega', 'Gallade-Mega', 'Gardevoir-Mega', 'Gengar', 'Gyarados', 'Gyarados-Mega',
199
201
  'Hawlucha', 'Heracross-Mega', 'Hoopa-Unbound', 'Hydreigon', 'Jirachi', 'Latias', 'Latias-Mega', 'Latios', 'Latios-Mega', 'Manaphy',
200
202
  'Medicham-Mega', 'Mew', 'Pinsir-Mega', 'Sableye-Mega', 'Slowbro-Mega', 'Slowking-Galar', 'Thundurus', 'Thundurus-Therian', 'Venusaur-Mega',
201
203
  'Xurkitree', 'Zapdos-Galar',
@@ -270,8 +270,8 @@ export const AbilitiesText: {[k: string]: AbilityText} = {
270
270
  },
271
271
  dazzling: {
272
272
  name: "Dazzling",
273
- desc: "While this Pokemon is active, priority moves from opposing Pokemon targeted at allies are prevented from having an effect.",
274
- shortDesc: "While this Pokemon is active, allies are protected from opposing priority moves.",
273
+ desc: "Priority moves used by opposing Pokemon targeting this Pokemon or its allies are prevented from having an effect.",
274
+ shortDesc: "This Pokemon and its allies are protected from opposing priority moves.",
275
275
 
276
276
  block: "#damp",
277
277
  },
@@ -1088,8 +1088,8 @@ export const AbilitiesText: {[k: string]: AbilityText} = {
1088
1088
  },
1089
1089
  queenlymajesty: {
1090
1090
  name: "Queenly Majesty",
1091
- desc: "While this Pokemon is active, priority moves from opposing Pokemon targeted at allies are prevented from having an effect.",
1092
- shortDesc: "While this Pokemon is active, allies are protected from opposing priority moves.",
1091
+ desc: "Priority moves used by opposing Pokemon targeting this Pokemon or its allies are prevented from having an effect.",
1092
+ shortDesc: "This Pokemon and its allies are protected from opposing priority moves.",
1093
1093
 
1094
1094
  block: "#damp",
1095
1095
  },
@@ -3484,27 +3484,27 @@ export const MovesText: {[k: string]: MoveText} = {
3484
3484
  },
3485
3485
  maxairstream: {
3486
3486
  name: "Max Airstream",
3487
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Speed of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute.",
3487
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Speed of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3488
3488
  shortDesc: "Base move affects power. Allies: +1 Speed.",
3489
3489
  },
3490
3490
  maxdarkness: {
3491
3491
  name: "Max Darkness",
3492
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Defense of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute.",
3492
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Defense of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3493
3493
  shortDesc: "Base move affects power. Foes: -1 Sp. Def.",
3494
3494
  },
3495
3495
  maxflare: {
3496
3496
  name: "Max Flare",
3497
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Sunny Day begins.",
3497
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Sunny Day begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3498
3498
  shortDesc: "Base move affects power. Starts Sunny Day.",
3499
3499
  },
3500
3500
  maxflutterby: {
3501
3501
  name: "Max Flutterby",
3502
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Attack of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute.",
3502
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Attack of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3503
3503
  shortDesc: "Base move affects power. Foes: -1 Sp. Atk.",
3504
3504
  },
3505
3505
  maxgeyser: {
3506
3506
  name: "Max Geyser",
3507
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Rain Dance begins.",
3507
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Rain Dance begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3508
3508
  shortDesc: "Base move affects power. Starts Rain Dance.",
3509
3509
  },
3510
3510
  maxguard: {
@@ -3516,67 +3516,67 @@ export const MovesText: {[k: string]: MoveText} = {
3516
3516
  },
3517
3517
  maxhailstorm: {
3518
3518
  name: "Max Hailstorm",
3519
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Hail begins.",
3519
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Hail begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3520
3520
  shortDesc: "Base move affects power. Starts Hail.",
3521
3521
  },
3522
3522
  maxknuckle: {
3523
3523
  name: "Max Knuckle",
3524
- desc: "Boosts the user and its allies' Attack by 1 stage. BP scales with the base move's BP.",
3524
+ desc: "Boosts the user and its allies' Attack by 1 stage. BP scales with the base move's BP. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3525
3525
  shortDesc: "Base move affects power. Allies: +1 Attack.",
3526
3526
  },
3527
3527
  maxlightning: {
3528
3528
  name: "Max Lightning",
3529
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Electric Terrain begins.",
3529
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Electric Terrain begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3530
3530
  shortDesc: "Base move affects power. Starts Electric Terrain.",
3531
3531
  },
3532
3532
  maxmindstorm: {
3533
3533
  name: "Max Mindstorm",
3534
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Psychic Terrain begins.",
3534
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Psychic Terrain begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3535
3535
  shortDesc: "Base move affects power. Starts Psychic Terrain.",
3536
3536
  },
3537
3537
  maxooze: {
3538
3538
  name: "Max Ooze",
3539
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Attack of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute.",
3539
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Attack of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3540
3540
  shortDesc: "Base move affects power. Allies: +1 Sp. Atk.",
3541
3541
  },
3542
3542
  maxovergrowth: {
3543
3543
  name: "Max Overgrowth",
3544
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Grassy Terrain begins.",
3544
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Grassy Terrain begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3545
3545
  shortDesc: "Base move affects power. Starts Grassy Terrain.",
3546
3546
  },
3547
3547
  maxphantasm: {
3548
3548
  name: "Max Phantasm",
3549
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Defense of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute.",
3549
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Defense of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3550
3550
  shortDesc: "Base move affects power. Foes: -1 Defense.",
3551
3551
  },
3552
3552
  maxquake: {
3553
3553
  name: "Max Quake",
3554
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Defense of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute.",
3554
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Special Defense of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3555
3555
  shortDesc: "Base move affects power. Allies: +1 Sp. Def.",
3556
3556
  },
3557
3557
  maxrockfall: {
3558
3558
  name: "Max Rockfall",
3559
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Sandstorm begins.",
3559
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Sandstorm begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3560
3560
  shortDesc: "Base move affects power. Starts Sandstorm.",
3561
3561
  },
3562
3562
  maxstarfall: {
3563
3563
  name: "Max Starfall",
3564
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Misty Terrain begins.",
3564
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the effect of Misty Terrain begins. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3565
3565
  shortDesc: "Base move affects power. Starts Misty Terrain.",
3566
3566
  },
3567
3567
  maxsteelspike: {
3568
3568
  name: "Max Steelspike",
3569
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Defense of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute.",
3569
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Defense of each Pokemon on the user's side is raised by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3570
3570
  shortDesc: "Base move affects power. Allies: +1 Defense.",
3571
3571
  },
3572
3572
  maxstrike: {
3573
3573
  name: "Max Strike",
3574
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Speed of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute.",
3574
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Speed of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3575
3575
  shortDesc: "Base move affects power. Foes: -1 Speed.",
3576
3576
  },
3577
3577
  maxwyrmwind: {
3578
3578
  name: "Max Wyrmwind",
3579
- desc: "Power is equal to the base move's Max Move power. If this move is successful, the Attack of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute.",
3579
+ desc: "Power is equal to the base move's Max Move power. If this move is successful, the Attack of each Pokemon on the opposing side is lowered by 1 stage, even if they have a substitute. This effect does not happen if the user is not Dynamaxed. If this move is used as a base move, it deals damage with a power of 0.",
3580
3580
  shortDesc: "Base move affects power. Foes: -1 Attack.",
3581
3581
  },
3582
3582
  meanlook: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/sim",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
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.1.3"
34
+ "mocha": "^9.1.4"
35
35
  },
36
36
  "scripts": {
37
37
  "compile": "tsc -p .",
@@ -1285,7 +1285,10 @@ export class BattleActions {
1285
1285
  this.battle.runEvent('ModifySecondaries', target, source, moveData, moveData.secondaries.slice());
1286
1286
  for (const secondary of secondaries) {
1287
1287
  const secondaryRoll = this.battle.random(100);
1288
- if (typeof secondary.chance === 'undefined' || secondaryRoll < secondary.chance) {
1288
+ // User stat boosts or target stat drops can possibly overflow if it goes beyond 256
1289
+ const secondaryOverflow = (secondary.boosts || secondary.self);
1290
+ if (typeof secondary.chance === 'undefined' ||
1291
+ secondaryRoll < (secondaryOverflow ? secondary.chance % 256 : secondary.chance)) {
1289
1292
  this.moveHit(target, source, move, secondary, true, isSelf);
1290
1293
  }
1291
1294
  }
@@ -340,6 +340,10 @@ export class RuleTable extends Map<string, string> {
340
340
  throw new Error(`maxForcedLevel is now a rule: "Adjust Level Down = NUMBER"`);
341
341
  }
342
342
  }
343
+
344
+ hasComplexBans() {
345
+ return (this.complexBans?.length > 0) || (this.complexTeamBans?.length > 0);
346
+ }
343
347
  }
344
348
 
345
349
  export class Format extends BasicEffect implements Readonly<BasicEffect> {
@@ -799,7 +803,6 @@ export class DexFormats {
799
803
  case '-':
800
804
  case '*':
801
805
  case '+':
802
- if (format?.team) throw new Error(`We don't currently support bans in generated teams`);
803
806
  if (rule.slice(1).includes('>') || rule.slice(1).includes('+')) {
804
807
  let buf = rule.slice(1);
805
808
  const gtIndex = buf.lastIndexOf('>');
package/sim/index.ts CHANGED
@@ -9,5 +9,6 @@ export {RandomPlayerAI} from './tools/random-player-ai';
9
9
  export {Side} from './side';
10
10
  export {Teams} from './teams';
11
11
  export {TeamValidator} from './team-validator';
12
+ export {Tags} from '../data/tags';
12
13
 
13
14
  export * from './exported-global-types';
@@ -26,6 +26,8 @@ import {
26
26
  import {Dex, toID} from './dex';
27
27
  import {Utils} from '../lib';
28
28
  import {Tags} from '../data/tags';
29
+ import {Teams} from './teams';
30
+ import {PRNG} from './prng';
29
31
 
30
32
  /**
31
33
  * Describes a possible way to get a pokemon. Is not exhaustive!
@@ -252,6 +254,16 @@ export class TeamValidator {
252
254
  `If you're not using a custom client, please report this as a bug. If you are, remember to use \`/utm null\` before starting a game in this format.`,
253
255
  ];
254
256
  }
257
+ const testTeamSeed = PRNG.generateSeed();
258
+ try {
259
+ const testTeamGenerator = Teams.getGenerator(format, testTeamSeed);
260
+ testTeamGenerator.getTeam(options as any); // Throws error if generation fails
261
+ } catch (e) {
262
+ return [
263
+ `${format.name}'s team generator (${format.team}) failed using these rules and seed (${testTeamSeed}):-`,
264
+ `${e}`,
265
+ ];
266
+ }
255
267
  return null;
256
268
  }
257
269
  if (!team) {