Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pkmn/protocol

Package Overview
Dependencies
Maintainers
0
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pkmn/protocol - npm Package Compare versions

Comparing version 0.6.25 to 0.6.26

build/chunk-RIICEHNS.mjs

4

build/index.js
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunk4XYC7FTLjs = require('./chunk-4XYC7FTL.js');
var _chunkRV4CKQH6js = require('./chunk-RV4CKQH6.js');
exports.Protocol = _chunk4XYC7FTLjs.Protocol; exports.ignoreKwArgsSimple = _chunk4XYC7FTLjs.ignoreKwArgsSimple;
exports.Protocol = _chunkRV4CKQH6js.Protocol; exports.ignoreKwArgsSimple = _chunkRV4CKQH6js.ignoreKwArgsSimple;
//# sourceMappingURL=index.js.map
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunk4XYC7FTLjs = require('../chunk-4XYC7FTL.js');
var _chunkRV4CKQH6js = require('../chunk-RV4CKQH6.js');

@@ -104,9 +104,7 @@ // src/verifier/index.ts

function verifyType(name, gen) {
if (!gen)
return verifyName(name);
if (!gen) return verifyName(name);
return verifyName(name) && !!gen.types.get(name);
}
function verifyTypes(types, gen) {
if (!gen)
return verifyName(types);
if (!gen) return verifyName(types);
const [type1, type2] = types.split("/");

@@ -168,4 +166,3 @@ return verifyType(type1, gen) && (!type2 || verifyType(type2, gen));

const m = /^([^|]{1,25}?)(, L\d{0,3})?(, [MF])?(, shiny)?$/.exec(details);
if (!m)
return false;
if (!m) return false;
return !gen || !!gen.species.get(m[1]);

@@ -194,6 +191,4 @@ }

const key = k;
if (!keys.includes(key))
return false;
if (!verifyKWArg(key, kwArgs[key], gen))
return false;
if (!keys.includes(key)) return false;
if (!verifyKWArg(key, kwArgs[key], gen)) return false;
}

@@ -203,17 +198,11 @@ return true;

function verifyKWArg(k, v, gen) {
if (v === void 0)
return true;
if (BOOL_KWARGS.has(k))
return v === true;
if (NAME_KWARGS.includes(k))
return verifyName(v);
if (v === void 0) return true;
if (BOOL_KWARGS.has(k)) return v === true;
if (NAME_KWARGS.includes(k)) return verifyName(v);
if (ABILITY_KWARGS.includes(k)) {
return v === "" || verifyAbilityName(v, gen);
}
if (ITEM_KWARGS.includes(k))
return verifyItemName(v, gen);
if (MOVE_KWARGS.includes(k))
return verifyMoveName(v, gen);
if (k === "of")
return v === "" || verifyPokemonIdent(v);
if (ITEM_KWARGS.includes(k)) return verifyItemName(v, gen);
if (MOVE_KWARGS.includes(k)) return verifyMoveName(v, gen);
if (k === "of") return v === "" || verifyPokemonIdent(v);
if (k === "spread") {

@@ -225,8 +214,5 @@ return v === true || v.split(",").every((s) => /^p[1234][abc]$/.test(s));

}
if (k === "number")
return verifyNum(v);
if (k === "move")
return verifyMoveName(v, gen) || verifyID(v);
if (k === "anim")
return verifyAnimationName(v, gen) || v === "prepare";
if (k === "number") return verifyNum(v);
if (k === "move") return verifyMoveName(v, gen) || verifyID(v);
if (k === "anim") return verifyAnimationName(v, gen) || v === "prepare";
return false;

@@ -264,20 +250,14 @@ }

"|join|"(args) {
if (args.length !== 3)
return false;
if (typeof args[2] !== "boolean")
return false;
if (args.length !== 3) return false;
if (typeof args[2] !== "boolean") return false;
return !!args[1];
}
"|leave|"(args) {
if (args.length !== 3)
return false;
if (typeof args[2] !== "boolean")
return false;
if (args.length !== 3) return false;
if (typeof args[2] !== "boolean") return false;
return !!args[1];
}
"|name|"(args) {
if (args.length !== 4)
return false;
if (typeof args[3] !== "boolean")
return false;
if (args.length !== 4) return false;
if (typeof args[3] !== "boolean") return false;
return !!args[1] && verifyID(args[2]);

@@ -322,4 +302,3 @@ }

"|updateuser|"(args) {
if (args.length < 5)
return false;
if (args.length < 5) return false;
return !!args[1] && (args[2] === "0" || args[2] === "1") && !!args[3] && verifyJSON(args[4]);

@@ -343,6 +322,4 @@ }

"|unlink|"(args) {
if (args.length === 2)
return !!args[1];
if (args.length === 3)
return args[1] === "hide" && !!args[2];
if (args.length === 2) return !!args[1];
if (args.length === 3) return args[1] === "hide" && !!args[2];
return false;

@@ -438,8 +415,5 @@ }

"|tournament|battleend|"(args) {
if (args.length !== 7)
return false;
if (!args[2] || !args[3])
return false;
if (/^[0-6],[0-6]$/.test(args[5]))
return false;
if (args.length !== 7) return false;
if (!args[2] || !args[3]) return false;
if (/^[0-6],[0-6]$/.test(args[5])) return false;
if (args[6] === "success") {

@@ -466,4 +440,3 @@ return ["win", "loss", "draw"].includes(args[4]);

"|player|"(args) {
if (args.length === 2)
return verifyPlayer(args[1]);
if (args.length === 2) return verifyPlayer(args[1]);
return args.length === 5 && verifyPlayer(args[1]) && !!args[2] && (args[4] === "" || verifyNum(args[4]));

@@ -497,19 +470,15 @@ }

"|teampreview|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 1 || args.length === 2 && verifyNum(args[1]);
}
"|updatepoke|"(args) {
if (this.gen && this.gen.num < 8)
return false;
if (this.gen && this.gen.num < 8) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonDetails(args[2], this.gen);
}
"|clearpoke|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 1;
}
"|poke|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 4 && verifyPlayer(args[1]) && verifyPokemonDetails(args[2], this.gen) && POKE_ITEMS.includes(args[3]);

@@ -550,6 +519,4 @@ }

var _a;
if (!verifyPokemonIdent(args[1]))
return false;
if (!(args[2] === "recharge" || verifyMoveName(args[2], this.gen)))
return false;
if (!verifyPokemonIdent(args[1])) return false;
if (!(args[2] === "recharge" || verifyMoveName(args[2], this.gen))) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {

@@ -581,4 +548,3 @@ case 1:

const keys = [...KWARGS, "anim", "miss", "notarget", "prepare", "spread", "zeffect"];
if (!verifyKWArgs(kwArgs, keys, this.gen))
return false;
if (!verifyKWArgs(kwArgs, keys, this.gen)) return false;
return args.length === 3 || args.length === 4 && (args[3] === "" || args[3] === "null" || verifyPokemonIdent(args[3]));

@@ -590,8 +556,5 @@ }

const valid = args.length === 4 && verifyPokemonIdent(args[1]) && verifyPokemonDetails(args[2], this.gen) && verifyPokemonHPStatus(args[3]);
if (!valid)
return false;
if (!this.gen)
return verifyKWArgs(kwArgs, KWARGS, this.gen);
if (this.gen.num === 1)
return !Object.keys(kwArgs).length;
if (!valid) return false;
if (!this.gen) return verifyKWArgs(kwArgs, KWARGS, this.gen);
if (this.gen.num === 1) return !Object.keys(kwArgs).length;
const from = [

@@ -608,24 +571,19 @@ "Baton Pass",

const to = [0, 0, 1, 1, 2, 3, 4, 4, 6, 8];
if (!verifyKWArgs(kwArgs, ["from"], this.gen))
return false;
if (!verifyKWArgs(kwArgs, ["from"], this.gen)) return false;
return !kwArgs.from || from.slice(0, to[this.gen.num]).includes(kwArgs.from);
}
"|drag|"(args) {
if (this.gen && this.gen.num < 2)
return false;
if (this.gen && this.gen.num < 2) return false;
return args.length === 4 && verifyPokemonIdent(args[1]) && verifyPokemonDetails(args[2], this.gen) && verifyPokemonHPStatus(args[3]);
}
"|detailschange|"(args) {
if (this.gen && this.gen.num < 4)
return false;
if (this.gen && this.gen.num < 4) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonDetails(args[2], this.gen);
}
"|replace|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonDetails(args[2], this.gen);
}
"|swap|"(args, kwArgs) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 3 && verifyKWArgs(kwArgs, ["from"], this.gen) && verifyPokemonIdent(args[1]) && verifyNum(args[2]) && kwArgs.from === "move: Ally Switch";

@@ -636,8 +594,6 @@ }

var _a;
if (!verifyPokemonIdent(args[1]))
return false;
if (!verifyPokemonIdent(args[1])) return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) {
const reasons = ["Disable", "flinch", "slp", "frz", "par", "partiallytrapped", "recharge"];
if (!reasons.includes(args[2]) || Object.keys(kwArgs).length)
return false;
if (!reasons.includes(args[2]) || Object.keys(kwArgs).length) return false;
return args[2] === "Disable" ? args.length === 4 && verifyMoveName(args[3], this.gen) : args.length === 3;

@@ -652,7 +608,5 @@ }

var _a;
if (this.gen && this.gen.num < 3)
return false;
if (this.gen && this.gen.num < 3) return false;
const valid = verifyPokemonIdent(args[1]) && verifySpeciesName(args[2], this.gen) && args.length === 3 || args.length === 4 && args[3] === "";
if (!valid)
return false;
if (!valid) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {

@@ -674,9 +628,6 @@ case 3: {

const valid = verifyPokemonIdent(args[1]) && verifyKWArgs(kwArgs, ["weak"], this.gen);
if (!valid || args.length > 3)
return false;
if (args.length === 2)
return true;
if (!valid || args.length > 3) return false;
if (args.length === 2) return true;
const reasons = ["move: Substitute", "par", "psn", "slp", "tox"];
if (!reasons.includes(args[2]))
return false;
if (!reasons.includes(args[2])) return false;
return !kwArgs.weak || args[2] === "move: Substitute";

@@ -688,4 +639,3 @@ }

}
if (args.length === 2)
return verifyPokemonIdent(args[1]);
if (args.length === 2) return verifyPokemonIdent(args[1]);
if (args.length === 3) {

@@ -702,18 +652,13 @@ return verifyPokemonIdent(args[1]) && (verifyStatusName(args[2]) || verifyEffectName(args[2], this.gen) || verifyMoveName(args[2], this.gen));

}
if (!verifyKWArgs(kwArgs, KWARGS, this.gen))
return false;
if (!verifyKWArgs(kwArgs, KWARGS, this.gen)) return false;
if (!(verifyPokemonIdent(args[1]) && (verifyEffectName(args[2], this.gen) || verifyMoveName(args[2], this.gen)))) {
return false;
}
if (args.length === 3)
return true;
if (args.length === 4)
return args[3] === "" || verifyMoveName(args[3], this.gen);
if (args.length === 3) return true;
if (args.length === 4) return args[3] === "" || verifyMoveName(args[3], this.gen);
return args.length === 5 && verifyPokemonIdent(args[1]) && verifyEffectName(args[2], this.gen) && verifyMoveName(args[3], this.gen) && (args[4] === "" || verifyPokemonIdent(args[4]));
}
"|-notarget|"(args) {
if (this.gen && this.gen.num < 3)
return false;
if (args.length === 2 && verifyPokemonIdent(args[1]))
return true;
if (this.gen && this.gen.num < 3) return false;
if (args.length === 2 && verifyPokemonIdent(args[1])) return true;
return !this.gen && args.length === 1;

@@ -723,6 +668,4 @@ }

var _a;
if (!verifyPokemonIdent(args[1]))
return false;
if (args.length === 2)
return !this.gen || this.gen.num <= 2;
if (!verifyPokemonIdent(args[1])) return false;
if (args.length === 2) return !this.gen || this.gen.num <= 2;
return ((_a = this.gen) == null ? void 0 : _a.num) !== 1 && args.length === 3 && verifyPokemonIdent(args[2]);

@@ -734,7 +677,5 @@ }

const valid = args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonHPStatus(args[2]);
if (!valid)
return false;
if (!valid) return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) {
if (!verifyKWArgs(kwArgs, ["from", "of"], this.gen))
return false;
if (!verifyKWArgs(kwArgs, ["from", "of"], this.gen)) return false;
return !kwArgs.from || (kwArgs.of ? ["brn", "psn", "Leech Seed", "Recoil"] : ["brn", "psn", "confusion"]).includes(kwArgs.from);

@@ -748,9 +689,6 @@ }

const valid = args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonHPStatus(args[2]);
if (!valid)
return false;
if (!valid) return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) {
if (!verifyKWArgs(kwArgs, ["from", "of", "silent"], this.gen))
return false;
if (!Object.keys(kwArgs).length)
return true;
if (!verifyKWArgs(kwArgs, ["from", "of", "silent"], this.gen)) return false;
if (!Object.keys(kwArgs).length) return true;
return kwArgs.silent ? !(kwArgs.from || kwArgs.of) : kwArgs.from === "drain" && !!kwArgs.of;

@@ -762,4 +700,3 @@ }

var _a;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1)
return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonHPStatus(args[2]) && verifyKWArgs(kwArgs, ["from", "silent"], this.gen) && kwArgs.from === "move: Pain Split";

@@ -771,9 +708,7 @@ }

const valid = args.length === 3 && verifyPokemonIdent(args[1]) && verifyStatusName(args[2]);
if (!valid)
return false;
if (!valid) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {
case 1:
case 2: {
if (!verifyKWArgs(kwArgs, ["from", "silent"], this.gen))
return false;
if (!verifyKWArgs(kwArgs, ["from", "silent"], this.gen)) return false;
if (kwArgs.from) {

@@ -785,6 +720,4 @@ return !kwArgs.silent && args[2] === "slp" && kwArgs.from.startsWith("move: ");

case 3: {
if (["frz", "tox"].includes(args[2]))
return !Object.keys(kwArgs).length;
if (!verifyKWArgs(kwArgs, ["from", "of"], this.gen))
return false;
if (["frz", "tox"].includes(args[2])) return !Object.keys(kwArgs).length;
if (!verifyKWArgs(kwArgs, ["from", "of"], this.gen)) return false;
if (args[2] === "slp") {

@@ -796,6 +729,4 @@ return !kwArgs.of && (!kwArgs.from || ((_b = kwArgs.from) == null ? void 0 : _b.startsWith("move: ")));

case 4: {
if (args[2] === "frz")
return !Object.keys(kwArgs).length;
if (!verifyKWArgs(kwArgs, ["from", "of"], this.gen))
return false;
if (args[2] === "frz") return !Object.keys(kwArgs).length;
if (!verifyKWArgs(kwArgs, ["from", "of"], this.gen)) return false;
if (args[2] === "slp") {

@@ -817,10 +748,7 @@ return !kwArgs.of && (!kwArgs.from || ((_c = kwArgs.from) == null ? void 0 : _c.startsWith("move: ")));

const valid = args.length === 3 && verifyPokemonIdent(args[1]) && verifyStatusName(args[2]);
if (!valid)
return false;
if (!valid) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {
case 1: {
if (!verifyKWArgs(kwArgs, ["msg", "silent"], this.gen))
return false;
if (kwArgs.msg)
return ["slp", "frz"].includes(args[2]);
if (!verifyKWArgs(kwArgs, ["msg", "silent"], this.gen)) return false;
if (kwArgs.msg) return ["slp", "frz"].includes(args[2]);
return !!kwArgs.silent;

@@ -832,11 +760,7 @@ }

case 4: {
if (!verifyKWArgs(kwArgs, ["msg", "silent", "from"], this.gen))
return false;
if (Object.keys(kwArgs).length > 1)
return false;
if (!kwArgs.from)
return true;
if (!verifyKWArgs(kwArgs, ["msg", "silent", "from"], this.gen)) return false;
if (Object.keys(kwArgs).length > 1) return false;
if (!kwArgs.from) return true;
if (args[2] === "frz") {
if (kwArgs.silent)
return false;
if (kwArgs.silent) return false;
} else {

@@ -846,4 +770,3 @@ return kwArgs.from === "ability: Natural Cure";

const from = ["move: Flame Wheel", "move: Sacred Fire", "ability: Natural Cure"];
if (this.gen.num === 4)
from.push("move: Flare Blitz");
if (this.gen.num === 4) from.push("move: Flare Blitz");
return from.includes(kwArgs.from);

@@ -856,9 +779,6 @@ }

"|-cureteam|"(args, kwArgs) {
if (this.gen && (this.gen.num < 2 || this.gen.num > 4))
return false;
if (this.gen && (this.gen.num < 2 || this.gen.num > 4)) return false;
const valid = args.length === 2 && verifyPokemonIdent(args[1]) && verifyKWArgs(kwArgs, ["from"], this.gen);
if (!valid)
return false;
if (!this.gen)
return true;
if (!valid) return false;
if (!this.gen) return true;
return kwArgs.from === (this.gen.num === 2 ? "move: Heal Bell" : "move: Aromatherapy");

@@ -870,7 +790,5 @@ }

const valid = args.length === 4 && verifyPokemonIdent(args[1]) && verifyBoostID(args[2]) && verifyNum(args[3]);
if (!valid)
return false;
if (!valid) return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) {
if (kwArgs.from === "Rage" && args[2] === "atk")
return true;
if (kwArgs.from === "Rage" && args[2] === "atk") return true;
return !Object.keys(kwArgs).length;

@@ -884,6 +802,4 @@ }

const valid = args.length === 4 && verifyPokemonIdent(args[1]) && verifyBoostID(args[2]) && verifyNum(args[3]);
if (!valid)
return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1)
return !Object.keys(kwArgs).length;
if (!valid) return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) return !Object.keys(kwArgs).length;
return verifyKWArgs(kwArgs, [...KWARGS, "multiple", "zeffect"], this.gen);

@@ -893,4 +809,3 @@ }

var _a;
if (this.gen && this.gen.num < 2)
return false;
if (this.gen && this.gen.num < 2) return false;
const from = ((_a = this.gen) == null ? void 0 : _a.num) === 2 ? ["move: Belly Drum"] : ["move: Belly Drum", "ability: Anger Point"];

@@ -900,10 +815,6 @@ return args.length === 4 && verifyPokemonIdent(args[1]) && args[2] === "atk" && verifyNum(args[3]) && verifyKWArgs(kwArgs, ["from"], this.gen) && from.includes(kwArgs.from);

"|-swapboost|"(args, kwArgs) {
if (!(verifyPokemonIdent(args[1]) && verifyPokemonIdent(args[2])))
return false;
if (!verifyKWArgs(kwArgs, ["from"], this.gen))
return false;
if (!this.gen)
return args.length === 3 || args.length === 4 && verifyBoostIDs(args[3]);
if (this.gen.num < 4)
return false;
if (!(verifyPokemonIdent(args[1]) && verifyPokemonIdent(args[2]))) return false;
if (!verifyKWArgs(kwArgs, ["from"], this.gen)) return false;
if (!this.gen) return args.length === 3 || args.length === 4 && verifyBoostIDs(args[3]);
if (this.gen.num < 4) return false;
switch (kwArgs.from) {

@@ -921,27 +832,19 @@ case "move: Heart Swap":

"|-invertboost|"(args, kwArgs) {
if (this.gen && this.gen.num < 6)
return false;
if (this.gen && this.gen.num < 6) return false;
return args.length === 2 && verifyPokemonIdent(args[1]) && verifyKWArgs(kwArgs, ["from"], this.gen) && kwArgs.from === "move: Topsy-Turvy";
}
"|-clearboost|"(args, kwArgs) {
if (!(args.length === 2 && verifyPokemonIdent(args[1])))
return false;
if (!this.gen)
return verifyKWArgs(kwArgs, [...KWARGS], this.gen);
if (this.gen.num < 5)
return false;
if (this.gen.num < 8)
return !Object.keys(kwArgs).length;
if (!(args.length === 2 && verifyPokemonIdent(args[1]))) return false;
if (!this.gen) return verifyKWArgs(kwArgs, [...KWARGS], this.gen);
if (this.gen.num < 5) return false;
if (this.gen.num < 8) return !Object.keys(kwArgs).length;
return verifyKWArgs(kwArgs, ["from", "of"], this.gen) && !kwArgs.from || kwArgs.from === "ability: Curious Medicine" && !!kwArgs.of;
}
"|-clearallboost|"(args, kwArgs) {
if (args.length !== 1 || !verifyKWArgs(kwArgs, ["silent"], this.gen))
return false;
if (!this.gen)
return true;
if (args.length !== 1 || !verifyKWArgs(kwArgs, ["silent"], this.gen)) return false;
if (!this.gen) return true;
return this.gen.num === 1 ? kwArgs.silent === true : !Object.keys(kwArgs).length;
}
"|-clearpositiveboost|"(args) {
if (this.gen && this.gen.num < 7)
return false;
if (this.gen && this.gen.num < 7) return false;
return args.length === 4 && verifyPokemonIdent(args[1]) && verifyPokemonIdent(args[2]) && args[3] === "move: Spectral Thief";

@@ -953,14 +856,11 @@ }

"|-candynamax|"(args) {
if (this.gen && this.gen.num < 8)
return false;
if (this.gen && this.gen.num < 8) return false;
return args.length === 2 && verifyPlayer(args[1]);
}
"|-terastallize|"(args) {
if (this.gen && this.gen.num < 9)
return false;
if (this.gen && this.gen.num < 9) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyType(args[2]);
}
"|-clearnegativeboost|"(args, kwArgs) {
if (this.gen && this.gen.num < 3)
return false;
if (this.gen && this.gen.num < 3) return false;
return args.length === 2 && verifyPokemonIdent(args[1]) && verifyKWArgs(kwArgs, ["silent", "zeffect"], this.gen) && Object.keys(kwArgs).length === 1;

@@ -970,4 +870,3 @@ }

var _a;
if (this.gen && this.gen.num < 2)
return false;
if (this.gen && this.gen.num < 2) return false;
const from = ((_a = this.gen) == null ? void 0 : _a.num) === 2 ? ["move: Psych Up"] : ["move: Psych Up", "ability: Costar"];

@@ -978,6 +877,4 @@ return args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonIdent(args[2]) && verifyKWArgs(kwArgs, ["from"], this.gen) && from.includes(kwArgs.from);

var _a;
if (args.length !== 2)
return false;
if (args[1] === "none")
return !Object.keys(kwArgs).length;
if (args.length !== 2) return false;
if (args[1] === "none") return !Object.keys(kwArgs).length;
const weather = [0, 0, 3, 4, 4, 4, 7, 7, 7, 8];

@@ -1009,12 +906,7 @@ const to = [0, 0, 0, 3, 4, 4, 7, 7, 8, 9];

case 9: {
if (!WEATHER.slice(0, weather[this.gen.num]).includes(args[1]))
return false;
if (this.gen.num === 9 && args[1] === "Hail")
return false;
if (!verifyKWArgs(kwArgs, ["upkeep", "from", "of"], this.gen))
return false;
if (!Object.keys(kwArgs).length)
return true;
if (kwArgs.upkeep)
return Object.keys(kwArgs).length === 1;
if (!WEATHER.slice(0, weather[this.gen.num]).includes(args[1])) return false;
if (this.gen.num === 9 && args[1] === "Hail") return false;
if (!verifyKWArgs(kwArgs, ["upkeep", "from", "of"], this.gen)) return false;
if (!Object.keys(kwArgs).length) return true;
if (kwArgs.upkeep) return Object.keys(kwArgs).length === 1;
return !!kwArgs.of && abilities.slice(0, to[this.gen.num]).includes(kwArgs.from);

@@ -1029,4 +921,3 @@ }

"|-fieldstart|"(args, kwArgs) {
if (this.gen && this.gen.num < 4)
return false;
if (this.gen && this.gen.num < 4) return false;
return args.length === 2 && (verifyMoveEffectName(args[1], this.gen) || verifyFieldCondition(args[1])) && verifyKWArgs(kwArgs, KWARGS, this.gen);

@@ -1036,4 +927,3 @@ }

"|-fieldend|"(args, kwArgs) {
if (this.gen && this.gen.num < 4)
return false;
if (this.gen && this.gen.num < 4) return false;
return args.length === 2 && (verifyMoveEffectName(args[1], this.gen) || verifyFieldCondition(args[1])) && verifyKWArgs(kwArgs, KWARGS, this.gen);

@@ -1044,4 +934,3 @@ }

const valid = args.length === 3 && verifySide(args[1]) && (!this.gen || this.gen.num >= 8 ? verifyKWArgs(kwArgs, ["silent"], this.gen) : !Object.keys(kwArgs).length);
if (!valid)
return false;
if (!valid) return false;
const modern = [

@@ -1080,2 +969,3 @@ "Reflect",

return modern.slice(0, 4).includes(args[2]);
// NB: modern
case 3:

@@ -1102,9 +992,7 @@ return classic.slice(0, 5).includes(args[2]);

"|-sideend|"(args, kwArgs) {
if (this.gen && this.gen.num < 2)
return false;
if (this.gen && this.gen.num < 2) return false;
return args.length === 3 && verifySide(args[1]) && (verifyMoveEffectName(args[2], this.gen) || verifySideCondition(args[2])) && verifyKWArgs(kwArgs, KWARGS, this.gen);
}
"|-swapsideconditions|"(args) {
if (this.gen && this.gen.num < 8)
return false;
if (this.gen && this.gen.num < 8) return false;
return args.length === 1;

@@ -1115,4 +1003,3 @@ }

var _a;
if (!verifyPokemonIdent(args[1]) || args.length > 4)
return false;
if (!verifyPokemonIdent(args[1]) || args.length > 4) return false;
if (((_a = this.gen) == null ? void 0 : _a.num) === 1) {

@@ -1140,4 +1027,3 @@ if (args.length === 3) {

const keys = [...KWARGS, "already", "damage", "block", "fatigue", "upkeep", "zeffect"];
if (!verifyKWArgs(kwArgs, keys, this.gen))
return false;
if (!verifyKWArgs(kwArgs, keys, this.gen)) return false;
if (args[2] === "Dynamax") {

@@ -1162,4 +1048,3 @@ return args.length === 3 || args.length === 4 && (args[3] === "Gmax" || args[3] === "");

const valid = args.length === 3 && verifyPokemonIdent(args[1]) && verifyKWArgs(kwArgs, ["silent"], this.gen);
if (!valid)
return false;
if (!valid) return false;
return (kwArgs.silent ? [

@@ -1196,4 +1081,3 @@ "Disable",

var _a;
if (!verifyPokemonIdent(args[1]))
return false;
if (!verifyPokemonIdent(args[1])) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {

@@ -1209,11 +1093,8 @@ case 1:

}
if (!(args.length === 2 && verifyKWArgs(kwArgs, ["from", "ohko"], this.gen)))
return false;
if (Object.keys(kwArgs).length > 1)
return false;
if (!(args.length === 2 && verifyKWArgs(kwArgs, ["from", "ohko"], this.gen))) return false;
if (Object.keys(kwArgs).length > 1) return false;
return !kwArgs.from || (kwArgs.from.startsWith("ability: ") || this.gen.num === 4 && kwArgs.from === "Oblivious");
}
default: {
if (!verifyKWArgs(kwArgs, [...KWARGS, "ohko"], this.gen))
return false;
if (!verifyKWArgs(kwArgs, [...KWARGS, "ohko"], this.gen)) return false;
return args.length === 2 || args.length === 3 && args[2] === "confusion";

@@ -1225,4 +1106,3 @@ }

"|-item|"(args, kwArgs) {
if (this.gen && this.gen.num < 2)
return false;
if (this.gen && this.gen.num < 2) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyItemName(args[2], this.gen) && verifyKWArgs(kwArgs, [...KWARGS, "identify"], this.gen);

@@ -1232,4 +1112,3 @@ }

"|-enditem|"(args, kwArgs) {
if (this.gen && this.gen.num < 2)
return false;
if (this.gen && this.gen.num < 2) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyItemName(args[2], this.gen) && verifyKWArgs(kwArgs, [...KWARGS, "eat", "move", "weaken"], this.gen);

@@ -1239,10 +1118,6 @@ }

"|-ability|"(args, kwArgs) {
if (this.gen && this.gen.num < 3)
return false;
if (!verifyKWArgs(kwArgs, [...KWARGS, "move", "weaken", "fail"], this.gen))
return false;
if (!(verifyPokemonIdent(args[1]) && verifyAbilityName(args[2], this.gen)))
return false;
if (args.length === 3)
return true;
if (this.gen && this.gen.num < 3) return false;
if (!verifyKWArgs(kwArgs, [...KWARGS, "move", "weaken", "fail"], this.gen)) return false;
if (!(verifyPokemonIdent(args[1]) && verifyAbilityName(args[2], this.gen))) return false;
if (args.length === 3) return true;
if (args.length === 4) {

@@ -1255,8 +1130,5 @@ return args[3] === "boost" || verifySide(args[3]) || verifyPokemonIdent(args[3]);

"|-endability|"(args, kwArgs) {
if (this.gen && this.gen.num < 3)
return false;
if (!verifyKWArgs(kwArgs, KWARGS, this.gen))
return false;
if (!verifyPokemonIdent(args[1]))
return false;
if (this.gen && this.gen.num < 3) return false;
if (!verifyKWArgs(kwArgs, KWARGS, this.gen)) return false;
if (!verifyPokemonIdent(args[1])) return false;
return args.length === 2 || args.length === 3 && (args[2] === "none" || verifyAbilityName(args[2], this.gen));

@@ -1266,31 +1138,24 @@ }

const valid = args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonIdent(args[2]);
if (!valid)
return false;
if (this.gen && this.gen.num < 5)
return !Object.keys(kwArgs).length;
if (!valid) return false;
if (this.gen && this.gen.num < 5) return !Object.keys(kwArgs).length;
return verifyKWArgs(kwArgs, ["from"], this.gen) && (!kwArgs.from || kwArgs.from === "ability: Imposter");
}
"|-mega|"(args) {
if (this.gen && (this.gen.num < 6 || this.gen.num > 7))
return false;
if (this.gen && (this.gen.num < 6 || this.gen.num > 7)) return false;
return args.length === 4 && verifyPokemonIdent(args[1]) && verifySpeciesName(args[2], this.gen) && (args[3] === "" || verifyItemName(args[3], this.gen));
}
"|-primal|"(args) {
if (this.gen && this.gen.num < 6)
return false;
if (this.gen && this.gen.num < 6) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && ["Blue Orb", "Red Orb"].includes(args[2]);
}
"|-burst|"(args) {
if (this.gen && this.gen.num < 7)
return false;
if (this.gen && this.gen.num < 7) return false;
return args.length === 4 && verifyPokemonIdent(args[1]) && verifySpeciesName(args[2], this.gen) && verifyItemName(args[3], this.gen);
}
"|-zpower|"(args) {
if (this.gen && this.gen.num < 7)
return false;
if (this.gen && this.gen.num < 7) return false;
return args.length === 2 && verifyPokemonIdent(args[1]);
}
"|-zbroken|"(args) {
if (this.gen && this.gen.num < 7)
return false;
if (this.gen && this.gen.num < 7) return false;
return args.length === 2 && verifyPokemonIdent(args[1]);

@@ -1303,6 +1168,4 @@ }

const valid = (args.length === 3 || args.length === 4 && args[3] === "") && verifyKWArgs(kwArgs, ["damage"], this.gen);
if (!valid)
return false;
if (args[1] === "")
return args[2] === "move: Splash";
if (!valid) return false;
if (args[1] === "") return args[2] === "move: Splash";
return verifyPokemonIdent(args[1]) && (kwArgs.damage ? args[2] === "Substitute" : ["Bide", "confusion", "move: Haze", "move: Mist", "move: Struggle"].includes(args[2]));

@@ -1325,11 +1188,8 @@ }

];
if (!verifyKWArgs(kwArgs, keys, this.gen))
return false;
if (!(args[1] === "" || verifyPokemonIdent(args[1])))
return false;
if (!verifyKWArgs(kwArgs, keys, this.gen)) return false;
if (!(args[1] === "" || verifyPokemonIdent(args[1]))) return false;
if (!(verifyEffectName(args[2], this.gen) || verifyAbilityName(args[2], this.gen) || verifyMoveName(args[2], this.gen))) {
return false;
}
if (args.length === 3)
return true;
if (args.length === 3) return true;
if (args.length === 4) {

@@ -1341,6 +1201,4 @@ return args[3] === "" || verifyAbilityName(args[3], this.gen) || verifyItemName(args[3], this.gen) || verifyMoveName(args[3], this.gen) || verifyNum(args[3]) || verifyPokemonIdent(args[3]);

"|-fieldactivate|"(args) {
if (args.length !== 2)
return false;
if (!this.gen)
return args[1] === "Delta Stream" || verifyEffectName(args[1], this.gen);
if (args.length !== 2) return false;
if (!this.gen) return args[1] === "Delta Stream" || verifyEffectName(args[1], this.gen);
const effects = [

@@ -1361,4 +1219,3 @@ "move: Pay Day",

"|-center|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 1;

@@ -1370,16 +1227,12 @@ }

"|-combine|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 1;
}
"|-waiting|"(args) {
if (this.gen && this.gen.num < 5)
return false;
if (this.gen && this.gen.num < 5) return false;
return args.length === 3 && verifyPokemonIdent(args[1]) && verifyPokemonIdent(args[2]);
}
"|-prepare|"(args) {
if (!(verifyPokemonIdent(args[1]) && verifyMoveName(args[2], this.gen)))
return false;
if (this.gen && this.gen.num < 5)
return args.length === 3;
if (!(verifyPokemonIdent(args[1]) && verifyMoveName(args[2], this.gen))) return false;
if (this.gen && this.gen.num < 5) return args.length === 3;
return args[2] === "Sky Drop" ? args.length === 4 && verifyPokemonIdent(args[3]) : args.length === 3;

@@ -1396,4 +1249,3 @@ }

const valid = args.length === 3 && verifyPokemonIdent(args[1]);
if (!valid)
return false;
if (!valid) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {

@@ -1409,4 +1261,3 @@ case 1:

const reasons = ["Destiny Bond", "Rage"];
if (this.gen.num >= 3)
reasons.push("Grudge");
if (this.gen.num >= 3) reasons.push("Grudge");
return !Object.keys(kwArgs).length && reasons.includes(args[2]);

@@ -1430,4 +1281,3 @@ }

const valid = args.length === 3 && verifyPokemonIdent(args[1]);
if (!valid)
return false;
if (!valid) return false;
switch (((_a = this.gen) == null ? void 0 : _a.num) || 0) {

@@ -1443,10 +1293,6 @@ case 1:

}
if (this.gen.num >= 4)
reasons.push("move: Roost");
if (!reasons.includes(args[2]))
return false;
if (this.gen.num === 2 && Object.keys(kwArgs).length)
return false;
if (!verifyKWArgs(kwArgs, ["of"], this.gen))
return false;
if (this.gen.num >= 4) reasons.push("move: Roost");
if (!reasons.includes(args[2])) return false;
if (this.gen.num === 2 && Object.keys(kwArgs).length) return false;
if (!verifyKWArgs(kwArgs, ["of"], this.gen)) return false;
return !kwArgs.of || args[2] === "Helping Hand";

@@ -1463,4 +1309,3 @@ }

"|-nothing|"(args) {
if (!this.raw)
throw new Error("Encountered non-upgraded |-nothing arg");
if (!this.raw) throw new Error("Encountered non-upgraded |-nothing arg");
return args.length === 1;

@@ -1472,11 +1317,8 @@ }

this.handler = new Handler(gen);
if (raw)
this.raw = new Handler(gen, raw);
if (raw) this.raw = new Handler(gen, raw);
}
verify(data) {
for (const { roomid, args, kwArgs } of _chunk4XYC7FTLjs.Protocol.parse(data)) {
if (!verifyRoomID(roomid))
return data;
if (!this.dispatch(args, kwArgs, false))
return data;
for (const { roomid, args, kwArgs } of _chunkRV4CKQH6js.Protocol.parse(data)) {
if (!verifyRoomID(roomid)) return data;
if (!this.dispatch(args, kwArgs, false)) return data;
}

@@ -1486,5 +1328,4 @@ return void 0;

verifyLine(line) {
const parsed = _chunk4XYC7FTLjs.Protocol.parseBattleLine(line);
if (!this.dispatch(parsed.args, parsed.kwArgs, false))
return parsed;
const parsed = _chunkRV4CKQH6js.Protocol.parseBattleLine(line);
if (!this.dispatch(parsed.args, parsed.kwArgs, false)) return parsed;
return void 0;

@@ -1494,7 +1335,5 @@ }

const handler = raw && this.raw ? this.raw : this.handler;
const key = _chunk4XYC7FTLjs.Protocol.key(args, raw);
if (!key || !handler[key])
return false;
if (Object.keys(kwArgs).length && !(key in _chunk4XYC7FTLjs.Protocol.ARGS_WITH_KWARGS))
return false;
const key = _chunkRV4CKQH6js.Protocol.key(args, raw);
if (!key || !handler[key]) return false;
if (Object.keys(kwArgs).length && !(key in _chunkRV4CKQH6js.Protocol.ARGS_WITH_KWARGS)) return false;
return handler[key](args, kwArgs);

@@ -1501,0 +1340,0 @@ }

{
"name": "@pkmn/protocol",
"version": "0.6.25",
"version": "0.6.26",
"description": "Parsing logic for Pokémon Showdown's PROTOCOL and SIM-PROTOCOL",

@@ -43,4 +43,4 @@ "repository": "github:pkmn/ps",

"devDependencies": {
"@pkmn/dex": "^0.9.4",
"@pkmn/data": "^0.9.4"
"@pkmn/dex": "^0.9.13",
"@pkmn/data": "^0.9.13"
},

@@ -47,0 +47,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc