@pkmn/sim 0.5.1 → 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.
Files changed (88) hide show
  1. package/build/config/formats.js +373 -289
  2. package/build/config/formats.js.map +1 -1
  3. package/build/data/abilities.js +5 -1
  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/formats-data.js +91 -92
  8. package/build/data/formats-data.js.map +1 -1
  9. package/build/data/items.js +5 -5
  10. package/build/data/items.js.map +1 -1
  11. package/build/data/learnsets.js +1 -1
  12. package/build/data/learnsets.js.map +1 -1
  13. package/build/data/mods/gen1/formats-data.js +190 -190
  14. package/build/data/mods/gen1/formats-data.js.map +1 -1
  15. package/build/data/mods/gen1/moves.js +1 -2
  16. package/build/data/mods/gen1/moves.js.map +1 -1
  17. package/build/data/mods/gen1/scripts.js +12 -0
  18. package/build/data/mods/gen1/scripts.js.map +1 -1
  19. package/build/data/mods/gen2/formats-data.js +2 -2
  20. package/build/data/mods/gen2/formats-data.js.map +1 -1
  21. package/build/data/mods/gen3/formats-data.js +12 -12
  22. package/build/data/mods/gen3/formats-data.js.map +1 -1
  23. package/build/data/mods/gen4/moves.js +22 -0
  24. package/build/data/mods/gen4/moves.js.map +1 -1
  25. package/build/data/mods/gen5/formats-data.js +172 -155
  26. package/build/data/mods/gen5/formats-data.js.map +1 -1
  27. package/build/data/mods/gen6/formats-data.js +1 -1
  28. package/build/data/mods/gen7/formats-data.js +1 -1
  29. package/build/data/mods/gen7/formats-data.js.map +1 -1
  30. package/build/data/mods/gen7/moves.js +154 -0
  31. package/build/data/mods/gen7/moves.js.map +1 -1
  32. package/build/data/moves.js +47 -20
  33. package/build/data/moves.js.map +1 -1
  34. package/build/data/pokedex.js +3 -3
  35. package/build/data/pokedex.js.map +1 -1
  36. package/build/data/rulesets.js +48 -5
  37. package/build/data/rulesets.js.map +1 -1
  38. package/build/data/tags.d.ts +1 -0
  39. package/build/data/tags.js +4 -3
  40. package/build/data/tags.js.map +1 -1
  41. package/build/data/text/abilities.js +4 -4
  42. package/build/data/text/abilities.js.map +1 -1
  43. package/build/data/text/moves.js +19 -19
  44. package/build/data/text/moves.js.map +1 -1
  45. package/build/sim/battle-actions.js +12 -4
  46. package/build/sim/battle-actions.js.map +1 -1
  47. package/build/sim/dex-formats.d.ts +1 -0
  48. package/build/sim/dex-formats.js +3 -2
  49. package/build/sim/dex-formats.js.map +1 -1
  50. package/build/sim/exported-global-types.d.ts +1 -0
  51. package/build/sim/global-types.d.ts +1 -0
  52. package/build/sim/index.d.ts +1 -0
  53. package/build/sim/index.js +3 -1
  54. package/build/sim/index.js.map +1 -1
  55. package/build/sim/pokemon.js +1 -1
  56. package/build/sim/pokemon.js.map +1 -1
  57. package/build/sim/team-validator.js +16 -0
  58. package/build/sim/team-validator.js.map +1 -1
  59. package/config/formats.ts +379 -292
  60. package/data/abilities.ts +3 -1
  61. package/data/aliases.ts +2 -2
  62. package/data/formats-data.ts +91 -92
  63. package/data/items.ts +5 -5
  64. package/data/learnsets.ts +1 -1
  65. package/data/mods/gen1/formats-data.ts +190 -190
  66. package/data/mods/gen1/moves.ts +1 -2
  67. package/data/mods/gen1/scripts.ts +11 -0
  68. package/data/mods/gen2/formats-data.ts +2 -2
  69. package/data/mods/gen3/formats-data.ts +12 -12
  70. package/data/mods/gen4/moves.ts +21 -0
  71. package/data/mods/gen5/formats-data.ts +172 -155
  72. package/data/mods/gen6/formats-data.ts +1 -1
  73. package/data/mods/gen7/formats-data.ts +1 -1
  74. package/data/mods/gen7/moves.ts +150 -0
  75. package/data/moves.ts +46 -20
  76. package/data/pokedex.ts +3 -3
  77. package/data/rulesets.ts +44 -6
  78. package/data/tags.ts +6 -3
  79. package/data/text/abilities.ts +4 -4
  80. package/data/text/moves.ts +19 -19
  81. package/package.json +2 -2
  82. package/sim/battle-actions.ts +12 -4
  83. package/sim/dex-formats.ts +4 -1
  84. package/sim/exported-global-types.ts +1 -0
  85. package/sim/global-types.ts +1 -0
  86. package/sim/index.ts +1 -0
  87. package/sim/pokemon.ts +1 -1
  88. package/sim/team-validator.ts +15 -0
@@ -438,7 +438,8 @@ export class BattleActions {
438
438
  target = targets[targets.length - 1]; // in case of redirection
439
439
  }
440
440
 
441
- if (!sourceEffect || sourceEffect.id === 'pursuit') {
441
+ const callerMoveForPressure = sourceEffect && (sourceEffect as ActiveMove).pp ? sourceEffect as ActiveMove : null;
442
+ if (!sourceEffect || callerMoveForPressure || sourceEffect.id === 'pursuit') {
442
443
  let extraPP = 0;
443
444
  for (const source of pressureTargets) {
444
445
  const ppDrop = this.battle.runEvent('DeductPP', source, pokemon, move);
@@ -447,7 +448,7 @@ export class BattleActions {
447
448
  }
448
449
  }
449
450
  if (extraPP > 0) {
450
- pokemon.deductPP(moveOrMoveName, extraPP);
451
+ pokemon.deductPP(callerMoveForPressure || moveOrMoveName, extraPP);
451
452
  }
452
453
  }
453
454
 
@@ -1284,7 +1285,10 @@ export class BattleActions {
1284
1285
  this.battle.runEvent('ModifySecondaries', target, source, moveData, moveData.secondaries.slice());
1285
1286
  for (const secondary of secondaries) {
1286
1287
  const secondaryRoll = this.battle.random(100);
1287
- 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)) {
1288
1292
  this.moveHit(target, source, move, secondary, true, isSelf);
1289
1293
  }
1290
1294
  }
@@ -1447,7 +1451,7 @@ export class BattleActions {
1447
1451
  this.battle.heal(pokemon.maxhp, pokemon, pokemon, zPower);
1448
1452
  break;
1449
1453
  case 'healreplacement':
1450
- move.self = {slotCondition: 'healreplacement'};
1454
+ pokemon.side.addSlotCondition(pokemon, 'healreplacement', pokemon, move);
1451
1455
  break;
1452
1456
  case 'clearnegativeboost':
1453
1457
  const boosts: SparseBoostsTable = {};
@@ -1575,6 +1579,10 @@ export class BattleActions {
1575
1579
 
1576
1580
  if (!basePower) return 0;
1577
1581
  basePower = this.battle.clampIntRange(basePower, 1);
1582
+ // Hacked Max Moves have 0 base power, even if you Dynamax
1583
+ if ((!source.volatiles['dynamax'] && move.isMax) || (move.isMax && this.dex.moves.get(move.baseMove).isMax)) {
1584
+ basePower = 0;
1585
+ }
1578
1586
 
1579
1587
  const level = source.level;
1580
1588
 
@@ -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('>');
@@ -309,6 +309,7 @@ export interface ModdedBattlePokemon {
309
309
  inherit?: true;
310
310
  lostItemForDelibird?: Item | null;
311
311
  boostBy?: (this: Pokemon, boost: SparseBoostsTable) => boolean | number;
312
+ clearBoosts?: (this: Pokemon) => void;
312
313
  calculateStat?: (this: Pokemon, statName: StatIDExceptHP, boost: number, modifier?: number) => number;
313
314
  cureStatus?: (this: Pokemon, silent?: boolean) => boolean;
314
315
  getAbility?: (this: Pokemon) => Ability;
@@ -309,6 +309,7 @@ interface ModdedBattlePokemon {
309
309
  inherit?: true;
310
310
  lostItemForDelibird?: Item | null;
311
311
  boostBy?: (this: Pokemon, boost: SparseBoostsTable) => boolean | number;
312
+ clearBoosts?: (this: Pokemon) => void;
312
313
  calculateStat?: (this: Pokemon, statName: StatIDExceptHP, boost: number, modifier?: number) => number;
313
314
  cureStatus?: (this: Pokemon, silent?: boolean) => boolean;
314
315
  getAbility?: (this: Pokemon) => Ability;
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';
package/sim/pokemon.ts CHANGED
@@ -794,7 +794,7 @@ export class Pokemon {
794
794
  for (const pokemon of this.battle.getAllActive()) {
795
795
  // can't use hasAbility because it would lead to infinite recursion
796
796
  if (pokemon.ability === ('neutralizinggas' as ID) && !pokemon.volatiles['gastroacid'] &&
797
- !pokemon.abilityState.ending) {
797
+ !pokemon.transformed && !pokemon.abilityState.ending) {
798
798
  neutralizinggas = true;
799
799
  break;
800
800
  }
@@ -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) {
@@ -540,6 +552,9 @@ export class TeamValidator {
540
552
  problem = this.checkItem(set, item, setHas);
541
553
  if (problem) problems.push(problem);
542
554
  if (ruleTable.has('obtainablemisc')) {
555
+ if (dex.gen === 4 && item.id === 'griseousorb' && species.num !== 487) {
556
+ problems.push(`${set.name} cannot hold the Griseous Orb.`, `(In Gen 4, only Giratina could hold the Griseous Orb).`);
557
+ }
543
558
  if (dex.gen <= 1) {
544
559
  if (item.id) {
545
560
  // no items allowed