@pkmn/protocol
Advanced tools
Comparing version 0.6.24 to 0.6.25
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
var _chunkTC4NPYKQjs = require('./chunk-TC4NPYKQ.js'); | ||
var _chunk4XYC7FTLjs = require('./chunk-4XYC7FTL.js'); | ||
exports.Protocol = _chunkTC4NPYKQjs.Protocol; exports.ignoreKwArgsSimple = _chunkTC4NPYKQjs.ignoreKwArgsSimple; | ||
exports.Protocol = _chunk4XYC7FTLjs.Protocol; exports.ignoreKwArgsSimple = _chunk4XYC7FTLjs.ignoreKwArgsSimple; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
window.pkmn=window.pkmn||{};window.pkmn.protocol=(()=>{var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},N=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of u(e))!A.call(o,a)&&a!==t&&d(o,a,{get:()=>e[a],enumerable:!(r=g(e,a))||r.enumerable});return o};var P=o=>N(d({},"__esModule",{value:!0}),o);var v={};f(v,{Protocol:()=>c,ignoreKwArgsSimple:()=>y});function p(o){return(""+o).toLowerCase().replace(/[^a-z0-9]+/g,"")}var y=new Set(["chatmsg","chatmsg-raw","raw","error","html","inactive","inactiveoff","warning","title","formats","selectorhtml","pagehtml","fieldhtml","controlshtml","bigerror","debug","tier","challstr","popup","","customgroups","notify"]),c=new class{constructor(){this.ARGS={"|init|":1,"|title|":1,"|users|":1,"||":1,"|html|":1,"|uhtml|":1,"|pagehtml|":1,"|uhtmlchange|":1,"|join|":1,"|leave|":1,"|name|":1,"|chat|":1,"|notify|":1,"|:|":1,"|c:|":1,"|t:|":1,"|battle|":1,"|popup|":1,"|pm|":1,"|usercount|":1,"|nametaken|":1,"|challstr|":1,"|updateuser|":1,"|formats|":1,"|updatesearch|":1,"|message|":1,"|updatechallenges|":1,"|queryresponse|":1,"|unlink|":1,"|raw|":1,"|error|":1,"|bigerror|":1,"|chatmsg|":1,"|chatmsg-raw|":1,"|controlshtml|":1,"|fieldhtml|":1,"|debug|":1,"|deinit|":1,"|selectorhtml|":1,"|refresh|":1,"|tempnotify|":1,"|tempnotifyoff|":1,"|noinit|":1,"|hidelines|":1,"|expire|":1,"|askreg|":1,"|tournament|create|":1,"|tournament|update|":1,"|tournament|updateEnd|":1,"|tournament|error|":1,"|tournament|forceend|":1,"|tournament|join|":1,"|tournament|leave|":1,"|tournament|replace|":1,"|tournament|start|":1,"|tournament|disqualify|":1,"|tournament|battlestart|":1,"|tournament|battleend|":1,"|tournament|end|":1,"|tournament|scouting|":1,"|tournament|autostart|":1,"|tournament|autodq|":1,"|player|":1,"|teamsize|":1,"|gametype|":1,"|gen|":1,"|tier|":1,"|rated|":1,"|seed|":1,"|rule|":1,"|teampreview|":1,"|clearpoke|":1,"|poke|":1,"|start|":1,"|done|":1,"|request|":1,"|inactive|":1,"|inactiveoff|":1,"|upkeep|":1,"|turn|":1,"|win|":1,"|tie|":1,"|move|":1,"|switch|":1,"|drag|":1,"|detailschange|":1,"|replace|":1,"|swap|":1,"|cant|":1,"|faint|":1,"|-formechange|":1,"|-fail|":1,"|-block|":1,"|-notarget|":1,"|-miss|":1,"|-damage|":1,"|-heal|":1,"|-sethp|":1,"|-status|":1,"|-curestatus|":1,"|-cureteam|":1,"|-boost|":1,"|-unboost|":1,"|-setboost|":1,"|-swapboost|":1,"|-invertboost|":1,"|-clearboost|":1,"|-clearallboost|":1,"|-clearpositiveboost|":1,"|-ohko|":1,"|-clearnegativeboost|":1,"|-copyboost|":1,"|-weather|":1,"|-fieldstart|":1,"|-fieldend|":1,"|-sidestart|":1,"|-sideend|":1,"|-start|":1,"|-end|":1,"|-crit|":1,"|-supereffective|":1,"|-resisted|":1,"|-immune|":1,"|-item|":1,"|-enditem|":1,"|-ability|":1,"|-endability|":1,"|-transform|":1,"|-mega|":1,"|-primal|":1,"|-burst|":1,"|-zpower|":1,"|-zbroken|":1,"|-activate|":1,"|-fieldactivate|":1,"|-hint|":1,"|-center|":1,"|-message|":1,"|-combine|":1,"|-waiting|":1,"|-prepare|":1,"|-mustrecharge|":1,"|-hitcount|":1,"|-singlemove|":1,"|-singleturn|":1,"|-anim|":1,"|warning|":1,"|-candynamax|":1,"|updatepoke|":1,"|-swapsideconditions|":1,"|-terastallize|":1,"|sentchoice|":1,"|customgroups|":1};this.ARGS_WITH_KWARGS={"|move|":1,"|switch|":1,"|cant|":1,"|-formechange|":1,"|-fail|":1,"|-block|":1,"|-damage|":1,"|-heal|":1,"|-sethp|":1,"|-status|":1,"|swap|":1,"|-curestatus|":1,"|-cureteam|":1,"|-boost|":1,"|-unboost|":1,"|-setboost|":1,"|-swapboost|":1,"|-invertboost|":1,"|-clearnegativeboost|":1,"|-weather|":1,"|-fieldstart|":1,"|-fieldend|":1,"|-sidestart|":1,"|-singlemove|":1,"|-sideend|":1,"|-start|":1,"|-end|":1,"|-immune|":1,"|-item|":1,"|-enditem|":1,"|-ability|":1,"|-endability|":1,"|-transform|":1,"|-activate|":1,"|-singleturn|":1,"|-clearallboost|":1,"|-anim|":1,"|-copyboost|":1,"|-clearboost|":1,"|-miss|":1}}*parse(o){let e=o.split(` | ||
`),t="";for(let[r,a]of e.entries())if(r===0&&a[0]===">"){t=a.slice(1);continue}else if(a){let{args:n,kwArgs:s}=this.parseBattleLine(a);yield{roomid:t,args:n,kwArgs:s}}}key(o,e=!1){let t=o[0]==="tournament"?`|${o[0]}|${o[1]}|`:`|${o[0]}|`;return e||t in this.ARGS?t:void 0}parseLine(o,e){if(!o.startsWith("|"))return["",o];if(o==="|")return["done"];let t=o.indexOf("|",1),r=o.slice(1,t);if(y.has(r))return m([r,o.slice(t+1)]);switch(r){case"c":case"chat":case"uhtml":case"uhtmlchange":let a=o.indexOf("|",t+1);return m([r,o.slice(t+1,a),o.slice(a+1)]);case"c:":case"pm":let n=o.indexOf("|",t+1),s=o.indexOf("|",n+1);return m([r,o.slice(t+1,n),o.slice(n+1,s),o.slice(s+1)])}return e?null:m(o.slice(1).split("|"))}parseBattleLine(o){let e=c.parseLine(o,!0);if(e)return{args:e,kwArgs:{}};e=o.slice(1).split("|");let t={};for(;e.length>1;){let r=e[e.length-1];if(r.charAt(0)!=="[")break;let a=r.indexOf("]");if(a<=0)break;t[r.slice(1,a)]=r.slice(a+1).trim()||!0,e.pop()}return T({args:m(e),kwArgs:t})}parsePokemonIdent(o){let e=o.indexOf(":"),t=o.slice(0,e),r=o.slice(e+2),a,n;return t.length<3?(a=t,n=null):(a=t.slice(0,2),n=t.charAt(2)),{player:a,position:n,name:r}}parseDetails(o,e,t="",r={}){r.details=t;let a=!o;r.name=o,r.speciesForme=o,r.level=100,r.shiny=!1,r.gender=void 0,r.ident=a?"":e,r.searchid=a?"":`${e}|${t}`;let n=t.split(", ");n[n.length-1].startsWith("tera:")&&(r.terastallized=n[n.length-1].slice(5),n.pop()),n[n.length-1]==="shiny"&&(r.shiny=!0,n.pop());let s=n[n.length-1];return(s==="M"||s==="F")&&(r.gender=s,n.pop()),n[1]&&(r.level=parseInt(n[1].substr(1))||100),n[0]&&(r.speciesForme=n[0]),r}parseHealth(o,e={}){let[t,r]=o.split(" ");if(e.hpcolor="",t==="0"||t==="0.0")e.maxhp||(e.maxhp=100),e.hp=0;else if(t.indexOf("/")>0){let[a,n]=t.split("/");if(isNaN(parseFloat(a))||isNaN(parseFloat(n)))return null;e.hp=parseFloat(a),e.maxhp=parseFloat(n),e.hp>e.maxhp&&(e.hp=e.maxhp);let s=n.slice(-1);(s==="y"||s==="g")&&(e.hpcolor=s)}else isNaN(parseFloat(t))||(e.maxhp||(e.maxhp=100),e.hp=e.maxhp*parseFloat(t)/100);return r?r==="par"||r==="brn"||r==="slp"||r==="frz"||r==="tox"||r==="psn"&&e.status!=="tox"?e.status=r:r==="fnt"&&(e.hp=0,e.fainted=!0):e.status=void 0,e}parseEffect(o,e=t=>t.trim()){return o?o.startsWith("item:")||o.startsWith("move:")?{name:e(o.slice(5)),type:o.slice(0,4)}:o.startsWith("ability:")?{name:e(o.slice(8)),type:"ability"}:{name:e(o)}:{name:e("")}}parseRequest(o){let e=JSON.parse(o);if(e.requestType||(e.requestType="move",e.forceSwitch?e.requestType="switch":e.teamPreview?e.requestType="team":e.wait&&(e.requestType="wait")),e.requestType==="wait"&&(e.noCancel=!0),e.side)for(let t of e.side.pokemon)this.parseDetails(t.ident.substr(4),t.ident,t.details,t),this.parseHealth(t.condition,t),t.ability=t.ability||t.baseAbility;if(e.active){e.active=e.active.map((t,r)=>e.side.pokemon[r].fainted?null:t);for(let t of e.active)if(t){for(let r of t.moves)r.move&&(r.name=r.move),r.id=p(r.name);if(t.maxMoves){t.maxMoves.maxMoves&&(t.canGigantamax=t.maxMoves.gigantamax,t.maxMoves=t.maxMoves.maxMoves);for(let r of t.maxMoves)r.id=r.move}if(t.canZMove){t.zMoves=t.canZMove;for(let r of t.zMoves)r&&(r.move&&(r.name=r.move),r.id=p(r.name))}}}return e}parseChallenges(o){return JSON.parse(o)}parseSearchState(o){return JSON.parse(o)}parseTournamentUpdate(o){return JSON.parse(o)}parseCustomGroupsJSON(o){return JSON.parse(o)}parseNameParts(o){let e="";/[A-Za-z0-9]/.test(o.charAt(0))||(e=o.charAt(0),o=o.slice(1));let t=o,r=o.indexOf("@"),a="",n=!1;return r>0&&(t=o.slice(0,r),a=o.slice(r+1),a.startsWith("!")&&(n=!0,a=a.slice(1))),{group:e,name:t,away:n,status:a}}};function m(o){switch(o[0]){case"name":case"n":case"N":{let[e,t,r]=o;return["name",t,r,e==="N"]}case"chat":case"c":{let[,e,t]=o;return["chat",e,t]}case"join":case"j":case"J":{let[e,t]=o;return["join",t,e==="J"]}case"leave":case"l":case"L":{let[e,t]=o;return["leave",t,e==="L"]}case"battle":case"b":{let[,e,t,r]=o;return["battle",e,t,r]}}return o}var h=new Set(["ingrain","quickguard","wideguard","craftyshield","matblock","protect","mist","safeguard","electricterrain","mistyterrain","psychicterrain","telepathy","stickyhold","suctioncups","aromaveil","flowerveil","sweetveil","disguise","safetygoggles","protectivepads"]),x=new Set(["ability: Damp","ability: Dazzling","ability: Queenly Majesty","ability: Armor Tail"]),k=new Set(["thundercage","clamp","whirlpool","firespin","magmastorm","sandtomb","infestation","trapped","bind","snaptrap","wrap"]),b=new Set(["eeriespell","gmaxdepletion","spite","grudge","forewarn","sketch","leppaberry","mysteryberry"]),I=new Set(["dryskin","eartheater","voltabsorb","waterabsorb"]);function T({args:o,kwArgs:e}){switch(o[0]){case"-activate":{if(e.item||e.move||e.number||e.ability)return{args:o,kwArgs:e};let[,t,r,a,n]=o,s=r,i=e.of,l=c.parseEffect(s,p).name;if(e.block)return{args:["-fail",t],kwArgs:e};if(l==="sturdy")return{args:["-activate",t,"ability: Sturdy"],kwArgs:e};if(l==="wonderguard")return{args:["-immune",t],kwArgs:{from:"ability: Wonder Guard"}};if(l==="beatup"&&e.of)return{args:o,kwArgs:{name:e.of}};if(h.has(l))return i?(e.of=t,{args:["-block",i,s,a||""],kwArgs:e}):{args:["-block",t,s,a||""],kwArgs:e};if(l==="charge")return{args:["-singlemove",t,"Charge"],kwArgs:{of:i||void 0}};if(k.has(l))return{args:["-start",t,s],kwArgs:{of:i||""}};if(l==="fairylock")return{args:["-fieldactivate",s],kwArgs:{}};if(l==="symbiosis"||l==="poltergeist")e.item=a;else if(l==="magnitude")e.number=a;else if(l==="skillswap"||l==="mummy"||l==="lingeringaroma")e.ability=a,e.ability2=n;else if(l==="wanderingspirit")if(a)e.ability=a,e.ability2=n;else return{args:["-ability",t,"Wandering Spirit"],kwArgs:{}};else b.has(l)&&(e.move=a,e.number=n);return{args:["-activate",t,s,i||""],kwArgs:e}}case"-start":{(e.from==="Protean"||e.from==="Color Change")&&(e.from="ability:"+e.from);break}case"move":{e.from==="Magic Bounce"&&(e.from="ability: Magic Bounce");break}case"cant":{let[,t,r,a]=o;if(x.has(r))return{args:["-block",t,r,a,e.of||""],kwArgs:{}};break}case"-heal":{let t=c.parseEffect(e.from,p).name;I.has(t)&&(e.of="");break}case"gen":{let[,t]=o;return{args:["gen",Number(t)],kwArgs:{}}}case"-restoreboost":{o[0]="-clearnegativeboost";break}case"-nothing":o=["-activate","","move: Splash"]}return{args:o,kwArgs:e}}return P(v);})(); | ||
window.pkmn=window.pkmn||{};window.pkmn.protocol=(()=>{var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var N=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of u(e))!A.call(o,a)&&a!==t&&d(o,a,{get:()=>e[a],enumerable:!(r=g(e,a))||r.enumerable});return o};var P=o=>f(d({},"__esModule",{value:!0}),o);var v={};N(v,{Protocol:()=>c,ignoreKwArgsSimple:()=>y});function p(o){return(""+o).toLowerCase().replace(/[^a-z0-9]+/g,"")}var y=new Set(["chatmsg","chatmsg-raw","raw","error","html","inactive","inactiveoff","warning","title","formats","selectorhtml","pagehtml","fieldhtml","controlshtml","bigerror","debug","tier","challstr","popup","","customgroups","notify"]),c=new class{constructor(){this.ARGS={"|init|":1,"|title|":1,"|users|":1,"||":1,"|html|":1,"|uhtml|":1,"|pagehtml|":1,"|uhtmlchange|":1,"|join|":1,"|leave|":1,"|name|":1,"|chat|":1,"|notify|":1,"|:|":1,"|c:|":1,"|t:|":1,"|battle|":1,"|popup|":1,"|pm|":1,"|usercount|":1,"|nametaken|":1,"|challstr|":1,"|updateuser|":1,"|formats|":1,"|updatesearch|":1,"|message|":1,"|updatechallenges|":1,"|queryresponse|":1,"|unlink|":1,"|raw|":1,"|error|":1,"|bigerror|":1,"|chatmsg|":1,"|chatmsg-raw|":1,"|controlshtml|":1,"|fieldhtml|":1,"|debug|":1,"|deinit|":1,"|selectorhtml|":1,"|refresh|":1,"|tempnotify|":1,"|tempnotifyoff|":1,"|noinit|":1,"|hidelines|":1,"|expire|":1,"|askreg|":1,"|tournament|create|":1,"|tournament|update|":1,"|tournament|updateEnd|":1,"|tournament|error|":1,"|tournament|forceend|":1,"|tournament|join|":1,"|tournament|leave|":1,"|tournament|replace|":1,"|tournament|start|":1,"|tournament|disqualify|":1,"|tournament|battlestart|":1,"|tournament|battleend|":1,"|tournament|end|":1,"|tournament|scouting|":1,"|tournament|autostart|":1,"|tournament|autodq|":1,"|player|":1,"|teamsize|":1,"|gametype|":1,"|gen|":1,"|tier|":1,"|rated|":1,"|seed|":1,"|rule|":1,"|teampreview|":1,"|custom|":1,"|clearpoke|":1,"|poke|":1,"|start|":1,"|done|":1,"|request|":1,"|inactive|":1,"|inactiveoff|":1,"|upkeep|":1,"|turn|":1,"|win|":1,"|tie|":1,"|move|":1,"|switch|":1,"|drag|":1,"|detailschange|":1,"|replace|":1,"|swap|":1,"|cant|":1,"|faint|":1,"|-formechange|":1,"|-fail|":1,"|-block|":1,"|-notarget|":1,"|-miss|":1,"|-damage|":1,"|-heal|":1,"|-sethp|":1,"|-status|":1,"|-curestatus|":1,"|-cureteam|":1,"|-boost|":1,"|-unboost|":1,"|-setboost|":1,"|-swapboost|":1,"|-invertboost|":1,"|-clearboost|":1,"|-clearallboost|":1,"|-clearpositiveboost|":1,"|-ohko|":1,"|-clearnegativeboost|":1,"|-copyboost|":1,"|-weather|":1,"|-fieldstart|":1,"|-fieldend|":1,"|-sidestart|":1,"|-sideend|":1,"|-start|":1,"|-end|":1,"|-crit|":1,"|-supereffective|":1,"|-resisted|":1,"|-immune|":1,"|-item|":1,"|-enditem|":1,"|-ability|":1,"|-endability|":1,"|-transform|":1,"|-mega|":1,"|-primal|":1,"|-burst|":1,"|-zpower|":1,"|-zbroken|":1,"|-activate|":1,"|-fieldactivate|":1,"|-hint|":1,"|-center|":1,"|-message|":1,"|-combine|":1,"|-waiting|":1,"|-prepare|":1,"|-mustrecharge|":1,"|-hitcount|":1,"|-singlemove|":1,"|-singleturn|":1,"|-anim|":1,"|warning|":1,"|-candynamax|":1,"|updatepoke|":1,"|-swapsideconditions|":1,"|-terastallize|":1,"|sentchoice|":1,"|customgroups|":1};this.ARGS_WITH_KWARGS={"|move|":1,"|switch|":1,"|cant|":1,"|-formechange|":1,"|-fail|":1,"|-block|":1,"|-damage|":1,"|-heal|":1,"|-sethp|":1,"|-status|":1,"|swap|":1,"|-curestatus|":1,"|-cureteam|":1,"|-boost|":1,"|-unboost|":1,"|-setboost|":1,"|-swapboost|":1,"|-invertboost|":1,"|-clearnegativeboost|":1,"|-weather|":1,"|-fieldstart|":1,"|-fieldend|":1,"|-sidestart|":1,"|-singlemove|":1,"|-sideend|":1,"|-start|":1,"|-end|":1,"|-immune|":1,"|-item|":1,"|-enditem|":1,"|-ability|":1,"|-endability|":1,"|-transform|":1,"|-activate|":1,"|-singleturn|":1,"|-clearallboost|":1,"|-anim|":1,"|-copyboost|":1,"|-clearboost|":1,"|-miss|":1}}*parse(o){let e=o.split(` | ||
`),t="";for(let[r,a]of e.entries())if(r===0&&a[0]===">"){t=a.slice(1);continue}else if(a){let{args:n,kwArgs:s}=this.parseBattleLine(a);yield{roomid:t,args:n,kwArgs:s}}}key(o,e=!1){let t=o[0]==="tournament"?`|${o[0]}|${o[1]}|`:`|${o[0]}|`;return e||t in this.ARGS?t:void 0}parseLine(o,e){if(!o.startsWith("|"))return["",o];if(o==="|")return["done"];let t=o.indexOf("|",1),r=o.slice(1,t);if(y.has(r))return i([r,o.slice(t+1)]);switch(r){case"c":case"chat":case"uhtml":case"uhtmlchange":let a=o.indexOf("|",t+1);return i([r,o.slice(t+1,a),o.slice(a+1)]);case"c:":case"pm":let n=o.indexOf("|",t+1),s=o.indexOf("|",n+1);return i([r,o.slice(t+1,n),o.slice(n+1,s),o.slice(s+1)])}return e?null:i(o.slice(1).split("|"))}parseBattleLine(o){let e=c.parseLine(o,!0);if(e)return{args:e,kwArgs:{}};e=o.slice(1).split("|");let t={};for(;e.length>1;){let r=e[e.length-1];if(r.charAt(0)!=="[")break;let a=r.indexOf("]");if(a<=0)break;t[r.slice(1,a)]=r.slice(a+1).trim()||!0,e.pop()}return T({args:i(e),kwArgs:t})}parsePokemonIdent(o){let e=o.indexOf(":"),t=o.slice(0,e),r=o.slice(e+2),a,n;return t.length<3?(a=t,n=null):(a=t.slice(0,2),n=t.charAt(2)),{player:a,position:n,name:r}}parseDetails(o,e,t="",r={}){r.details=t;let a=!o;r.name=o,r.speciesForme=o,r.level=100,r.shiny=!1,r.gender=void 0,r.ident=a?"":e,r.searchid=a?"":`${e}|${t}`;let n=t.split(", ");n[n.length-1].startsWith("tera:")&&(r.terastallized=n[n.length-1].slice(5),n.pop()),n[n.length-1]==="shiny"&&(r.shiny=!0,n.pop());let s=n[n.length-1];return(s==="M"||s==="F")&&(r.gender=s,n.pop()),n[1]&&(r.level=parseInt(n[1].substr(1))||100),n[0]&&(r.speciesForme=n[0]),r}parseHealth(o,e={}){let[t,r]=o.split(" ");if(e.hpcolor="",t==="0"||t==="0.0")e.maxhp||(e.maxhp=100),e.hp=0;else if(t.indexOf("/")>0){let[a,n]=t.split("/");if(isNaN(parseFloat(a))||isNaN(parseFloat(n)))return null;e.hp=parseFloat(a),e.maxhp=parseFloat(n),e.hp>e.maxhp&&(e.hp=e.maxhp);let s=n.slice(-1);(s==="y"||s==="g")&&(e.hpcolor=s)}else isNaN(parseFloat(t))||(e.maxhp||(e.maxhp=100),e.hp=e.maxhp*parseFloat(t)/100);return r?r==="par"||r==="brn"||r==="slp"||r==="frz"||r==="tox"||r==="psn"&&e.status!=="tox"?e.status=r:r==="fnt"&&(e.hp=0,e.fainted=!0):e.status=void 0,e}parseEffect(o,e=t=>t.trim()){return o?o.startsWith("item:")||o.startsWith("move:")?{name:e(o.slice(5)),type:o.slice(0,4)}:o.startsWith("ability:")?{name:e(o.slice(8)),type:"ability"}:{name:e(o)}:{name:e("")}}parseRequest(o){let e=JSON.parse(o);if(e.requestType||(e.requestType="move",e.forceSwitch?e.requestType="switch":e.teamPreview?e.requestType="team":e.wait&&(e.requestType="wait")),e.requestType==="wait"&&(e.noCancel=!0),e.side)for(let t of e.side.pokemon)this.parseDetails(t.ident.substr(4),t.ident,t.details,t),this.parseHealth(t.condition,t),t.ability=t.ability||t.baseAbility;if(e.active){e.active=e.active.map((t,r)=>e.side.pokemon[r].fainted?null:t);for(let t of e.active)if(t){for(let r of t.moves)r.move&&(r.name=r.move),r.id=p(r.name);if(t.maxMoves){t.maxMoves.maxMoves&&(t.canGigantamax=t.maxMoves.gigantamax,t.maxMoves=t.maxMoves.maxMoves);for(let r of t.maxMoves)r.id=r.move}if(t.canZMove){t.zMoves=t.canZMove;for(let r of t.zMoves)r&&(r.move&&(r.name=r.move),r.id=p(r.name))}}}return e}parseChallenges(o){return JSON.parse(o)}parseSearchState(o){return JSON.parse(o)}parseTournamentUpdate(o){return JSON.parse(o)}parseCustomGroupsJSON(o){return JSON.parse(o)}parseNameParts(o){let e="";/[A-Za-z0-9]/.test(o.charAt(0))||(e=o.charAt(0),o=o.slice(1));let t=o,r=o.indexOf("@"),a="",n=!1;return r>0&&(t=o.slice(0,r),a=o.slice(r+1),a.startsWith("!")&&(n=!0,a=a.slice(1))),{group:e,name:t,away:n,status:a}}};function i(o){switch(o[0]){case"name":case"n":case"N":{let[e,t,r]=o;return["name",t,r,e==="N"]}case"chat":case"c":{let[,e,t]=o;return["chat",e,t]}case"join":case"j":case"J":{let[e,t]=o;return["join",t,e==="J"]}case"leave":case"l":case"L":{let[e,t]=o;return["leave",t,e==="L"]}case"battle":case"b":{let[,e,t,r]=o;return["battle",e,t,r]}}return o}var h=new Set(["ingrain","quickguard","wideguard","craftyshield","matblock","protect","mist","safeguard","electricterrain","mistyterrain","psychicterrain","telepathy","stickyhold","suctioncups","aromaveil","flowerveil","sweetveil","disguise","safetygoggles","protectivepads"]),x=new Set(["ability: Damp","ability: Dazzling","ability: Queenly Majesty","ability: Armor Tail"]),k=new Set(["thundercage","clamp","whirlpool","firespin","magmastorm","sandtomb","infestation","trapped","bind","snaptrap","wrap"]),b=new Set(["eeriespell","gmaxdepletion","spite","grudge","forewarn","sketch","leppaberry","mysteryberry"]),I=new Set(["dryskin","eartheater","voltabsorb","waterabsorb"]);function T({args:o,kwArgs:e}){switch(o[0]){case"-activate":{if(e.item||e.move||e.number||e.ability)return{args:o,kwArgs:e};let[,t,r,a,n]=o,s=r,m=e.of,l=c.parseEffect(s,p).name;if(e.block)return{args:["-fail",t],kwArgs:e};if(l==="sturdy")return{args:["-activate",t,"ability: Sturdy"],kwArgs:e};if(l==="wonderguard")return{args:["-immune",t],kwArgs:{from:"ability: Wonder Guard"}};if(l==="beatup"&&e.of)return{args:o,kwArgs:{name:e.of}};if(h.has(l))return m?(e.of=t,{args:["-block",m,s,a||""],kwArgs:e}):{args:["-block",t,s,a||""],kwArgs:e};if(l==="charge")return{args:["-singlemove",t,"Charge"],kwArgs:{of:m||void 0}};if(k.has(l))return{args:["-start",t,s],kwArgs:{of:m||""}};if(l==="fairylock")return{args:["-fieldactivate",s],kwArgs:{}};if(l==="symbiosis"||l==="poltergeist")e.item=a;else if(l==="magnitude")e.number=a;else if(l==="skillswap"||l==="mummy"||l==="lingeringaroma")e.ability=a,e.ability2=n;else if(l==="wanderingspirit")if(a)e.ability=a,e.ability2=n;else return{args:["-ability",t,"Wandering Spirit"],kwArgs:{}};else b.has(l)&&(e.move=a,e.number=n);return{args:["-activate",t,s,m||""],kwArgs:e}}case"-start":{(e.from==="Protean"||e.from==="Color Change")&&(e.from="ability:"+e.from);break}case"move":{e.from==="Magic Bounce"&&(e.from="ability: Magic Bounce");break}case"cant":{let[,t,r,a]=o;if(x.has(r))return{args:["-block",t,r,a,e.of||""],kwArgs:{}};break}case"-heal":{let t=c.parseEffect(e.from,p).name;I.has(t)&&(e.of="");break}case"gen":{let[,t]=o;return{args:["gen",Number(t)],kwArgs:{}}}case"-restoreboost":{o[0]="-clearnegativeboost";break}case"-nothing":o=["-activate","","move: Splash"]}return{args:o,kwArgs:e}}return P(v);})(); |
@@ -87,2 +87,3 @@ import { GenerationNum } from '@pkmn/types'; | ||
'|gen|'(args: Args['|gen|']): boolean; | ||
'|custom|'(): boolean; | ||
'|tier|'(args: Args['|tier|']): boolean; | ||
@@ -89,0 +90,0 @@ '|rated|'(args: Args['|rated|']): boolean; |
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
var _chunkTC4NPYKQjs = require('../chunk-TC4NPYKQ.js'); | ||
var _chunk4XYC7FTLjs = require('../chunk-4XYC7FTL.js'); | ||
@@ -471,2 +471,5 @@ // src/verifier/index.ts | ||
} | ||
"|custom|"() { | ||
return true; | ||
} | ||
"|tier|"(args) { | ||
@@ -1409,3 +1412,3 @@ return args.length === 2 && verifyName(args[1]); | ||
verify(data) { | ||
for (const { roomid, args, kwArgs } of _chunkTC4NPYKQjs.Protocol.parse(data)) { | ||
for (const { roomid, args, kwArgs } of _chunk4XYC7FTLjs.Protocol.parse(data)) { | ||
if (!verifyRoomID(roomid)) | ||
@@ -1419,3 +1422,3 @@ return data; | ||
verifyLine(line) { | ||
const parsed = _chunkTC4NPYKQjs.Protocol.parseBattleLine(line); | ||
const parsed = _chunk4XYC7FTLjs.Protocol.parseBattleLine(line); | ||
if (!this.dispatch(parsed.args, parsed.kwArgs, false)) | ||
@@ -1427,6 +1430,6 @@ return parsed; | ||
const handler = raw && this.raw ? this.raw : this.handler; | ||
const key = _chunkTC4NPYKQjs.Protocol.key(args, raw); | ||
const key = _chunk4XYC7FTLjs.Protocol.key(args, raw); | ||
if (!key || !handler[key]) | ||
return false; | ||
if (Object.keys(kwArgs).length && !(key in _chunkTC4NPYKQjs.Protocol.ARGS_WITH_KWARGS)) | ||
if (Object.keys(kwArgs).length && !(key in _chunk4XYC7FTLjs.Protocol.ARGS_WITH_KWARGS)) | ||
return false; | ||
@@ -1433,0 +1436,0 @@ return handler[key](args, kwArgs); |
{ | ||
"name": "@pkmn/protocol", | ||
"version": "0.6.24", | ||
"version": "0.6.25", | ||
"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.2", | ||
"@pkmn/data": "^0.9.2" | ||
"@pkmn/dex": "^0.9.4", | ||
"@pkmn/data": "^0.9.4" | ||
}, | ||
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
776444
6475