@pkmn/protocol
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -38,3 +38,3 @@ "use strict"; | ||
'|-waiting|': 1, '|-prepare|': 1, '|-mustrecharge|': 1, '|-hitcount|': 1, '|-singlemove|': 1, | ||
'|-singleturn|': 1, '|-anim|': 1, '|warning|': 1, | ||
'|-singleturn|': 1, '|-anim|': 1, '|warning|': 1, '|-candynamax|': 1, | ||
}; | ||
@@ -41,0 +41,0 @@ this.ARGS_WITH_KWARGS = { |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var e={};function t(e){return(""+e).toLowerCase().replace(/[^a-z0-9]+/g,"")}function a(e){switch(e[0]){case"name":case"n":case"N":var t=e[0];return["name",e[1],e[2],"N"===t];case"chat":case"c":return["chat",e[1],e[2]];case"join":case"j":case"J":var a=e[0];return["join",e[1],"J"===a];case"leave":case"l":case"L":var r=e[0];return["leave",e[1],"L"===r];case"battle":case"b":return["battle",e[1],e[2],e[3]]}return e}e.Protocol=new(function(){function n(){this.ARGS={"|init|":1,"|title|":1,"|userlist|":1,"||":1,"|html|":1,"|uhtml|":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,"|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,"|split|":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},this.ARGS_WITH_KWARGS={"|move|":1,"|detailschange|":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,"|-fieldactivate|":1,"|-fieldstart|":1,"|-fieldend|":1,"|-sidestart|":1,"|-sideend|":1,"|-start|":1,"|-end|":1,"|-immune|":1,"|-item|":1,"|-enditem|":1,"|-ability|":1,"|-endability|":1,"|-transform|":1,"|-activate|":1,"|-singleturn|":1,"|-miss|":1,"|-clearallboost|":1,"|-anim|":1,"|-copyboost|":1,"|-clearboost|":1,"|-clearpositiveboost|":1,"|-singlemove|":1,"|switch|":1}}var o=n.prototype;return o.parse=function*(e){for(var t="",a=0,r=e.split("\n").entries();a<r.length;a++){var s=r[a],i=s[0],n=s[1];if(0!==i||">"!==n[0]){if(n){var o=this.parseBattleLine(n),l=o.args,c=o.kwArgs;yield{roomid:t,args:l,kwArgs:c}}}else t=n.slice(1)}},o.key=function(e){var t="tournament"===e[0]?"|"+e[0]+"|"+e[1]+"|":"|"+e[0]+"|";return t in this.ARGS?t:void 0},o.parseLine=function(e,t){if(!e.startsWith("|"))return["",e];if("|"===e)return["done"];var r=e.indexOf("|",1),s=e.slice(1,r);switch(s){case"chatmsg":case"chatmsg-raw":case"raw":case"error":case"html":case"inactive":case"inactiveoff":case"warning":case"fieldhtml":case"controlshtml":case"bigerror":case"debug":case"tier":case"challstr":case"popup":case"":return a([s,e.slice(r+1)]);case"c":case"chat":case"uhtml":case"uhtmlchange":var i=e.indexOf("|",r+1);return a([s,e.slice(r+1,i),e.slice(i+1)]);case"c:":case"pm":var n=e.indexOf("|",r+1),o=e.indexOf("|",n+1);return a([s,e.slice(r+1,n),e.slice(n+1,o),e.slice(o+1)])}return t?null:a(e.slice(1).split("|"))},o.parseBattleLine=function(n){var o=e.Protocol.parseLine(n,!0);if(o)return{args:o,kwArgs:{}};o=n.slice(1).split("|");for(var l={};o.length>1;){var c=o[o.length-1];if("["!==c.charAt(0))break;var u=c.indexOf("]");if(u<=0)break;l[c.slice(1,u)]=c.slice(u+1).trim()||!0,o.pop()}return function(a){var n=a.args,o=a.kwArgs;switch(n[0]){case"-activate":if(o.item||o.move||o.number||o.ability)return{args:n,kwArgs:o};var l=n,c=l[1],u=l[2],m=l[3],p=l[4],g=u,f=o.of,v=e.Protocol.parseEffect(g,t).name;if(o.block)return{args:["-fail",c],kwArgs:o};if("sturdy"===v)return{args:["-activate",c,"ability: Sturdy"],kwArgs:o};if("wonderguard"===v)return{args:["-immune",c],kwArgs:{from:"ability: Wonder Guard"}};if("beatup"===v&&o.of)return{args:n,kwArgs:{name:o.of}};if(r.has(v))return f?(o.of=c,{args:["-block",f,g,m||""],kwArgs:o}):{args:["-block",c,g,m||""],kwArgs:o};if("charge"===v)return{args:["-singlemove",c,g],kwArgs:{of:f||void 0}};if(s.has(v))return{args:["-start",c,g],kwArgs:{of:f||""}};if("fairylock"===v)return{args:["-fieldactivate",g],kwArgs:{}};if("symbiosis"===v||"poltergeist"===v)o.item=m;else if("magnitude"===v)o.number=m;else if("skillswap"===v||"mummy"===v)o.ability=m,o.ability2=p;else if("wanderingspirit"===v){if(!m)return{args:["-ability",c,"Wandering Spirit"],kwArgs:{}};o.ability=m,o.ability2=p}else i.has(v)&&(o.move=m,o.number=p);return{args:["-activate",c,g,f||""],kwArgs:o};case"-start":"Protean"!==o.from&&"Color Change"!==o.from||(o.from="ability:"+o.from);break;case"move":"Magic Bounce"===o.from&&(o.from="ability: Magic Bounce");break;case"cant":var h=n,d=h[1],b=h[2],w=h[3];if(["ability: Queenly Majesty","ability: Damp","ability: Dazzling"].includes(b))return{args:["-block",d,b,w,o.of||""],kwArgs:{}};break;case"gen":var y=n[1];return{args:["gen",Number(y)],kwArgs:{}};case"-nothing":n=["-activate","","move: Splash"]}return{args:n,kwArgs:o}}({args:a(o),kwArgs:l})},o.parsePokemonIdent=function(e){var t,a,r=e.indexOf(":"),s=e.slice(0,r),i=e.slice(r+2);return s.length<3?(t=s,a=null):(t=s.slice(0,2),a=s.charAt(2)),{player:t,position:a,name:i}},o.parseDetails=function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};r.details=a;var s=!e;r.name=e,r.speciesForme=e,r.level=100,r.shiny=!1,r.gender=void 0,r.ident=s?"":t,r.searchid=s?"":t+"|"+a;var i=a.split(", ");"shiny"===i[i.length-1]&&(r.shiny=!0,i.pop());var n=i[i.length-1];return"M"!==n&&"F"!==n||(r.gender=n,i.pop()),i[1]&&(r.level=parseInt(i[1].substr(1))||100),i[0]&&(r.speciesForme=i[0]),r},o.parseHealth=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e.split(" "),r=a[0],s=a[1];if(t.hpcolor="","0"===r||"0.0"===r)t.maxhp||(t.maxhp=100),t.hp=0;else if(r.indexOf("/")>0){var i=r.split("/"),n=i[0],o=i[1];if(isNaN(parseFloat(n))||isNaN(parseFloat(o)))return null;t.hp=parseFloat(n),t.maxhp=parseFloat(o),t.hp>t.maxhp&&(t.hp=t.maxhp);var l=o.slice(-1);"y"!==l&&"g"!==l||(t.hpcolor=l)}else isNaN(parseFloat(r))||(t.maxhp||(t.maxhp=100),t.hp=t.maxhp*parseFloat(r)/100);return s?"par"===s||"brn"===s||"slp"===s||"frz"===s||"tox"===s||"psn"===s&&"tox"!==t.status?t.status=s:"fnt"===s&&(t.hp=0,t.fainted=!0):t.status=void 0,t},o.parseEffect=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){return e.trim()};return e?e.startsWith("item:")||e.startsWith("move:")?{name:t(e.slice(5)),type:e.slice(0,4)}:e.startsWith("ability:")?{name:t(e.slice(8)),type:"ability"}:{name:t(e)}:{name:t("")}},o.parseRequest=function(e){var a=JSON.parse(e);if(a.requestType||(a.requestType="move",a.forceSwitch?a.requestType="switch":a.teamPreview?a.requestType="team":a.wait&&(a.requestType="wait")),"wait"===a.requestType&&(a.noCancel=!0),a.side)for(var r=0,s=a.side.pokemon;r<s.length;r++){var i=s[r];this.parseDetails(i.ident.substr(4),i.ident,i.details,i),this.parseHealth(i.condition,i),i.ability=i.ability||i.baseAbility}if(a.active){a.active=a.active.map((function(e,t){return a.side.pokemon[t].fainted?null:e}));for(var n=0,o=a.active;n<o.length;n++){var l=o[n];if(l){for(var c=0,u=l.moves;c<u.length;c++){var m=u[c];m.move&&(m.name=m.move),m.id=t(m.name)}if(l.maxMoves){l.maxMoves.maxMoves&&(l.canGigantamax=l.maxMoves.gigantamax,l.maxMoves=l.maxMoves.maxMoves);for(var p=0,g=l.maxMoves;p<g.length;p++){var f=g[p];f.id=f.move}}if(l.canZMove){l.zMoves=l.canZMove;for(var v=0,h=l.zMoves;v<h.length;v++){var d=h[v];d&&(d.move&&(d.name=d.move),d.id=t(d.name))}}}}}return a},o.parseChallenges=function(e){return JSON.parse(e)},o.parseSearchState=function(e){return JSON.parse(e)},o.parseTournamentUpdate=function(e){return JSON.parse(e)},o.parseNameParts=function(e){var t="";/[A-Za-z0-9]/.test(e.charAt(0))||(t=e.charAt(0),e=e.slice(1));var a=e,r=e.indexOf("@"),s="",i=!1;return r>0&&(a=e.slice(0,r),(s=e.slice(r+1)).startsWith("!")&&(i=!0,s=s.slice(1))),{group:t,name:a,away:i,status:s}},n}());var r=new Set(["ingrain","quickguard","wideguard","craftyshield","matblock","protect","mist","safeguard","electricterrain","mistyterrain","psychicterrain","telepathy","stickyhold","suctioncups","aromaveil","flowerveil","sweetveil","disguise","safetygoggles","protectivepads"]),s=new Set(["thundercage","clamp","whirlpool","firespin","magmastorm","sandtomb","infestation","trapped","bind","snaptrap","wrap"]),i=new Set(["eeriespell","gmaxdepletion","spite","grudge","forewarn","sketch","leppaberry","mysteryberry"]);window.Protocol=e.Protocol}(); | ||
!function(){"use strict";var e={};function t(e){return(""+e).toLowerCase().replace(/[^a-z0-9]+/g,"")}function a(e){switch(e[0]){case"name":case"n":case"N":var t=e[0];return["name",e[1],e[2],"N"===t];case"chat":case"c":return["chat",e[1],e[2]];case"join":case"j":case"J":var a=e[0];return["join",e[1],"J"===a];case"leave":case"l":case"L":var r=e[0];return["leave",e[1],"L"===r];case"battle":case"b":return["battle",e[1],e[2],e[3]]}return e}e.Protocol=new(function(){function n(){this.ARGS={"|init|":1,"|title|":1,"|userlist|":1,"||":1,"|html|":1,"|uhtml|":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,"|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,"|split|":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},this.ARGS_WITH_KWARGS={"|move|":1,"|detailschange|":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,"|-fieldactivate|":1,"|-fieldstart|":1,"|-fieldend|":1,"|-sidestart|":1,"|-sideend|":1,"|-start|":1,"|-end|":1,"|-immune|":1,"|-item|":1,"|-enditem|":1,"|-ability|":1,"|-endability|":1,"|-transform|":1,"|-activate|":1,"|-singleturn|":1,"|-miss|":1,"|-clearallboost|":1,"|-anim|":1,"|-copyboost|":1,"|-clearboost|":1,"|-clearpositiveboost|":1,"|-singlemove|":1,"|switch|":1}}var o=n.prototype;return o.parse=function*(e){for(var t="",a=0,r=e.split("\n").entries();a<r.length;a++){var s=r[a],i=s[0],n=s[1];if(0!==i||">"!==n[0]){if(n){var o=this.parseBattleLine(n),c=o.args,l=o.kwArgs;yield{roomid:t,args:c,kwArgs:l}}}else t=n.slice(1)}},o.key=function(e){var t="tournament"===e[0]?"|"+e[0]+"|"+e[1]+"|":"|"+e[0]+"|";return t in this.ARGS?t:void 0},o.parseLine=function(e,t){if(!e.startsWith("|"))return["",e];if("|"===e)return["done"];var r=e.indexOf("|",1),s=e.slice(1,r);switch(s){case"chatmsg":case"chatmsg-raw":case"raw":case"error":case"html":case"inactive":case"inactiveoff":case"warning":case"fieldhtml":case"controlshtml":case"bigerror":case"debug":case"tier":case"challstr":case"popup":case"":return a([s,e.slice(r+1)]);case"c":case"chat":case"uhtml":case"uhtmlchange":var i=e.indexOf("|",r+1);return a([s,e.slice(r+1,i),e.slice(i+1)]);case"c:":case"pm":var n=e.indexOf("|",r+1),o=e.indexOf("|",n+1);return a([s,e.slice(r+1,n),e.slice(n+1,o),e.slice(o+1)])}return t?null:a(e.slice(1).split("|"))},o.parseBattleLine=function(n){var o=e.Protocol.parseLine(n,!0);if(o)return{args:o,kwArgs:{}};o=n.slice(1).split("|");for(var c={};o.length>1;){var l=o[o.length-1];if("["!==l.charAt(0))break;var u=l.indexOf("]");if(u<=0)break;c[l.slice(1,u)]=l.slice(u+1).trim()||!0,o.pop()}return function(a){var n=a.args,o=a.kwArgs;switch(n[0]){case"-activate":if(o.item||o.move||o.number||o.ability)return{args:n,kwArgs:o};var c=n,l=c[1],u=c[2],m=c[3],p=c[4],g=u,f=o.of,v=e.Protocol.parseEffect(g,t).name;if(o.block)return{args:["-fail",l],kwArgs:o};if("sturdy"===v)return{args:["-activate",l,"ability: Sturdy"],kwArgs:o};if("wonderguard"===v)return{args:["-immune",l],kwArgs:{from:"ability: Wonder Guard"}};if("beatup"===v&&o.of)return{args:n,kwArgs:{name:o.of}};if(r.has(v))return f?(o.of=l,{args:["-block",f,g,m||""],kwArgs:o}):{args:["-block",l,g,m||""],kwArgs:o};if("charge"===v)return{args:["-singlemove",l,g],kwArgs:{of:f||void 0}};if(s.has(v))return{args:["-start",l,g],kwArgs:{of:f||""}};if("fairylock"===v)return{args:["-fieldactivate",g],kwArgs:{}};if("symbiosis"===v||"poltergeist"===v)o.item=m;else if("magnitude"===v)o.number=m;else if("skillswap"===v||"mummy"===v)o.ability=m,o.ability2=p;else if("wanderingspirit"===v){if(!m)return{args:["-ability",l,"Wandering Spirit"],kwArgs:{}};o.ability=m,o.ability2=p}else i.has(v)&&(o.move=m,o.number=p);return{args:["-activate",l,g,f||""],kwArgs:o};case"-start":"Protean"!==o.from&&"Color Change"!==o.from||(o.from="ability:"+o.from);break;case"move":"Magic Bounce"===o.from&&(o.from="ability: Magic Bounce");break;case"cant":var h=n,d=h[1],b=h[2],w=h[3];if(["ability: Queenly Majesty","ability: Damp","ability: Dazzling"].includes(b))return{args:["-block",d,b,w,o.of||""],kwArgs:{}};break;case"gen":var y=n[1];return{args:["gen",Number(y)],kwArgs:{}};case"-nothing":n=["-activate","","move: Splash"]}return{args:n,kwArgs:o}}({args:a(o),kwArgs:c})},o.parsePokemonIdent=function(e){var t,a,r=e.indexOf(":"),s=e.slice(0,r),i=e.slice(r+2);return s.length<3?(t=s,a=null):(t=s.slice(0,2),a=s.charAt(2)),{player:t,position:a,name:i}},o.parseDetails=function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};r.details=a;var s=!e;r.name=e,r.speciesForme=e,r.level=100,r.shiny=!1,r.gender=void 0,r.ident=s?"":t,r.searchid=s?"":t+"|"+a;var i=a.split(", ");"shiny"===i[i.length-1]&&(r.shiny=!0,i.pop());var n=i[i.length-1];return"M"!==n&&"F"!==n||(r.gender=n,i.pop()),i[1]&&(r.level=parseInt(i[1].substr(1))||100),i[0]&&(r.speciesForme=i[0]),r},o.parseHealth=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e.split(" "),r=a[0],s=a[1];if(t.hpcolor="","0"===r||"0.0"===r)t.maxhp||(t.maxhp=100),t.hp=0;else if(r.indexOf("/")>0){var i=r.split("/"),n=i[0],o=i[1];if(isNaN(parseFloat(n))||isNaN(parseFloat(o)))return null;t.hp=parseFloat(n),t.maxhp=parseFloat(o),t.hp>t.maxhp&&(t.hp=t.maxhp);var c=o.slice(-1);"y"!==c&&"g"!==c||(t.hpcolor=c)}else isNaN(parseFloat(r))||(t.maxhp||(t.maxhp=100),t.hp=t.maxhp*parseFloat(r)/100);return s?"par"===s||"brn"===s||"slp"===s||"frz"===s||"tox"===s||"psn"===s&&"tox"!==t.status?t.status=s:"fnt"===s&&(t.hp=0,t.fainted=!0):t.status=void 0,t},o.parseEffect=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){return e.trim()};return e?e.startsWith("item:")||e.startsWith("move:")?{name:t(e.slice(5)),type:e.slice(0,4)}:e.startsWith("ability:")?{name:t(e.slice(8)),type:"ability"}:{name:t(e)}:{name:t("")}},o.parseRequest=function(e){var a=JSON.parse(e);if(a.requestType||(a.requestType="move",a.forceSwitch?a.requestType="switch":a.teamPreview?a.requestType="team":a.wait&&(a.requestType="wait")),"wait"===a.requestType&&(a.noCancel=!0),a.side)for(var r=0,s=a.side.pokemon;r<s.length;r++){var i=s[r];this.parseDetails(i.ident.substr(4),i.ident,i.details,i),this.parseHealth(i.condition,i),i.ability=i.ability||i.baseAbility}if(a.active){a.active=a.active.map((function(e,t){return a.side.pokemon[t].fainted?null:e}));for(var n=0,o=a.active;n<o.length;n++){var c=o[n];if(c){for(var l=0,u=c.moves;l<u.length;l++){var m=u[l];m.move&&(m.name=m.move),m.id=t(m.name)}if(c.maxMoves){c.maxMoves.maxMoves&&(c.canGigantamax=c.maxMoves.gigantamax,c.maxMoves=c.maxMoves.maxMoves);for(var p=0,g=c.maxMoves;p<g.length;p++){var f=g[p];f.id=f.move}}if(c.canZMove){c.zMoves=c.canZMove;for(var v=0,h=c.zMoves;v<h.length;v++){var d=h[v];d&&(d.move&&(d.name=d.move),d.id=t(d.name))}}}}}return a},o.parseChallenges=function(e){return JSON.parse(e)},o.parseSearchState=function(e){return JSON.parse(e)},o.parseTournamentUpdate=function(e){return JSON.parse(e)},o.parseNameParts=function(e){var t="";/[A-Za-z0-9]/.test(e.charAt(0))||(t=e.charAt(0),e=e.slice(1));var a=e,r=e.indexOf("@"),s="",i=!1;return r>0&&(a=e.slice(0,r),(s=e.slice(r+1)).startsWith("!")&&(i=!0,s=s.slice(1))),{group:t,name:a,away:i,status:s}},n}());var r=new Set(["ingrain","quickguard","wideguard","craftyshield","matblock","protect","mist","safeguard","electricterrain","mistyterrain","psychicterrain","telepathy","stickyhold","suctioncups","aromaveil","flowerveil","sweetveil","disguise","safetygoggles","protectivepads"]),s=new Set(["thundercage","clamp","whirlpool","firespin","magmastorm","sandtomb","infestation","trapped","bind","snaptrap","wrap"]),i=new Set(["eeriespell","gmaxdepletion","spite","grudge","forewarn","sketch","leppaberry","mysteryberry"]);window.Protocol=e.Protocol}(); |
@@ -105,2 +105,3 @@ import { Protocol, Args, KWArgs } from '../index'; | ||
'|-ohko|'(args: Args['|-ohko|']): boolean; | ||
'|-candynamax|'(args: Args['|-candynamax|']): boolean; | ||
'|-clearnegativeboost|'(args: Args['|-clearnegativeboost|'], kwArgs: KWArgs['|-clearnegativeboost|']): boolean; | ||
@@ -107,0 +108,0 @@ '|-copyboost|'(args: Args['|-copyboost|'], kwArgs: KWArgs['|-copyboost|']): boolean; |
@@ -564,2 +564,5 @@ "use strict"; | ||
} | ||
'|-candynamax|'(args) { | ||
return args.length === 2 && verifyPlayer(args[1]); | ||
} | ||
'|-clearnegativeboost|'(args, kwArgs) { | ||
@@ -566,0 +569,0 @@ return args.length === 2 && |
{ | ||
"name": "@pkmn/protocol", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"main": "build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "build/index.d.ts", |
@@ -656,2 +656,6 @@ import {BoostName, GameType, ID, Player, StatusName} from '@pkmn/types'; | ||
'|-candynamax|'(args: Args['|-candynamax|']) { | ||
return args.length === 2 && verifyPlayer(args[1]); | ||
} | ||
'|-clearnegativeboost|'( | ||
@@ -658,0 +662,0 @@ args: Args['|-clearnegativeboost|'], kwArgs: KWArgs['|-clearnegativeboost|'] |
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 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 too big to display
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
453547
6967