diff --git a/sim/TEAMS.md b/sim/TEAMS.md index 3cb7ce9a33..2e175f2f71 100644 --- a/sim/TEAMS.md +++ b/sim/TEAMS.md @@ -160,6 +160,46 @@ Packed format looks like this: Articuno||leftovers|pressure|icebeam,hurricane,substitute,roost|Modest|252,,,252,4,||,,,30,30,|||]Ludicolo||lifeorb|swiftswim|surf,gigadrain,icebeam,raindance|Modest|4,,,252,,252|||||]Volbeat||damprock|prankster|tailglow,batonpass,encore,raindance|Bold|248,,252,,8,|M||||]Seismitoad||lifeorb|swiftswim|hydropump,earthpower,stealthrock,raindance|Modest|,,,252,4,252|||||]Alomomola||damprock|regenerator|wish,protect,toxic,raindance|Bold|252,,252,,4,|||||]Armaldo||leftovers|swiftswim|xscissor,stoneedge,aquatail,rapidspin|Adamant|128,252,4,,,124||||| ``` +Converting between formats +-------------------------- + +API: + +`Sim.Teams.unpack(packedTeam: string): PokemonSet[]` + +- Converts a packed team to a JSON team + +`Sim.Teams.pack(team: PokemonSet[]): string` + +- Converts a JSON team to a packed team + +`Sim.Teams.export(team: PokemonSet[]): string` + +- Converts a JSON team to an export team + +`Sim.Teams.exportSet(set: PokemonSet): string` + +- Converts a JSON set to export format + +`Sim.Teams.generate(format: Format | string, options?: {seed: number[4]}): PokemonSet` + +- Generate a team for a random format + +(Import is not available in this version; we'll add it to a future version.) + +Example use: + +```js +const Sim = require('pokemon-showdown'); + +console.log(JSON.stringify(Sim.Teams.unpack( + `Articuno||leftovers|pressure|icebeam,hurricane,substitute,roost|Modest|252,,,252,4,||,,,30,30,|||]Ludicolo||lifeorb|swiftswim|surf,gigadrain,icebeam,raindance|Modest|4,,,252,,252|||||]Volbeat||damprock|prankster|tailglow,batonpass,encore,raindance|Bold|248,,252,,8,|M||||]Seismitoad||lifeorb|swiftswim|hydropump,earthpower,stealthrock,raindance|Modest|,,,252,4,252|||||]Alomomola||damprock|regenerator|wish,protect,toxic,raindance|Bold|252,,252,,4,|||||]Armaldo||leftovers|swiftswim|xscissor,stoneedge,aquatail,rapidspin|Adamant|128,252,4,,,124|||||` +))); + +// will log the team to console in JSON format + +``` + Team validator -------------- @@ -173,69 +213,11 @@ const Sim = require('pokemon-showdown'); const validator = new Sim.TeamValidator('gen6nu'); -const output = validator.validateTeam([ - { - "name": "", - "species": "Articuno", - "gender": "", - "item": "Leftovers", - "ability": "Pressure", - "evs": {"hp": 252, "atk": 0, "def": 0, "spa": 252, "spd": 4, "spe": 0}, - "nature": "Modest", - "ivs": {"hp": 31, "atk": 31, "def": 31, "spa": 30, "spd": 30, "spe": 31}, - "moves": ["Ice Beam", "Hurricane", "Substitute", "Roost"] - }, - { - "name": "", - "species": "Ludicolo", - "gender": "", - "item": "Life Orb", - "ability": "Swift Swim", - "evs": {"hp": 4, "atk": 0, "def": 0, "spa": 252, "spd": 0, "spe": 252}, - "nature": "Modest", - "moves": ["Surf", "Giga Drain", "Ice Beam", "Rain Dance"] - }, - { - "name": "", - "species": "Volbeat", - "gender": "M", - "item": "Damp Rock", - "ability": "Prankster", - "evs": {"hp": 248, "atk": 0, "def": 252, "spa": 0, "spd": 8, "spe": 0}, - "nature": "Bold", - "moves": ["Tail Glow", "Baton Pass", "Encore", "Rain Dance"] - }, - { - "name": "", - "species": "Seismitoad", - "gender": "", - "item": "Life Orb", - "ability": "Swift Swim", - "evs": {"hp": 0, "atk": 0, "def": 0, "spa": 252, "spd": 4, "spe": 252}, - "nature": "Modest", - "moves": ["Hydro Pump", "Earth Power", "Stealth Rock", "Rain Dance"] - }, - { - "name": "", - "species": "Alomomola", - "gender": "", - "item": "Damp Rock", - "ability": "Regenerator", - "evs": {"hp": 252, "atk": 0, "def": 252, "spa": 0, "spd": 4, "spe": 0}, - "nature": "Bold", - "moves": ["Wish", "Protect", "Toxic", "Rain Dance"] - }, - { - "name": "", - "species": "Armaldo", - "gender": "", - "item": "Leftovers", - "ability": "Swift Swim", - "evs": {"hp": 128, "atk": 252, "def": 4, "spa": 0, "spd": 0, "spe": 124}, - "nature": "Adamant", - "moves": ["X-Scissor", "Stone Edge", "Aqua Tail", "Rapid Spin"] - } -]); +const output = validator.validateTeam( + Sim.Teams.unpack( + `Articuno||leftovers|pressure|icebeam,hurricane,substitute,roost|Modest|252,,,252,4,||,,,30,30,|||]Ludicolo||lifeorb|swiftswim|surf,gigadrain,icebeam,raindance|Modest|4,,,252,,252|||||]Volbeat||damprock|prankster|tailglow,batonpass,encore,raindance|Bold|248,,252,,8,|M||||]Seismitoad||lifeorb|swiftswim|hydropump,earthpower,stealthrock,raindance|Modest|,,,252,4,252|||||]Alomomola||damprock|regenerator|wish,protect,toxic,raindance|Bold|252,,252,,4,|||||]Armaldo||leftovers|swiftswim|xscissor,stoneedge,aquatail,rapidspin|Adamant|128,252,4,,,124|||||` + ) +); ``` `output` will be an array of problems, if it's not a legal team, or `null`, if it's a legal team.