@pkmn/sim 0.5.8 → 0.5.11

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 (50) hide show
  1. package/build/config/formats.js +390 -238
  2. package/build/config/formats.js.map +1 -1
  3. package/build/data/aliases.js +1 -2
  4. package/build/data/aliases.js.map +1 -1
  5. package/build/data/formats-data.js +3 -3
  6. package/build/data/formats-data.js.map +1 -1
  7. package/build/data/learnsets.js +5 -6
  8. package/build/data/learnsets.js.map +1 -1
  9. package/build/data/mods/gen3/formats-data.js +1 -1
  10. package/build/data/mods/gen3/formats-data.js.map +1 -1
  11. package/build/data/mods/gen7/formats-data.js +1 -1
  12. package/build/data/mods/gen7/formats-data.js.map +1 -1
  13. package/build/data/mods/gen7/pokedex.js +1 -0
  14. package/build/data/mods/gen7/pokedex.js.map +1 -1
  15. package/build/data/pokedex.js +2 -2
  16. package/build/data/rulesets.js +0 -139
  17. package/build/data/rulesets.js.map +1 -1
  18. package/build/data/tags.js +4 -4
  19. package/build/data/tags.js.map +1 -1
  20. package/build/lib/index.js +5 -1
  21. package/build/lib/index.js.map +1 -1
  22. package/build/lib/streams.js +5 -1
  23. package/build/lib/streams.js.map +1 -1
  24. package/build/sim/battle-actions.js +0 -6
  25. package/build/sim/battle-actions.js.map +1 -1
  26. package/build/sim/battle-queue.js +1 -3
  27. package/build/sim/battle-queue.js.map +1 -1
  28. package/build/sim/dex.js +5 -1
  29. package/build/sim/dex.js.map +1 -1
  30. package/build/sim/index.js +5 -1
  31. package/build/sim/index.js.map +1 -1
  32. package/build/sim/teams.js +5 -1
  33. package/build/sim/teams.js.map +1 -1
  34. package/build/sim/tools/index.js +5 -1
  35. package/build/sim/tools/index.js.map +1 -1
  36. package/build/sim/tools/runner.js +5 -1
  37. package/build/sim/tools/runner.js.map +1 -1
  38. package/config/formats.ts +376 -237
  39. package/data/aliases.ts +1 -2
  40. package/data/formats-data.ts +3 -3
  41. package/data/learnsets.ts +5 -6
  42. package/data/mods/gen3/formats-data.ts +1 -1
  43. package/data/mods/gen7/formats-data.ts +1 -1
  44. package/data/mods/gen7/pokedex.ts +1 -0
  45. package/data/pokedex.ts +2 -2
  46. package/data/rulesets.ts +0 -125
  47. package/data/tags.ts +4 -4
  48. package/package.json +2 -2
  49. package/sim/battle-actions.ts +0 -7
  50. package/sim/battle-queue.ts +1 -3
package/config/formats.ts CHANGED
@@ -206,7 +206,7 @@ export const Formats: FormatList = [
206
206
  ],
207
207
  banlist: [
208
208
  'Calyrex-Ice', 'Calyrex-Shadow', 'Cinderace', 'Dialga', 'Dragonite', 'Eternatus', 'Genesect', 'Giratina', 'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Jirachi',
209
- 'Kyogre', 'Kyurem-Black', 'Kyurem-White', 'Lugia', 'Lunala', 'Magearna', 'Marshadow', 'Melmetal', 'Mew', 'Mewtwo', 'Mimikyu', 'Necrozma-Dawn-Wings',
209
+ 'Kyogre', 'Kyurem-Black', 'Kyurem-White', 'Lugia', 'Lunala', 'Magearna', 'Marshadow', 'Melmetal', 'Mew', 'Mewtwo', 'Mimikyu', 'Necrozma', 'Necrozma-Dawn-Wings',
210
210
  'Necrozma-Dusk-Mane', 'Palkia', 'Rayquaza', 'Reshiram', 'Sableye', 'Snorlax', 'Solgaleo', 'Victini', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned',
211
211
  'Zamazenta', 'Zamazenta-Crowned', 'Zekrom', 'Moody', 'Power Construct', 'Bright Powder', 'Focus Band', 'Focus Sash', 'Lax Incense', 'Quick Claw', 'Perish Song',
212
212
  ],
@@ -234,8 +234,8 @@ export const Formats: FormatList = [
234
234
  mod: 'gen8',
235
235
  ruleset: ['[Gen 8] PU'],
236
236
  banlist: [
237
- 'PU', 'Aurorus', 'Centiskorch', 'Drampa', 'Exeggutor-Alola', 'Gallade', 'Haunter', 'Magmortar', 'Magneton', 'Omastar', 'Rotom-Frost',
238
- 'Turtonator', 'Vanilluxe', 'Vikavolt', 'Silvally-Dragon', 'Silvally-Ground', 'Sneasel', 'Damp Rock', 'Grassy Seed',
237
+ 'PU', 'Arctovish', 'Aurorus', 'Centiskorch', 'Drampa', 'Exeggutor-Alola', 'Gallade', 'Haunter', 'Magmortar', 'Magneton', 'Omastar',
238
+ 'Rotom-Frost', 'Turtonator', 'Vanilluxe', 'Vikavolt', 'Silvally-Dragon', 'Silvally-Ground', 'Sneasel', 'Damp Rock', 'Grassy Seed',
239
239
  ],
240
240
  },
241
241
  {
@@ -481,7 +481,7 @@ export const Formats: FormatList = [
481
481
  ruleset: ['Standard NatDex', 'OHKO Clause', 'Evasion Moves Clause', 'Species Clause', 'Dynamax Clause', 'Sleep Clause Mod'],
482
482
  banlist: [
483
483
  'Alakazam-Mega', 'Arceus', 'Blastoise-Mega', 'Blaziken-Mega', 'Calyrex-Ice', 'Calyrex-Shadow', 'Cinderace', 'Darkrai',
484
- 'Darmanitan-Galar', 'Deoxys-Attack', 'Deoxys-Base', 'Deoxys-Speed', 'Dialga', 'Dracovish', 'Eternatus',
484
+ 'Darmanitan-Galar', 'Deoxys-Attack', 'Deoxys-Base', 'Deoxys-Speed', 'Dialga', 'Dracovish', 'Dragapult', 'Eternatus',
485
485
  'Genesect', 'Gengar-Mega', 'Giratina', 'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Kangaskhan-Mega', 'Kyogre', 'Kyurem-Black',
486
486
  'Kyurem-White', 'Landorus-Base', 'Lucario-Mega', 'Lugia', 'Lunala', 'Magearna', 'Marshadow', 'Metagross-Mega', 'Mewtwo',
487
487
  'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Necrozma-Ultra', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram',
@@ -511,16 +511,14 @@ export const Formats: FormatList = [
511
511
  'Drizzle', 'Drought',
512
512
  // Slowbronite is banned so it doesn't validate on Galarian Slowbro
513
513
  'Slowbronite',
514
- // NDOU suspect
515
- 'Dragapult',
516
514
  ],
517
515
  // Used to distinguish UU from below UU in the client
518
516
  restricted: [
519
- 'Aegislash', 'Alakazam-Base', 'Altaria-Mega', 'Amoonguss', 'Azumarill', 'Beedrill-Mega', 'Blaziken-Base', 'Breloom', 'Celesteela',
520
- 'Chandelure', 'Donphan', 'Dracozolt', 'Dragonite', 'Feraligatr', 'Gastrodon', 'Hatterene', 'Hippowdon', 'Infernape', 'Keldeo',
521
- 'Krookodile', 'Mamoswine', 'Mandibuzz', 'Manectric-Mega', 'Melmetal', 'Mienshao', 'Moltres-Base', 'Nidoking', 'Nidoqueen', 'Nihilego',
522
- 'Quagsire', 'Regieleki', 'Ribombee', 'Rotom-Heat', 'Rotom-Wash', 'Salamence', 'Scizor', 'Skarmory', 'Slowking-Base', 'Swampert-Base',
523
- 'Talonflame', 'Tangrowth', 'Tornadus-Base', 'Umbreon', 'Urshifu-Rapid-Strike',
517
+ 'Aegislash', 'Altaria-Mega', 'Amoonguss', 'Azumarill', 'Beedrill-Mega', 'Breloom', 'Celesteela', 'Chandelure', 'Donphan', 'Dracozolt',
518
+ 'Dragonite', 'Feraligatr', 'Gastrodon', 'Hatterene', 'Hippowdon', 'Infernape', 'Keldeo', 'Krookodile', 'Mamoswine', 'Mandibuzz',
519
+ 'Manectric-Mega', 'Melmetal', 'Mienshao', 'Moltres-Base', 'Nidoking', 'Nidoqueen', 'Nihilego', 'Quagsire', 'Regieleki', 'Ribombee',
520
+ 'Rotom-Heat', 'Rotom-Wash', 'Salamence', 'Scizor', 'Skarmory', 'Slowking-Base', 'Swampert-Base', 'Talonflame', 'Tangrowth', 'Tornadus-Base',
521
+ 'Umbreon', 'Urshifu-Rapid-Strike',
524
522
  ],
525
523
  },
526
524
  {
@@ -639,142 +637,201 @@ export const Formats: FormatList = [
639
637
  column: 2,
640
638
  },
641
639
  {
642
- name: "[Gen 8] Trademarked",
643
- desc: `Sacrifice your Pokémon's ability for a status move that activates on switch-in.`,
640
+ name: "[Gen 8] Shared Power",
641
+ desc: `Once a Pokémon switches in, its ability is shared with the rest of the team.`,
644
642
  threads: [
645
- `&bullet; <a href="https://www.smogon.com/forums/threads/3656980/">Trademarked</a>`,
643
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3660877/">Shared Power</a>`,
646
644
  ],
647
645
 
648
- mod: 'gen8',
646
+ mod: 'sharedpower',
649
647
  // searchShow: false,
650
648
  ruleset: ['Standard', 'Dynamax Clause'],
651
649
  banlist: [
652
- 'Calyrex-Ice', 'Calyrex-Shadow', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Dragapult', 'Eternatus', 'Kyurem-Black', 'Kyurem-White', 'Giratina',
653
- 'Giratina-Origin', 'Genesect', 'Groudon', 'Ho-Oh', 'Kartana', 'Kyogre', 'Lugia', 'Lunala', 'Magearna', 'Marowak-Alola', 'Marshadow', 'Melmetal',
654
- 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram', 'Solgaleo', 'Spectrier',
655
- 'Urshifu-Base', 'Victini', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom', 'Zygarde-Base',
656
- 'Arena Trap', 'Moody', 'Neutralizing Gas', 'Power Construct', 'Shadow Tag', 'Baton Pass',
657
- ],
658
- restricted: [
659
- 'Baneful Bunker', 'Block', 'Copycat', 'Corrosive Gas', 'Detect', 'Destiny Bond', 'Disable', 'Encore', 'Fairy Lock', 'Hypnosis', 'Ingrain',
660
- 'Instruct', 'Lovely Kiss', 'King\'s Shield', 'Mat Block', 'Mean Look', 'Memento', 'move:Metronome', 'Obstruct', 'Octolock', 'Nature Power',
661
- 'Parting Shot', 'Psycho Shift', 'Protect', 'Roar', 'Sing', 'Skill Swap', 'Sleep Powder', 'Sleep Talk', 'Spiky Shield', 'Spore', 'Substitute',
662
- 'Switcheroo', 'Teleport', 'Trick', 'Whirlwind', 'Wish', 'Yawn',
650
+ 'Calyrex-Ice', 'Calyrex-Shadow', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Eternatus', 'Genesect', 'Giratina',
651
+ 'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Kyogre', 'Kyurem-Black', 'Kyurem-White', 'Lugia', 'Lunala', 'Magearna',
652
+ 'Marshadow', 'Melmetal', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia',
653
+ 'Pheromosa', 'Rayquaza', 'Reshiram', 'Shedinja', 'Solgaleo', 'Urshifu-Base', 'Urshifu-Rapid-Strike',
654
+ 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom',
655
+ 'Arena Trap', 'Contrary', 'Drizzle ++ Swift Swim', 'Drought ++ Chlorophyll', 'Electric Surge ++ Surge Surfer',
656
+ 'Fur Coat', 'Guts', 'Harvest', 'Huge Power', 'Imposter', 'Innards Out', 'Libero', 'Magic Bounce', 'Magic Guard',
657
+ 'Magnet Pull', 'Mold Breaker', 'Moody', 'Neutralizing Gas', 'Power Construct', 'Queenly Majesty', 'Quick Draw',
658
+ 'Regenerator', 'Sand Rush', 'Sand Veil', 'Shadow Tag', 'Simple', 'Snow Cloak', 'Snow Warning ++ Slush Rush',
659
+ 'Speed Boost', 'Stakeout', 'Steelworker ++ Steely Spirit', 'Stench', 'Tinted Lens', 'Triage', 'Unaware',
660
+ 'Unburden', 'Water Bubble', 'King\'s Rock', 'Baton Pass',
663
661
  ],
664
- onValidateTeam(team, format, teamHas) {
665
- const problems = [];
666
- for (const trademark in teamHas.trademarks) {
667
- if (teamHas.trademarks[trademark] > 1) {
668
- problems.push(`You are limited to 1 of each Trademark.`, `(You have ${teamHas.trademarks[trademark]} Pok\u00e9mon with ${trademark} as a Trademark.)`);
662
+ getSharedPower(pokemon) {
663
+ const sharedPower = new Set<string>();
664
+ for (const ally of pokemon.side.pokemon) {
665
+ if (ally.previouslySwitchedIn > 0) {
666
+ if (pokemon.battle.dex.currentMod !== 'sharedpower' && ['trace', 'mirrorarmor'].includes(ally.baseAbility)) {
667
+ sharedPower.add('noability');
668
+ continue;
669
+ }
670
+ sharedPower.add(ally.baseAbility);
669
671
  }
670
672
  }
671
- return problems;
673
+ sharedPower.delete(pokemon.baseAbility);
674
+ return sharedPower;
672
675
  },
673
- validateSet(set, teamHas) {
674
- const dex = this.dex;
675
- const ability = dex.moves.get(set.ability);
676
- if (!ability.exists) { // Not even a real move
677
- return this.validateSet(set, teamHas);
676
+ onBeforeSwitchIn(pokemon) {
677
+ let format = this.format;
678
+ if (!format.getSharedPower) format = this.dex.formats.get('gen8sharedpower');
679
+ for (const ability of format.getSharedPower!(pokemon)) {
680
+ const effect = 'ability:' + ability;
681
+ pokemon.volatiles[effect] = {id: this.toID(effect), target: pokemon};
682
+ if (!pokemon.m.abils) pokemon.m.abils = [];
683
+ if (!pokemon.m.abils.includes(effect)) pokemon.m.abils.push(effect);
678
684
  }
679
- // Absolute trademark bans
680
- if (ability.category !== 'Status') {
681
- return [`${ability.name} is not a status move, and cannot be used as a trademark.`];
685
+ },
686
+ onSwitchInPriority: 2,
687
+ onSwitchIn(pokemon) {
688
+ let format = this.format;
689
+ if (!format.getSharedPower) format = this.dex.formats.get('gen8sharedpower');
690
+ for (const ability of format.getSharedPower!(pokemon)) {
691
+ if (ability === 'noability') {
692
+ this.hint(`Mirror Armor and Trace break in Shared Power formats that don't use Shared Power as a base, so they get removed from non-base users.`);
693
+ }
694
+ const effect = 'ability:' + ability;
695
+ delete pokemon.volatiles[effect];
696
+ pokemon.addVolatile(effect);
682
697
  }
683
- if (ability.forceSwitch || ability.selfSwitch) {
698
+ },
699
+ },
700
+ {
701
+ name: "[Gen 8] Cross Evolution",
702
+ desc: `Give a Pok&eacute;mon a Pok&eacute;mon name of the next evolution stage as a nickname to inherit stat changes, typing, abilities, and up to 2 moves from the next stage Pok&eacute;mon.`,
703
+ threads: [
704
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3657562/">Cross Evolution</a>`,
705
+ ],
706
+
707
+ mod: 'gen8',
708
+ // searchShow: false,
709
+ ruleset: ['Standard', 'Overflow Stat Mod', 'Dynamax Clause', '2 Ability Clause'],
710
+ banlist: ['Corsola-Galar', 'Sneasel', 'Type: Null', 'Arena Trap', 'Ice Scales', 'Moody', 'King\'s Rock', 'Baton Pass'],
711
+ restricted: ['Chansey', 'Lunala', 'Shedinja', 'Solgaleo', 'Gorilla Tactics', 'Huge Power', 'Pure Power', 'Shadow Tag'],
712
+ onValidateTeam(team) {
713
+ const names = new Set<ID>();
714
+ for (const set of team) {
715
+ const name = set.name;
716
+ if (names.has(this.dex.toID(name))) {
717
+ return [
718
+ `Your Pok\u00e9mon must have different nicknames.`,
719
+ `(You have more than one Pok\u00e9mon named '${name}')`,
720
+ ];
721
+ }
722
+ names.add(this.dex.toID(name));
723
+ }
724
+ if (!names.size) {
684
725
  return [
685
- `Force-switching and self-switching moves are banned from being used as trademarks.`,
686
- `(${ability.name} is a ${ability.forceSwitch ? 'force' : 'self'}-switching move.)`,
726
+ `${this.format.name} works using nicknames; your team has 0 nicknamed Pok\u00e9mon.`,
727
+ `(If this was intentional, add a nickname to one Pok\u00e9mon that isn't the name of a Pok\u00e9mon species.)`,
687
728
  ];
688
729
  }
689
- const irrevokablyRestricted = [
690
- 'Assist', 'Copycat', 'Metronome', 'Mirror Move', 'Sleep Talk', // Could call another unsafe trademark
691
- 'Recycle', 'Trace', // Causes endless turns
692
- 'Skill Swap', // Self-propagates indefinitely
693
- ];
694
- for (const m of set.moves) {
695
- const move = dex.moves.get(m);
696
- if (irrevokablyRestricted.includes(move.name)) {
697
- return [`${move.name} is banned from Trademark, irrespective of custom rules, because it can cause endless turns.`];
698
- }
730
+ },
731
+ checkCanLearn(move, species, lsetData, set) {
732
+ // @ts-ignore
733
+ if (!set.sp?.exists || !set.crossSpecies?.exists) {
734
+ return this.checkCanLearn(move, species, lsetData, set);
699
735
  }
700
- if (irrevokablyRestricted.includes(ability.name)) {
701
- return [`${ability.name} cannot safely function as a trademark.`];
736
+ // @ts-ignore
737
+ const problem = this.checkCanLearn(move, set.sp);
738
+ if (!problem) return null;
739
+ // @ts-ignore
740
+ if (!set.crossMovesLeft) return problem;
741
+ // @ts-ignore
742
+ if (this.checkCanLearn(move, set.crossSpecies)) return problem;
743
+ // @ts-ignore
744
+ set.crossMovesLeft--;
745
+ return null;
746
+ },
747
+ validateSet(set, teamHas) {
748
+ const crossSpecies = this.dex.species.get(set.name);
749
+ let problems = this.dex.formats.get('Pokemon').onChangeSet?.call(this, set, this.format) || null;
750
+ if (Array.isArray(problems) && problems.length) return problems;
751
+ const crossNonstandard = (!this.ruleTable.has('standardnatdex') && crossSpecies.isNonstandard === 'Past') ||
752
+ crossSpecies.isNonstandard === 'Future';
753
+ const crossIsCap = !this.ruleTable.has('+pokemontag:cap') && crossSpecies.isNonstandard === 'CAP';
754
+ if (!crossSpecies.exists || crossNonstandard || crossIsCap) return this.validateSet(set, teamHas);
755
+ const species = this.dex.species.get(set.species);
756
+ const check = this.checkSpecies(set, species, species, {});
757
+ if (check) return [check];
758
+ const nonstandard = !this.ruleTable.has('standardnatdex') && species.isNonstandard === 'Past';
759
+ const isCap = !this.ruleTable.has('+pokemontag:cap') && species.isNonstandard === 'CAP';
760
+ if (!species.exists || nonstandard || isCap || species === crossSpecies) return this.validateSet(set, teamHas);
761
+ if (!species.nfe) return [`${species.name} cannot cross evolve because it doesn't evolve.`];
762
+ const crossIsUnreleased = (crossSpecies.tier === "Unreleased" && crossSpecies.isNonstandard === "Unobtainable");
763
+ if (crossSpecies.battleOnly || crossIsUnreleased || !crossSpecies.prevo) {
764
+ return [`${species.name} cannot cross evolve into ${crossSpecies.name} because it isn't an evolution.`];
765
+ }
766
+ if (this.ruleTable.isRestrictedSpecies(crossSpecies)) {
767
+ return [`${species.name} cannot cross evolve into ${crossSpecies.name} because it is banned.`];
768
+ }
769
+ const crossPrevoSpecies = this.dex.species.get(crossSpecies.prevo);
770
+ if (!crossPrevoSpecies.prevo !== !species.prevo) {
771
+ return [
772
+ `${species.name} cannot cross evolve into ${crossSpecies.name} because they are not consecutive evolution stages.`,
773
+ ];
702
774
  }
703
- // Contingent trademark bans
704
- if (this.ruleTable.isRestricted(`move:${ability.id}`)) {
705
- return [`${ability.name} is restricted from being used as a trademark.`];
775
+ const item = this.dex.items.get(set.item);
776
+ if (item.itemUser?.length) {
777
+ if (!item.itemUser.includes(crossSpecies.name) || crossSpecies.name !== species.name) {
778
+ return [`${species.name} cannot use ${item.name} because it is cross evolved into ${crossSpecies.name}.`];
779
+ }
706
780
  }
707
- if (set.moves.map(this.toID).includes(ability.id)) {
708
- return [`${set.name} may not use ${ability.name} as both a trademark and one of its moves simultaneously.`];
781
+ const ability = this.dex.abilities.get(set.ability);
782
+ if (!this.ruleTable.isRestricted(`ability:${ability.id}`) || Object.values(species.abilities).includes(ability.name)) {
783
+ set.species = crossSpecies.name;
709
784
  }
710
- const customRules = this.format.customRules || [];
711
- if (!customRules.includes('!obtainableabilities')) customRules.push('!obtainableabilities');
712
785
 
713
- const TeamValidator: typeof import('../sim/team-validator').TeamValidator =
714
- require('../sim/team-validator').TeamValidator;
715
-
716
- const validator = new TeamValidator(dex.formats.get(`${this.format.id}@@@${customRules.join(',')}`));
717
- const moves = set.moves;
718
- set.moves = [ability.id];
719
- set.ability = dex.species.get(set.species).abilities['0'];
720
- let problems = validator.validateSet(set, {}) || [];
721
- if (problems.length) return problems;
722
- set.moves = moves;
723
- set.ability = dex.species.get(set.species).abilities['0'];
724
- problems = problems.concat(validator.validateSet(set, teamHas) || []);
725
- set.ability = ability.id;
726
- if (!teamHas.trademarks) teamHas.trademarks = {};
727
- teamHas.trademarks[ability.name] = (teamHas.trademarks[ability.name] || 0) + 1;
728
- return problems.length ? problems : null;
786
+ // @ts-ignore
787
+ set.sp = species;
788
+ // @ts-ignore
789
+ set.crossSpecies = crossSpecies;
790
+ // @ts-ignore
791
+ set.crossMovesLeft = 2;
792
+ problems = this.validateSet(set, teamHas);
793
+ set.name = crossSpecies.name;
794
+ set.species = species.name;
795
+ return problems;
729
796
  },
730
- pokemon: {
731
- getAbility() {
732
- const move = this.battle.dex.moves.get(this.battle.toID(this.ability));
733
- if (!move.exists) return Object.getPrototypeOf(this).getAbility.call(this);
734
- return {
735
- id: move.id,
736
- name: move.name,
737
- onStart(this: Battle, pokemon: Pokemon) {
738
- this.add('-activate', pokemon, 'ability: ' + move.name);
739
- this.actions.useMove(move, pokemon);
740
- },
741
- toString() {
742
- return "";
743
- },
744
- };
745
- },
797
+ onModifySpecies(species, target, source, effect) {
798
+ if (!target) return; // chat
799
+ if (effect && ['imposter', 'transform'].includes(effect.id)) return;
800
+ if (target.set.name === target.set.species) return;
801
+ const crossSpecies = this.dex.species.get(target.set.name);
802
+ if (!crossSpecies.exists) return;
803
+ if (species.battleOnly || !species.nfe) return;
804
+ const crossIsUnreleased = (crossSpecies.tier === "Unreleased" && crossSpecies.isNonstandard === "Unobtainable");
805
+ if (crossSpecies.battleOnly || crossIsUnreleased || !crossSpecies.prevo) return;
806
+ const crossPrevoSpecies = this.dex.species.get(crossSpecies.prevo);
807
+ if (!crossPrevoSpecies.prevo !== !species.prevo) return;
808
+
809
+ const mixedSpecies = this.dex.deepClone(species);
810
+ mixedSpecies.weightkg =
811
+ Math.max(0.1, +(species.weightkg + crossSpecies.weightkg - crossPrevoSpecies.weightkg)).toFixed(1);
812
+ mixedSpecies.nfe = false;
813
+ mixedSpecies.evos = [];
814
+ mixedSpecies.eggGroups = crossSpecies.eggGroups;
815
+ mixedSpecies.abilities = crossSpecies.abilities;
816
+ mixedSpecies.bst = 0;
817
+ let i: StatID;
818
+ for (i in species.baseStats) {
819
+ const statChange = crossSpecies.baseStats[i] - crossPrevoSpecies.baseStats[i];
820
+ mixedSpecies.baseStats[i] = this.clampIntRange(species.baseStats[i] + statChange, 1, 255);
821
+ mixedSpecies.bst += mixedSpecies.baseStats[i];
822
+ }
823
+ if (crossSpecies.types[0] !== crossPrevoSpecies.types[0]) mixedSpecies.types[0] = crossSpecies.types[0];
824
+ if (crossSpecies.types[1] !== crossPrevoSpecies.types[1]) {
825
+ mixedSpecies.types[1] = crossSpecies.types[1] || crossSpecies.types[0];
826
+ }
827
+ if (mixedSpecies.types[0] === mixedSpecies.types[1]) mixedSpecies.types = [mixedSpecies.types[0]];
828
+
829
+ return mixedSpecies;
746
830
  },
747
- },
748
- {
749
- name: "[Gen 8] Linked",
750
- desc: `The first two moves in a Pok&eacute;mon's moveset are used simultaneously.`,
751
- threads: [
752
- `&bullet; <a href="https://www.smogon.com/forums/threads/3660421/">Linked</a>`,
753
- ],
754
-
755
- mod: 'linked',
756
- ruleset: ['Standard', 'Dynamax Clause'],
757
- banlist: [
758
- 'Calyrex-Ice', 'Calyrex-Shadow', 'Cinderace', 'Cloyster', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Eternatus', 'Genesect', 'Giratina',
759
- 'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Kyogre', 'Kyurem', 'Kyurem-Black', 'Kyurem-White', 'Landorus-Base', 'Lugia', 'Lunala', 'Magearna',
760
- 'Marshadow', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram', 'Solgaleo',
761
- 'Spectrier', 'Urshifu-Base', 'Volcarona', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom',
762
- 'Zygarde-Base', 'Zygarde-Complete', 'Arena Trap', 'Chlorophyll', 'Moody', 'Power Construct', 'Sand Rush', 'Sand Veil', 'Shadow Tag', 'Slush Rush',
763
- 'Snow Cloak', 'Speed Boost', 'Surge Surfer', 'Swift Swim', 'Unburden', 'Bright Powder', 'King\'s Rock', 'Lax Incense', 'Baton Pass',
764
- ],
765
- restricted: [
766
- 'Baneful Bunker', 'Bounce', 'Protect', 'Detect', 'Dig', 'Dive', 'Fly', 'King\'s Shield', 'Nature\'s Madness', 'Night Shade',
767
- 'Obstruct', 'Phantom Force', 'Seismic Toss', 'Shadow Force', 'Sky Drop', 'Spiky Shield', 'Super Fang', 'Trick Room',
768
- ],
769
- onValidateSet(set) {
770
- const problems = [];
771
- for (const [i, moveid] of set.moves.entries()) {
772
- const move = this.dex.moves.get(moveid);
773
- if ([0, 1].includes(i) && this.ruleTable.isRestricted(`move:${move.id}`)) {
774
- problems.push(`${set.name || set.species}'s move ${move.name} cannot be linked.`);
775
- }
831
+ onBegin() {
832
+ for (const pokemon of this.getAllPokemon()) {
833
+ pokemon.baseSpecies = pokemon.species;
776
834
  }
777
- return problems;
778
835
  },
779
836
  },
780
837
 
@@ -862,12 +919,12 @@ export const Formats: FormatList = [
862
919
  mod: 'mixandmega',
863
920
  ruleset: ['Obtainable', 'Species Clause', 'Nickname Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Team Preview', 'HP Percentage Mod', 'Cancel Mod', 'Overflow Stat Mod', 'Dynamax Clause', 'Sleep Clause Mod', 'Endless Battle Clause'],
864
921
  banlist: [
865
- 'Calyrex-Shadow', 'Kyogre', 'Zacian',
922
+ 'Calyrex-Shadow', 'Eternatus', 'Kyogre', 'Zacian',
866
923
  'Beedrillite', 'Blazikenite', 'Gengarite', 'Kangaskhanite', 'Mawilite', 'Medichamite', 'Pidgeotite',
867
924
  'Moody', 'Shadow Tag', 'Baton Pass', 'Electrify',
868
925
  ],
869
926
  restricted: [
870
- 'Calyrex-Ice', 'Dialga', 'Eternatus', 'Gengar', 'Giratina', 'Groudon', 'Ho-Oh', 'Kyurem-Black', 'Kyurem-White',
927
+ 'Calyrex-Ice', 'Dialga', 'Gengar', 'Giratina', 'Groudon', 'Ho-Oh', 'Kyurem-Black', 'Kyurem-White',
871
928
  'Lugia', 'Lunala', 'Marshadow', 'Melmetal', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane',
872
929
  'Palkia', 'Pheromosa', 'Rayquaza', 'Regigigas', 'Reshiram', 'Urshifu', 'Urshifu-Rapid-Strike', 'Xerneas',
873
930
  'Yveltal', 'Zekrom', 'Zygarde-Complete',
@@ -962,9 +1019,10 @@ export const Formats: FormatList = [
962
1019
  mod: 'gen8',
963
1020
  ruleset: ['Standard', 'Dynamax Clause', 'Sleep Moves Clause'],
964
1021
  banlist: [
965
- 'Blissey', 'Calyrex-Shadow', 'Chansey', 'Dragapult', 'Hawlucha', 'Marowak-Alola', 'Melmetal', 'Pikachu', 'Toxapex',
966
- 'Xerneas', 'Zacian', 'Zacian-Crowned', 'Uber > 1', 'AG ++ Uber > 1', 'Arena Trap', 'Huge Power', 'Moody', 'Pure Power',
967
- 'Shadow Tag', 'Swift Swim', 'Bright Powder', 'Focus Band', 'King\'s Rock', 'Lax Incense', 'Quick Claw', 'Baton Pass',
1022
+ 'Blissey', 'Calyrex-Shadow', 'Chansey', 'Dragapult', 'Eternatus', 'Hawlucha', 'Marowak-Alola', 'Melmetal', 'Pikachu',
1023
+ 'Toxapex', 'Xerneas', 'Zacian', 'Zacian-Crowned', 'Uber > 1', 'AG ++ Uber > 1', 'Arena Trap', 'Huge Power', 'Moody',
1024
+ 'Pure Power', 'Shadow Tag', 'Swift Swim', 'Bright Powder', 'Focus Band', 'King\'s Rock', 'Lax Incense', 'Quick Claw',
1025
+ 'Baton Pass',
968
1026
  ],
969
1027
  onValidateTeam(team) {
970
1028
  const gods = new Set<string>();
@@ -1093,9 +1151,8 @@ export const Formats: FormatList = [
1093
1151
  ],
1094
1152
 
1095
1153
  mod: 'gen8bdsp',
1096
- searchShow: false,
1097
1154
  ruleset: ['[Gen 8 BDSP] RU'],
1098
- banlist: ['RU', 'NUBL'],
1155
+ banlist: ['RU', 'NUBL', 'Damp Rock', 'Heat Rock'],
1099
1156
  },
1100
1157
  {
1101
1158
  name: "[Gen 8 BDSP] LC",
@@ -1105,7 +1162,7 @@ export const Formats: FormatList = [
1105
1162
 
1106
1163
  mod: 'gen8bdsp',
1107
1164
  ruleset: ['Little Cup', 'Standard'],
1108
- banlist: ['Gligar', 'Meditite', 'Misdreavus', 'Murkrow', 'Scyther', 'Sneasel', 'Tangela', 'Vulpix', 'Yanma', 'Moody', 'Baton Pass'],
1165
+ banlist: ['Gligar', 'Meditite', 'Misdreavus', 'Murkrow', 'Scyther', 'Sneasel', 'Tangela', 'Vulpix', 'Yanma', 'Moody', 'Baton Pass', 'Sticky Web'],
1109
1166
  },
1110
1167
  {
1111
1168
  name: "[Gen 8 BDSP] Monotype",
@@ -1187,10 +1244,10 @@ export const Formats: FormatList = [
1187
1244
  ruleset: ['Standard', 'Dynamax Clause', 'Camomons Mod'],
1188
1245
  banlist: [
1189
1246
  'Calyrex-Ice', 'Calyrex-Shadow', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Dragonite', 'Eternatus', 'Genesect', 'Giratina', 'Giratina-Origin',
1190
- 'Groudon', 'Ho-Oh', 'Hydreigon', 'Kartana', 'Kyogre', 'Kyurem', 'Kyurem-Black', 'Kyurem-White', 'Landorus-Base', 'Latias', 'Latios', 'Lugia',
1191
- 'Lunala', 'Marshadow', 'Mew', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram',
1192
- 'Reuniclus', 'Shedinja', 'Slowking-Galar', 'Solgaleo', 'Spectrier', 'Tornadus-Therian', 'Volcarona', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned',
1193
- 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom', 'Zeraora', 'Zygarde-Base', 'Arena Trap', 'Moody', 'Power Construct', 'Shadow Tag', 'Baton Pass',
1247
+ 'Groudon', 'Ho-Oh', 'Hydreigon', 'Kartana', 'Kyogre', 'Kyurem', 'Kyurem-Black', 'Kyurem-White', 'Landorus-Base', 'Lugia', 'Lunala', 'Marshadow',
1248
+ 'Mew', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram', 'Shedinja', 'Solgaleo',
1249
+ 'Spectrier', 'Tornadus-Therian', 'Volcarona', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom', 'Zeraora',
1250
+ 'Zygarde-Base', 'Arena Trap', 'Moody', 'Power Construct', 'Shadow Tag', 'Baton Pass', 'Calm Mind',
1194
1251
  ],
1195
1252
  },
1196
1253
  {
@@ -1375,6 +1432,39 @@ export const Formats: FormatList = [
1375
1432
  this.add('-start', pokemon, donorTemplate.name, '[silent]');
1376
1433
  },
1377
1434
  },
1435
+ {
1436
+ name: "[Gen 8] Linked",
1437
+ desc: `The first two moves in a Pok&eacute;mon's moveset are used simultaneously.`,
1438
+ threads: [
1439
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3660421/">Linked</a>`,
1440
+ ],
1441
+
1442
+ mod: 'linked',
1443
+ searchShow: false,
1444
+ ruleset: ['Standard', 'Dynamax Clause'],
1445
+ banlist: [
1446
+ 'Calyrex-Ice', 'Calyrex-Shadow', 'Cinderace', 'Cloyster', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Eternatus', 'Genesect', 'Giratina',
1447
+ 'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Kartana', 'Kyogre', 'Kyurem', 'Kyurem-Black', 'Kyurem-White', 'Landorus-Base', 'Lugia', 'Lunala',
1448
+ 'Magearna', 'Marshadow', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram',
1449
+ 'Solgaleo', 'Spectrier', 'Urshifu-Base', 'Volcarona', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned',
1450
+ 'Zekrom', 'Zygarde-Base', 'Zygarde-Complete', 'Arena Trap', 'Chlorophyll', 'Moody', 'Power Construct', 'Sand Rush', 'Sand Veil', 'Shadow Tag',
1451
+ 'Slush Rush', 'Snow Cloak', 'Speed Boost', 'Surge Surfer', 'Swift Swim', 'Unburden', 'Bright Powder', 'King\'s Rock', 'Lax Incense', 'Baton Pass',
1452
+ ],
1453
+ restricted: [
1454
+ 'Baneful Bunker', 'Bounce', 'Protect', 'Detect', 'Dig', 'Dive', 'Fly', 'King\'s Shield', 'Nature\'s Madness', 'Night Shade',
1455
+ 'Obstruct', 'Phantom Force', 'Seismic Toss', 'Shadow Force', 'Sky Drop', 'Spiky Shield', 'Super Fang', 'Trick Room',
1456
+ ],
1457
+ onValidateSet(set) {
1458
+ const problems = [];
1459
+ for (const [i, moveid] of set.moves.entries()) {
1460
+ const move = this.dex.moves.get(moveid);
1461
+ if ([0, 1].includes(i) && this.ruleTable.isRestricted(`move:${move.id}`)) {
1462
+ problems.push(`${set.name || set.species}'s move ${move.name} cannot be linked.`);
1463
+ }
1464
+ }
1465
+ return problems;
1466
+ },
1467
+ },
1378
1468
  {
1379
1469
  name: "[Gen 8] Multibility",
1380
1470
  desc: `Run a second ability at the cost of giving up a Pok&eacute;mon's item slot.`,
@@ -1683,64 +1773,113 @@ export const Formats: FormatList = [
1683
1773
  },
1684
1774
  },
1685
1775
  {
1686
- name: "[Gen 8] Shared Power",
1687
- desc: `Once a Pok&eacute;mon switches in, its ability is shared with the rest of the team.`,
1776
+ name: "[Gen 8] Trademarked",
1777
+ desc: `Sacrifice your Pok&eacute;mon's ability for a status move that activates on switch-in.`,
1688
1778
  threads: [
1689
- `&bullet; <a href="https://www.smogon.com/forums/threads/3660877/">Shared Power</a>`,
1779
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3656980/">Trademarked</a>`,
1690
1780
  ],
1691
1781
 
1692
- mod: 'sharedpower',
1782
+ mod: 'gen8',
1783
+ // While bugs are being fixed
1693
1784
  searchShow: false,
1785
+ challengeShow: false,
1786
+ tournamentShow: false,
1694
1787
  ruleset: ['Standard', 'Dynamax Clause'],
1695
1788
  banlist: [
1696
- 'Calyrex-Ice', 'Calyrex-Shadow', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Eternatus', 'Genesect', 'Giratina',
1697
- 'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Kyogre', 'Kyurem-Black', 'Kyurem-White', 'Lugia', 'Lunala', 'Magearna',
1698
- 'Marshadow', 'Melmetal', 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia',
1699
- 'Pheromosa', 'Rayquaza', 'Reshiram', 'Shedinja', 'Solgaleo', 'Urshifu-Base', 'Urshifu-Rapid-Strike',
1700
- 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom',
1701
- 'Arena Trap', 'Contrary', 'Drizzle ++ Swift Swim', 'Drought ++ Chlorophyll', 'Electric Surge ++ Surge Surfer',
1702
- 'Fur Coat', 'Guts', 'Harvest', 'Huge Power', 'Imposter', 'Innards Out', 'Libero', 'Magic Bounce', 'Magic Guard',
1703
- 'Magnet Pull', 'Mold Breaker', 'Moody', 'Neutralizing Gas', 'Power Construct', 'Queenly Majesty', 'Quick Draw',
1704
- 'Regenerator', 'Sand Rush', 'Sand Veil', 'Shadow Tag', 'Simple', 'Snow Cloak', 'Snow Warning ++ Slush Rush', 'Speed Boost',
1705
- 'Stakeout', 'Steelworker ++ Steely Spirit', 'Tinted Lens', 'Triage', 'Unaware', 'Unburden', 'Water Bubble',
1706
- 'Baton Pass',
1789
+ 'Calyrex-Ice', 'Calyrex-Shadow', 'Darmanitan-Galar', 'Dialga', 'Dracovish', 'Dragapult', 'Eternatus', 'Kyurem-Black', 'Kyurem-White', 'Giratina',
1790
+ 'Giratina-Origin', 'Genesect', 'Groudon', 'Ho-Oh', 'Kartana', 'Kyogre', 'Lugia', 'Lunala', 'Magearna', 'Marowak-Alola', 'Marshadow', 'Melmetal',
1791
+ 'Mewtwo', 'Naganadel', 'Necrozma-Dawn-Wings', 'Necrozma-Dusk-Mane', 'Palkia', 'Pheromosa', 'Rayquaza', 'Reshiram', 'Solgaleo', 'Spectrier',
1792
+ 'Urshifu-Base', 'Victini', 'Xerneas', 'Yveltal', 'Zacian', 'Zacian-Crowned', 'Zamazenta', 'Zamazenta-Crowned', 'Zekrom', 'Zygarde-Base',
1793
+ 'Arena Trap', 'Moody', 'Neutralizing Gas', 'Power Construct', 'Shadow Tag', 'Baton Pass',
1707
1794
  ],
1708
- getSharedPower(pokemon) {
1709
- const sharedPower = new Set<string>();
1710
- for (const ally of pokemon.side.pokemon) {
1711
- if (ally.previouslySwitchedIn > 0) {
1712
- if (pokemon.battle.dex.currentMod !== 'sharedpower' && ['trace', 'mirrorarmor'].includes(ally.baseAbility)) {
1713
- sharedPower.add('noability');
1714
- continue;
1715
- }
1716
- sharedPower.add(ally.baseAbility);
1795
+ restricted: [
1796
+ 'Baneful Bunker', 'Block', 'Copycat', 'Corrosive Gas', 'Detect', 'Destiny Bond', 'Disable', 'Encore', 'Fairy Lock', 'Hypnosis', 'Ingrain',
1797
+ 'Instruct', 'Lovely Kiss', 'King\'s Shield', 'Mat Block', 'Mean Look', 'Memento', 'move:Metronome', 'Obstruct', 'Octolock', 'Nature Power',
1798
+ 'Parting Shot', 'Psycho Shift', 'Protect', 'Roar', 'Sing', 'Skill Swap', 'Sleep Powder', 'Sleep Talk', 'Spiky Shield', 'Spore', 'Substitute',
1799
+ 'Switcheroo', 'Teleport', 'Trick', 'Whirlwind', 'Wish', 'Yawn',
1800
+ ],
1801
+ onValidateTeam(team, format, teamHas) {
1802
+ const problems = [];
1803
+ for (const trademark in teamHas.trademarks) {
1804
+ if (teamHas.trademarks[trademark] > 1) {
1805
+ problems.push(`You are limited to 1 of each Trademark.`, `(You have ${teamHas.trademarks[trademark]} Pok\u00e9mon with ${trademark} as a Trademark.)`);
1717
1806
  }
1718
1807
  }
1719
- sharedPower.delete(pokemon.baseAbility);
1720
- return sharedPower;
1808
+ return problems;
1721
1809
  },
1722
- onBeforeSwitchIn(pokemon) {
1723
- let format = this.format;
1724
- if (!format.getSharedPower) format = this.dex.formats.get('gen8sharedpower');
1725
- for (const ability of format.getSharedPower!(pokemon)) {
1726
- const effect = 'ability:' + ability;
1727
- pokemon.volatiles[effect] = {id: this.toID(effect), target: pokemon};
1728
- if (!pokemon.m.abils) pokemon.m.abils = [];
1729
- if (!pokemon.m.abils.includes(effect)) pokemon.m.abils.push(effect);
1810
+ validateSet(set, teamHas) {
1811
+ const dex = this.dex;
1812
+ const ability = dex.moves.get(set.ability);
1813
+ if (!ability.exists) { // Not even a real move
1814
+ return this.validateSet(set, teamHas);
1730
1815
  }
1731
- },
1732
- onSwitchInPriority: 2,
1733
- onSwitchIn(pokemon) {
1734
- let format = this.format;
1735
- if (!format.getSharedPower) format = this.dex.formats.get('gen8sharedpower');
1736
- for (const ability of format.getSharedPower!(pokemon)) {
1737
- if (ability === 'noability') {
1738
- this.hint(`Mirror Armor and Trace break in Shared Power formats that don't use Shared Power as a base, so they get removed from non-base users.`);
1816
+ // Absolute trademark bans
1817
+ if (ability.category !== 'Status') {
1818
+ return [`${ability.name} is not a status move, and cannot be used as a trademark.`];
1819
+ }
1820
+ if (ability.forceSwitch || ability.selfSwitch) {
1821
+ return [
1822
+ `Force-switching and self-switching moves are banned from being used as trademarks.`,
1823
+ `(${ability.name} is a ${ability.forceSwitch ? 'force' : 'self'}-switching move.)`,
1824
+ ];
1825
+ }
1826
+ const irrevokablyRestricted = [
1827
+ 'Assist', 'Copycat', 'Metronome', 'Mirror Move', 'Sleep Talk', // Could call another unsafe trademark
1828
+ 'Recycle', 'Trace', // Causes endless turns
1829
+ 'Skill Swap', // Self-propagates indefinitely
1830
+ ];
1831
+ for (const m of set.moves) {
1832
+ const move = dex.moves.get(m);
1833
+ if (irrevokablyRestricted.includes(move.name)) {
1834
+ return [`${move.name} is banned from Trademark, irrespective of custom rules, because it can cause endless turns.`];
1739
1835
  }
1740
- const effect = 'ability:' + ability;
1741
- delete pokemon.volatiles[effect];
1742
- pokemon.addVolatile(effect);
1743
1836
  }
1837
+ if (irrevokablyRestricted.includes(ability.name)) {
1838
+ return [`${ability.name} cannot safely function as a trademark.`];
1839
+ }
1840
+ // Contingent trademark bans
1841
+ if (this.ruleTable.isRestricted(`move:${ability.id}`)) {
1842
+ return [`${ability.name} is restricted from being used as a trademark.`];
1843
+ }
1844
+ if (set.moves.map(this.toID).includes(ability.id)) {
1845
+ return [`${set.name} may not use ${ability.name} as both a trademark and one of its moves simultaneously.`];
1846
+ }
1847
+ const customRules = this.format.customRules || [];
1848
+ if (!customRules.includes('!obtainableabilities')) customRules.push('!obtainableabilities');
1849
+
1850
+ const TeamValidator: typeof import('../sim/team-validator').TeamValidator =
1851
+ require('../sim/team-validator').TeamValidator;
1852
+
1853
+ const validator = new TeamValidator(dex.formats.get(`${this.format.id}@@@${customRules.join(',')}`));
1854
+ const moves = set.moves;
1855
+ set.moves = [ability.id];
1856
+ set.ability = dex.species.get(set.species).abilities['0'];
1857
+ let problems = validator.validateSet(set, {}) || [];
1858
+ if (problems.length) return problems;
1859
+ set.moves = moves;
1860
+ set.ability = dex.species.get(set.species).abilities['0'];
1861
+ problems = problems.concat(validator.validateSet(set, teamHas) || []);
1862
+ set.ability = ability.id;
1863
+ if (!teamHas.trademarks) teamHas.trademarks = {};
1864
+ teamHas.trademarks[ability.name] = (teamHas.trademarks[ability.name] || 0) + 1;
1865
+ return problems.length ? problems : null;
1866
+ },
1867
+ pokemon: {
1868
+ getAbility() {
1869
+ const move = this.battle.dex.moves.get(this.battle.toID(this.ability));
1870
+ if (!move.exists) return Object.getPrototypeOf(this).getAbility.call(this);
1871
+ return {
1872
+ id: move.id,
1873
+ name: move.name,
1874
+ onStart(this: Battle, pokemon: Pokemon) {
1875
+ this.add('-activate', pokemon, 'ability: ' + move.name);
1876
+ this.actions.useMove(move, pokemon);
1877
+ },
1878
+ toString() {
1879
+ return "";
1880
+ },
1881
+ };
1882
+ },
1744
1883
  },
1745
1884
  },
1746
1885
  {
@@ -1907,7 +2046,6 @@ export const Formats: FormatList = [
1907
2046
 
1908
2047
  mod: 'sharedpower',
1909
2048
  team: 'random',
1910
- searchShow: false,
1911
2049
  ruleset: ['[Gen 8] Random Battle', 'Team Preview', 'Dynamax Clause', 'Camomons Mod', 'Inverse Mod', 'Scalemons Mod'],
1912
2050
  onBeforeSwitchIn(pokemon) {
1913
2051
  let format = this.format;
@@ -2210,39 +2348,45 @@ export const Formats: FormatList = [
2210
2348
  column: 3,
2211
2349
  },
2212
2350
  {
2213
- name: "[Gen 3] UU",
2351
+ name: "[Gen 4] UU",
2214
2352
  threads: [
2215
- `&bullet; <a href="https://www.smogon.com/forums/threads/3585923/">ADV UU Metagame Discussion</a>`,
2216
- `&bullet; <a href="https://www.smogon.com/forums/threads/3548578/">ADV UU Viability Rankings</a>`,
2353
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3532624/">DPP UU Metagame Discussion</a>`,
2354
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3503638/">DPP UU Viability Rankings</a>`,
2217
2355
  ],
2218
2356
 
2219
- mod: 'gen3',
2357
+ mod: 'gen4',
2220
2358
  // searchShow: false,
2221
- ruleset: ['Standard', 'NFE Clause'],
2222
- banlist: ['Uber', 'OU', 'UUBL', 'Smeargle + Ingrain', 'Baton Pass'],
2223
- unbanlist: ['Scyther', 'Sand Veil'],
2359
+ ruleset: ['[Gen 4] OU'],
2360
+ banlist: ['OU', 'UUBL'],
2361
+ unbanlist: ['Arena Trap', 'Swagger'],
2224
2362
  },
2225
2363
  {
2226
- name: "[Gen 1] NU",
2364
+ name: "[Gen 7] LC",
2227
2365
  threads: [
2228
- `&bullet; <a href="https://www.smogon.com/forums/threads/3668913/">RBY NU Viability Rankings</a>`,
2366
+ `&bullet; <a href="https://www.smogon.com/dex/sm/formats/lc/">USM LC Banlist</a>`,
2367
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3639319/">USM LC Sample Teams</a>`,
2368
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3621440/">USM LC Viability Rankings</a>`,
2229
2369
  ],
2230
2370
 
2231
- mod: 'gen1',
2371
+ mod: 'gen7',
2232
2372
  // searchShow: false,
2233
- ruleset: ['[Gen 1] UU'],
2234
- banlist: ['UU', 'NUBL'],
2373
+ ruleset: ['Little Cup', 'Standard', 'Swagger Clause'],
2374
+ banlist: [
2375
+ 'Aipom', 'Cutiefly', 'Drifloon', 'Gligar', 'Gothita', 'Meditite', 'Misdreavus', 'Murkrow', 'Porygon',
2376
+ 'Scyther', 'Sneasel', 'Swirlix', 'Tangela', 'Trapinch', 'Vulpix-Base', 'Wingull', 'Yanma',
2377
+ 'Eevium Z', 'Baton Pass', 'Dragon Rage', 'Sonic Boom', 'Sticky Web',
2378
+ ],
2235
2379
  },
2236
2380
  {
2237
- name: "[Gen 4] Ubers",
2381
+ name: "[Gen 5] PU",
2238
2382
  threads: [
2239
- `&bullet; <a href="https://www.smogon.com/forums/posts/8286279/">DPP Ubers</a>`,
2383
+ `&bullet; <a href="https://www.smogon.com/forums/posts/7326932/">BW2 PU</a>`,
2240
2384
  ],
2241
2385
 
2242
- mod: 'gen4',
2386
+ mod: 'gen5',
2243
2387
  // searchShow: false,
2244
- ruleset: ['Standard'],
2245
- banlist: ['AG'],
2388
+ ruleset: ['[Gen 5] NU', 'Sleep Moves Clause'],
2389
+ banlist: ['NU', 'PUBL'],
2246
2390
  },
2247
2391
 
2248
2392
  // Past Gens OU
@@ -2535,23 +2679,6 @@ export const Formats: FormatList = [
2535
2679
  ruleset: ['[Gen 7] NU'],
2536
2680
  banlist: ['NU', 'PUBL'],
2537
2681
  },
2538
- {
2539
- name: "[Gen 7] LC",
2540
- threads: [
2541
- `&bullet; <a href="https://www.smogon.com/dex/sm/formats/lc/">USM LC Banlist</a>`,
2542
- `&bullet; <a href="https://www.smogon.com/forums/threads/3639319/">USM LC Sample Teams</a>`,
2543
- `&bullet; <a href="https://www.smogon.com/forums/threads/3621440/">USM LC Viability Rankings</a>`,
2544
- ],
2545
-
2546
- mod: 'gen7',
2547
- searchShow: false,
2548
- ruleset: ['Little Cup', 'Standard', 'Swagger Clause'],
2549
- banlist: [
2550
- 'Aipom', 'Cutiefly', 'Drifloon', 'Gligar', 'Gothita', 'Meditite', 'Misdreavus', 'Murkrow', 'Porygon',
2551
- 'Scyther', 'Sneasel', 'Swirlix', 'Tangela', 'Trapinch', 'Vulpix-Base', 'Wingull', 'Yanma',
2552
- 'Eevium Z', 'Baton Pass', 'Dragon Rage', 'Sonic Boom', 'Sticky Web',
2553
- ],
2554
- },
2555
2682
  {
2556
2683
  name: "[Gen 7] Monotype",
2557
2684
  desc: `All the Pok&eacute;mon on a team must share a type.`,
@@ -2895,14 +3022,15 @@ export const Formats: FormatList = [
2895
3022
  mod: 'gen6',
2896
3023
  searchShow: false,
2897
3024
  ruleset: [
2898
- 'Max Team Size = 3', 'Picked Team Size = 1',
2899
- 'Obtainable', 'Nickname Clause', 'Moody Clause', 'OHKO Clause', 'Evasion Moves Clause', 'Accuracy Moves Clause', 'Swagger Clause', 'Endless Battle Clause', 'HP Percentage Mod', 'Cancel Mod', 'Team Preview',
3025
+ 'Max Team Size = 3', 'Picked Team Size = 1', 'Obtainable', 'Nickname Clause', 'Moody Clause', 'OHKO Clause',
3026
+ 'Evasion Moves Clause', 'Accuracy Moves Clause', 'Swagger Clause', 'Endless Battle Clause', 'HP Percentage Mod',
3027
+ 'Cancel Mod', 'Team Preview',
2900
3028
  ],
2901
3029
  banlist: [
2902
3030
  'Arceus', 'Blaziken', 'Darkrai', 'Deoxys-Base', 'Deoxys-Attack', 'Deoxys-Defense', 'Dialga', 'Giratina',
2903
3031
  'Giratina-Origin', 'Groudon', 'Ho-Oh', 'Kangaskhan-Mega', 'Kyogre', 'Kyurem-White', 'Lugia', 'Mewtwo',
2904
3032
  'Palkia', 'Rayquaza', 'Reshiram', 'Salamence-Mega', 'Shaymin-Sky', 'Xerneas', 'Yveltal', 'Zekrom',
2905
- 'Focus Sash', 'Soul Dew', 'Perish Song',
3033
+ 'Focus Sash', 'Soul Dew', 'Grass Whistle', 'Hypnosis', 'Perish Song', 'Sing', 'Yawn',
2906
3034
  ],
2907
3035
  },
2908
3036
  {
@@ -3115,17 +3243,6 @@ export const Formats: FormatList = [
3115
3243
  ruleset: ['[Gen 5] RU', '!Sleep Moves Clause', 'Sleep Clause Mod'],
3116
3244
  banlist: ['RU', 'NUBL', 'Assist', 'Copycat'],
3117
3245
  },
3118
- {
3119
- name: "[Gen 5] PU",
3120
- threads: [
3121
- `&bullet; <a href="https://www.smogon.com/forums/posts/7326932/">BW2 PU</a>`,
3122
- ],
3123
-
3124
- mod: 'gen5',
3125
- searchShow: false,
3126
- ruleset: ['[Gen 5] NU', 'Sleep Moves Clause'],
3127
- banlist: ['NU', 'PUBL'],
3128
- },
3129
3246
  {
3130
3247
  name: "[Gen 5] LC",
3131
3248
  threads: [
@@ -3165,7 +3282,7 @@ export const Formats: FormatList = [
3165
3282
  'Picked Team Size = 1', 'Max Team Size = 3',
3166
3283
  'Standard', 'Baton Pass Clause', 'Swagger Clause', 'Accuracy Moves Clause',
3167
3284
  ],
3168
- banlist: ['Uber', 'Cottonee', 'Dragonite', 'Kyurem-Black', 'Mew', 'Togekiss', 'Whimsicott', 'Victini', 'Bright Powder', 'Focus Band', 'Focus Sash', 'Lax Incense', 'Quick Claw', 'Soul Dew', 'Perish Song'],
3285
+ banlist: ['Uber', 'Cottonee', 'Dragonite', 'Jirachi', 'Kyurem-Black', 'Mew', 'Togekiss', 'Whimsicott', 'Victini', 'Bright Powder', 'Focus Band', 'Focus Sash', 'Lax Incense', 'Quick Claw', 'Soul Dew', 'Perish Song'],
3169
3286
  unbanlist: ['Genesect', 'Landorus', 'Manaphy', 'Thundurus', 'Tornadus-Therian'],
3170
3287
  },
3171
3288
  {
@@ -3266,17 +3383,15 @@ export const Formats: FormatList = [
3266
3383
  column: 5,
3267
3384
  },
3268
3385
  {
3269
- name: "[Gen 4] UU",
3386
+ name: "[Gen 4] Ubers",
3270
3387
  threads: [
3271
- `&bullet; <a href="https://www.smogon.com/forums/threads/3532624/">DPP UU Metagame Discussion</a>`,
3272
- `&bullet; <a href="https://www.smogon.com/forums/threads/3503638/">DPP UU Viability Rankings</a>`,
3388
+ `&bullet; <a href="https://www.smogon.com/forums/posts/8286279/">DPP Ubers</a>`,
3273
3389
  ],
3274
3390
 
3275
3391
  mod: 'gen4',
3276
3392
  searchShow: false,
3277
- ruleset: ['[Gen 4] OU'],
3278
- banlist: ['OU', 'UUBL'],
3279
- unbanlist: ['Arena Trap', 'Swagger'],
3393
+ ruleset: ['Standard'],
3394
+ banlist: ['AG'],
3280
3395
  },
3281
3396
  {
3282
3397
  name: "[Gen 4] NU",
@@ -3424,6 +3539,19 @@ export const Formats: FormatList = [
3424
3539
  ruleset: ['Standard', 'Deoxys Camouflage Clause', 'One Baton Pass Clause'],
3425
3540
  banlist: ['Wobbuffet + Leftovers'],
3426
3541
  },
3542
+ {
3543
+ name: "[Gen 3] UU",
3544
+ threads: [
3545
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3585923/">ADV UU Metagame Discussion</a>`,
3546
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3548578/">ADV UU Viability Rankings</a>`,
3547
+ ],
3548
+
3549
+ mod: 'gen3',
3550
+ searchShow: false,
3551
+ ruleset: ['Standard', 'NFE Clause'],
3552
+ banlist: ['Uber', 'OU', 'UUBL', 'Smeargle + Ingrain', 'Baton Pass'],
3553
+ unbanlist: ['Scyther', 'Sand Veil'],
3554
+ },
3427
3555
  {
3428
3556
  name: "[Gen 3] NU",
3429
3557
  threads: [
@@ -3583,6 +3711,17 @@ export const Formats: FormatList = [
3583
3711
  ruleset: ['[Gen 1] OU'],
3584
3712
  banlist: ['OU', 'UUBL'],
3585
3713
  },
3714
+ {
3715
+ name: "[Gen 1] NU",
3716
+ threads: [
3717
+ `&bullet; <a href="https://www.smogon.com/forums/threads/3668913/">RBY NU Viability Rankings</a>`,
3718
+ ],
3719
+
3720
+ mod: 'gen1',
3721
+ searchShow: false,
3722
+ ruleset: ['[Gen 1] UU'],
3723
+ banlist: ['UU', 'NUBL'],
3724
+ },
3586
3725
  {
3587
3726
  name: "[Gen 1] Japanese OU",
3588
3727
  desc: `Generation 1 with Japanese battle mechanics.`,