@pkmn/data 0.5.2 → 0.5.3

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.
@@ -1 +1 @@
1
- var _this=this;function _defineProperties(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),t}!function(){"use strict";var t={},e=_this&&_this.__await||function(t){return this instanceof e?(this.v=t,this):new e(t)},i=_this&&_this.__asyncGenerator||function(t,i,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s,r=n.apply(t,i||[]),o=[];return s={},a("next"),a("throw"),a("return"),s[Symbol.asyncIterator]=function(){return this},s;function a(t){r[t]&&(s[t]=function(e){return new Promise((function(i,n){o.push([t,e,i,n])>1||h(t,e)}))})}function h(t,i){try{(n=r[t](i)).value instanceof e?Promise.resolve(n.value.v).then(c,u):d(o[0][2],n)}catch(t){d(o[0][3],t)}var n}function c(t){h("next",t)}function u(t){h("throw",t)}function d(t,e){t(e),o.shift(),o.length&&h(o[0][0],o[0][1])}},n=_this&&_this.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(e){return new Promise((function(n,s){(function(t,e,i,n){Promise.resolve(n).then((function(e){t({value:e,done:i})}),e)})(n,s,(e=t[i](e)).done,e.value)}))}}};t.Stats=t.Learnsets=t.Type=t.Types=t.Natures=t.Conditions=t.Specie=t.Species=t.Moves=t.Items=t.Abilities=t.Generation=t.Generations=t.toID=void 0;var s=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e?(t>>>0)%2**e:t>>>0};function r(t,e,i){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&!i.has(n)&&(t[n]=e[n]);return t}function o(t){return(null==t?void 0:t.id)&&(t=t.id),"string"!=typeof t&&"number"!=typeof t?"":(""+t).toLowerCase().replace(/[^a-z0-9]+/g,"")}t.toID=o;var a=function(t){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.DEFAULT_EXISTS;this.cache=Object.create(null),this.dex=t,this.exists=i}var i=e.prototype;return i.get=function(t){var e=this;return this.cache[t]?this.cache[t]:this.cache[t]=new h(this.dex.forGen(t),(function(i){return e.exists(i,t)}))},i[t]=function*(){for(var t=1;t<=8;t++)yield this.get(t)},e}(Symbol.iterator);t.Generations=a,a.DEFAULT_EXISTS=function(t){return!!t.exists&&((!("isNonstandard"in t)||!t.isNonstandard)&&(("Ability"!==t.kind||"noability"!==t.id)&&!("tier"in t&&["Illegal","Unreleased"].includes(t.tier))))};var h=function(){function t(t,e){this.dex=t,this.exists=e,this.abilities=new c(this.dex,this.exists),this.items=new u(this.dex,this.exists),this.moves=new d(this.dex,this.exists),this.species=new f(this.dex,this.exists),this.natures=new p(this.dex,this.exists),this.types=new y(this.dex,this.exists),this.learnsets=new k(this,this.dex,this.exists),this.conditions=new v(this.dex,this.exists),this.stats=new P(this.dex)}var e=t.prototype;return e.toString=function(){return"[Generation:"+this.num+"]"},e.toJSON=function(){return this.toString()},_createClass(t,[{key:"num",get:function(){return this.dex.gen}}]),t}();t.Generation=h;var c=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.abilities.get(t);return this.exists(e)?e:void 0},i[t]=function*(){for(var t in this.dex.data.Abilities){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Abilities=c;var u=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.items.get(t);return this.exists(e)?e:void 0},i[t]=function*(){for(var t in this.dex.data.Items){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Items=u;var d=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.moves.get(t);return this.exists(e)?e:void 0},i[t]=function*(){for(var t in this.dex.data.Moves){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Moves=d;var f=function(t){function e(t,e){this.cache=Object.create(null),this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.species.get(t);if(this.exists(e)){var i=e.speciesid||e.id,n=this.cache[i];return n||(this.cache[i]=new l(this.dex,this.exists,e))}},i[t]=function*(){for(var t in this.dex.data.Species){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Species=f;var l=function(){function t(e,i,n){var s,o,a,h,c,u,d,f,l,v=this;r(this,n,t.EXCLUDE),this.dex=e,this.dex.gen>=2?(this.gender=n.gender,this.genderRatio=n.genderRatio):this.genderRatio={M:0,F:0},this.dex.gen>=3?(this.abilities={0:n.abilities[0]},n.abilities[1]&&this.dex.abilities.get(n.abilities[1]).gen<=this.dex.gen&&(this.abilities[1]=n.abilities[1]),this.dex.gen>=5&&n.abilities.H&&(this.abilities.H=n.abilities.H),this.dex.gen>=7&&n.abilities.S&&(this.abilities.S=n.abilities.S)):this.abilities={0:""},this.evos=null===(s=n.evos)||void 0===s?void 0:s.filter((function(t){return i(v.dex.species.get(t))})),this.nfe=!!(null===(o=this.evos)||void 0===o?void 0:o.length),this.nfe||(this.evos=void 0),this.cosmeticFormes=null===(a=n.cosmeticFormes)||void 0===a?void 0:a.filter((function(t){return i(v.dex.species.get(t))})),(null===(h=this.cosmeticFormes)||void 0===h?void 0:h.length)||(this.cosmeticFormes=void 0),this.otherFormes=null===(c=n.otherFormes)||void 0===c?void 0:c.filter((function(t){return i(v.dex.species.get(t))})),(null===(u=this.otherFormes)||void 0===u?void 0:u.length)||(this.otherFormes=void 0),this.formeOrder=null===(d=n.formeOrder)||void 0===d?void 0:d.filter((function(t){return i(v.dex.species.get(t))})),(null===(f=this.formeOrder)||void 0===f?void 0:f.length)||(this.formeOrder=void 0),this.formes=null===(l=this.formeOrder)||void 0===l?void 0:l.filter((function(t){return!v.dex.species.get(t).isGigantamax})),this.prevo=n.prevo&&i(this.dex.species.get(n.prevo))?n.prevo:void 0}var e=t.prototype;return e.toString=function(){return this.name},e.toJSON=function(){return r({},this,new Set(["dex"]))},_createClass(t,[{key:"formeNum",get:function(){var t=this;return this.baseSpecies===this.name?this.formeOrder?this.formeOrder.findIndex((function(e){return e===t.name})):0:this.dex.species.get(this.baseSpecies).formeOrder.findIndex((function(e){return e===(t.isGigantamax?t.baseSpecies:t.name)}))}}]),t}();t.Specie=l,l.EXCLUDE=new Set(["abilities","cosmeticFormes","evos","gender","genderRatio","nfe","otherFormes","prevo"]);var v=function(){function t(t,e){this.dex=t,this.exists=e}return t.prototype.get=function(t){var e=this.dex.conditions.get(t);return this.exists(e)?e:void 0},t}();t.Conditions=v;var p=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){if(!(this.dex.gen<3)){var e=this.dex.natures.get(t);return this.exists(e)?e:void 0}},i[t]=function*(){for(var t in this.dex.data.Natures){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Natures=p;var g={"-2":.25,"-1":.5,0:1,1:2,2:4},y=function(t){function e(t,e){this.cache=Object.create(null),this.dex=t,this.exists=e,this.unknown=new S({effectType:"Type",kind:"Type",id:"",name:"???",exists:t.gen<=4,gen:1,damageTaken:{},HPivs:{},HPdvs:{}},t,this)}var i=e.prototype;return i.get=function(t){if("???"===t)return this.unknown;var e=this.dex.types.get(t);if(this.exists(e)){var i=this.cache[e.id];return i||(this.cache[e.id]=new S(e,this.dex,this))}},i[t]=function*(){for(var t in this.dex.data.Types){var e=this.get(t);e&&(yield e)}this.dex.gen>=2&&this.dex.gen<=4&&(yield this.unknown)},i.getHiddenPower=function(t){return this.dex.getHiddenPower(t)},i.canDamage=function(t,e){return this.dex.getImmunity(t,e)},i.totalEffectiveness=function(t,e){if(!this.canDamage(t,e))return 0;var i=""+this.dex.getEffectiveness(t,e);return g[i]},e}(Symbol.iterator);t.Types=y;var x=[1,2,.5,0],m=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],S=function(){function t(t,e,i){for(var n in Object.assign(this,t),this.types=i,this.category="Fairy"===this.name?void 0:m.includes(this.name)?"Special":"Physical",this.effectiveness={"???":1},e.data.Types){var s=n.charAt(0).toUpperCase()+n.slice(1);this.effectiveness[s]=x[e.data.Types[n].damageTaken[this.name]||0]}}var e=t.prototype;return e.canDamage=function(t){return this.types.canDamage(this.name,t)},e.totalEffectiveness=function(t){return this.types.totalEffectiveness(this.name,t)},e.toString=function(){return this.name},e.toJSON=function(){return r({},this,new Set(["types"]))},t}();t.Type=S;var b=new Set(["cut","fly","surf","strength","flash","rocksmash","waterfall","dive"]),w=new Set(["cut","fly","surf","strength","rocksmash","waterfall","rockclimb"]),k=function(t){function s(t,e,i){this.cache=Object.create(null),this.gen=t,this.dex=e,this.exists=i}var r=s.prototype;return r.get=async function(t){var e=await this.dex.learnsets.get(o(t));return this.exists(e)?e:void 0},r[t]=function(){return i(this,arguments,(function*(){for(var t in this.dex.data.Learnsets||(yield e(this.dex.learnsets.get("LOAD"))),this.dex.data.Learnsets){var i=yield e(this.get(t));i&&(yield yield e(i))}}))},r.all=function(t){return i(this,arguments,(function*(){var i=t.id,n=yield e(this.get(i));for(n||(i="string"==typeof t.battleOnly&&t.battleOnly!==t.baseSpecies?o(t.battleOnly):o(t.baseSpecies),n=yield e(this.get(i)));n&&(yield yield e(n),i="lycanrocdusk"===i||"rockruff"===t.id&&"rockruff"===i?"rockruffdusk":"gastrodoneast"===t.id?"gastrodon":"pumpkaboosuper"===t.id?"pumpkaboo":o(t.battleOnly||t.changesFrom||t.prevo));){var s=this.gen.species.get(i);if(!s)break;t=s,n=yield e(this.get(i))}}))},r.learnable=async function(t,e){var i,s,r=this,o=this.gen.species.get(t);if(o){if(!e){var a=this.cache[o.id];if(a)return a}var h={};try{for(var c,u=n(this.all(o));!(c=await u.next()).done;){var d=c.value;if(d.learnset)for(var f in d.learnset){var l=this.gen.moves.get(f);if(l){var v=d.learnset[f];this.isLegal(l,v,e||this.gen)&&(h[l.id]=v.filter((function(t){return+t.charAt(0)<=r.gen.num})))}}}}catch(t){i={error:t}}finally{try{c&&!c.done&&(s=u.return)&&await s.call(u)}finally{if(i)throw i.error}}return e||(this.cache[o.id]=h),h}},r.canLearn=async function(t,e,i){var s,r,o,a=this.gen.species.get(t);if(!a)return!1;if("string"==typeof(e="string"==typeof e&&this.gen.moves.get(e)||e))return!1;try{for(var h,c=n(this.all(a));!(h=await c.next()).done;){var u=h.value;if(this.isLegal(e,null===(o=u.learnset)||void 0===o?void 0:o[e.id],i||this.gen))return!0}}catch(t){s={error:t}}finally{try{h&&!h.done&&(r=c.return)&&await r.call(c)}finally{if(s)throw s.error}}return!1},r.isLegal=function(t,e,i){if(e){var n=e.map((function(t){return Number(t[0])})),s=Math.min.apply(Math,n),r=7===s&&e.every((function(t){return"7"!==t[0]||"7V"===t}))||8===s&&e.every((function(t){return"8"!==t[0]||"8V"===t}));if("Pentagon"===i)return n.includes(6);if("Plus"===i)return n.includes(7)&&!r;if("Galar"===i)return n.includes(8)&&!r;if(this.gen.num>=3&&s<=4&&(b.has(t.id)||w.has(t.id))){var o="",a=!1;3===s&&(o+="3",a=!0),a&&(a=!b.has(t.id)),(a||n.includes(4))&&(o+="4",a=!0),a&&(a=!w.has(t.id));var h=a?5:Math.min.apply(Math,n.filter((function(t){return t>4})));return(o+="012345678".slice(h)).includes(""+i.num)}return"012345678".slice(s).includes(""+i.num)}},s}(Symbol.iterator);t.Learnsets=k;var D=["hp","atk","def","spe","spa","spd"],_={HP:"hp",hp:"hp",Attack:"atk",Atk:"atk",atk:"atk",Defense:"def",Def:"def",def:"def","Special Attack":"spa",SpA:"spa",SAtk:"spa",SpAtk:"spa",spa:"spa",Special:"spa",spc:"spa",Spc:"spa","Special Defense":"spd",SpD:"spd",SDef:"spd",SpDef:"spd",spd:"spd",Speed:"spe",Spe:"spe",Spd:"spe",spe:"spe"},O={hp:["HP","HP"],atk:["Atk","Attack"],def:["Def","Defense"],spa:["SpA","Special Attack"],spd:["SpD","Special Defense"],spe:["Spe","Speed"],spc:["Spc","Special"]},P=function(t){function e(t){this.dex=t}var i=e.prototype;return i.calc=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:31,n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,o=arguments.length>5?arguments[5]:void 0;if(void 0===n&&(n=this.dex.gen<3?252:0),this.dex.gen<3&&(i=2*this.toDV(i),o=void 0),"hp"===t)return 1===e?e:s(s(2*e+i+s(n/4)+100)*r/100+10);var a=s(s(2*e+i+s(n/4))*r/100+5);if(void 0!==o){if(o.plus===t)return s(s(110*a,16)/100);if(o.minus===t)return s(s(90*a,16)/100)}return a},i.get=function(t){return _[t]},i.display=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=_[t];return void 0===i?t:(1===this.dex.gen&&"spa"===i&&(i="spc"),O[i][+e])},i.fill=function(t,e){for(var i=0;i<D.length;i++){var n=D[i];n in t||(t[n]=e)}return t},i.getHPDV=function(t){return this.toDV(void 0===t.atk?31:t.atk)%2*8+this.toDV(void 0===t.def?31:t.def)%2*4+this.toDV(void 0===t.spe?31:t.spe)%2*2+this.toDV(void 0===t.spa?31:t.spa)%2},i[t]=function*(){for(var t=0;t<D.length;t++){var e=D[t];yield e}},i.toDV=function(t){return Math.floor(t/2)},i.toIV=function(t){return 2*t+1},e}(Symbol.iterator);t.Stats=P,window.Generations=t.Generations}();
1
+ var _this=this;function _defineProperties(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}!function(){"use strict";var t={},e=_this&&_this.__await||function(t){return this instanceof e?(this.v=t,this):new e(t)},i=_this&&_this.__asyncGenerator||function(t,i,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s,r=n.apply(t,i||[]),o=[];return s={},a("next"),a("throw"),a("return"),s[Symbol.asyncIterator]=function(){return this},s;function a(t){r[t]&&(s[t]=function(e){return new Promise((function(i,n){o.push([t,e,i,n])>1||h(t,e)}))})}function h(t,i){try{(n=r[t](i)).value instanceof e?Promise.resolve(n.value.v).then(c,u):d(o[0][2],n)}catch(t){d(o[0][3],t)}var n}function c(t){h("next",t)}function u(t){h("throw",t)}function d(t,e){t(e),o.shift(),o.length&&h(o[0][0],o[0][1])}},n=_this&&_this.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(e){return new Promise((function(n,s){(function(t,e,i,n){Promise.resolve(n).then((function(e){t({value:e,done:i})}),e)})(n,s,(e=t[i](e)).done,e.value)}))}}};t.Stats=t.Learnsets=t.Type=t.Types=t.Natures=t.Conditions=t.Specie=t.Species=t.Moves=t.Items=t.Abilities=t.Generation=t.Generations=t.toID=void 0;var s=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e?(t>>>0)%2**e:t>>>0};function r(t,e,i){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&!i.has(n)&&(t[n]=e[n]);return t}function o(t){return(null==t?void 0:t.id)&&(t=t.id),"string"!=typeof t&&"number"!=typeof t?"":(""+t).toLowerCase().replace(/[^a-z0-9]+/g,"")}t.toID=o;var a=function(t){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.DEFAULT_EXISTS;this.cache=Object.create(null),this.dex=t,this.exists=i}var i=e.prototype;return i.get=function(t){var e=this;return this.cache[t]?this.cache[t]:this.cache[t]=new h(this.dex.forGen(t),(function(i){return e.exists(i,t)}))},i[t]=function*(){for(var t=1;t<=8;t++)yield this.get(t)},e}(Symbol.iterator);t.Generations=a,a.DEFAULT_EXISTS=function(t){return!!t.exists&&((!("isNonstandard"in t)||!t.isNonstandard)&&(("Ability"!==t.kind||"noability"!==t.id)&&!("tier"in t&&["Illegal","Unreleased"].includes(t.tier))))};var h=function(){function t(t,e){this.dex=t,this.exists=e,this.abilities=new c(this.dex,this.exists),this.items=new u(this.dex,this.exists),this.moves=new d(this.dex,this.exists),this.species=new f(this.dex,this.exists),this.natures=new p(this.dex,this.exists),this.types=new y(this.dex,this.exists),this.learnsets=new k(this,this.dex,this.exists),this.conditions=new v(this.dex,this.exists),this.stats=new P(this.dex)}var e=t.prototype;return e.toString=function(){return"[Generation:"+this.num+"]"},e.toJSON=function(){return this.toString()},_createClass(t,[{key:"num",get:function(){return this.dex.gen}}]),t}();t.Generation=h;var c=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.abilities.get(t);return this.exists(e)?e:void 0},i[t]=function*(){for(var t in this.dex.data.Abilities){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Abilities=c;var u=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.items.get(t);return this.exists(e)?e:void 0},i[t]=function*(){for(var t in this.dex.data.Items){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Items=u;var d=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.moves.get(t);return this.exists(e)?e:void 0},i[t]=function*(){for(var t in this.dex.data.Moves){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Moves=d;var f=function(t){function e(t,e){this.cache=Object.create(null),this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){var e=this.dex.species.get(t);if(this.exists(e)){var i=e.speciesid||e.id,n=this.cache[i];return n||(this.cache[i]=new l(this.dex,this.exists,e))}},i[t]=function*(){for(var t in this.dex.data.Species){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Species=f;var l=function(){function t(e,i,n){var s,o,a,h,c,u,d,f,l,v=this;r(this,n,t.EXCLUDE),this.dex=e,this.dex.gen>=2?(this.gender=n.gender,this.genderRatio=n.genderRatio):this.genderRatio={M:0,F:0},this.dex.gen>=3?(this.abilities={0:n.abilities[0]},n.abilities[1]&&this.dex.abilities.get(n.abilities[1]).gen<=this.dex.gen&&(this.abilities[1]=n.abilities[1]),this.dex.gen>=5&&n.abilities.H&&(this.abilities.H=n.abilities.H),this.dex.gen>=7&&n.abilities.S&&(this.abilities.S=n.abilities.S)):this.abilities={0:""},this.evos=null===(s=n.evos)||void 0===s?void 0:s.filter((function(t){return i(v.dex.species.get(t))})),this.nfe=!!(null===(o=this.evos)||void 0===o?void 0:o.length),this.nfe||(this.evos=void 0),this.cosmeticFormes=null===(a=n.cosmeticFormes)||void 0===a?void 0:a.filter((function(t){return i(v.dex.species.get(t))})),(null===(h=this.cosmeticFormes)||void 0===h?void 0:h.length)||(this.cosmeticFormes=void 0),this.otherFormes=null===(c=n.otherFormes)||void 0===c?void 0:c.filter((function(t){return i(v.dex.species.get(t))})),(null===(u=this.otherFormes)||void 0===u?void 0:u.length)||(this.otherFormes=void 0),this.formeOrder=null===(d=n.formeOrder)||void 0===d?void 0:d.filter((function(t){return i(v.dex.species.get(t))})),(null===(f=this.formeOrder)||void 0===f?void 0:f.length)||(this.formeOrder=void 0),this.formes=null===(l=this.formeOrder)||void 0===l?void 0:l.filter((function(t){return!v.dex.species.get(t).isGigantamax})),this.prevo=n.prevo&&i(this.dex.species.get(n.prevo))?n.prevo:void 0}var e=t.prototype;return e.toString=function(){return this.name},e.toJSON=function(){return r({},this,new Set(["dex"]))},_createClass(t,[{key:"formeNum",get:function(){var t=this;return this.baseSpecies===this.name?this.formeOrder?this.formeOrder.findIndex((function(e){return e===t.name})):0:this.dex.species.get(this.baseSpecies).formeOrder.findIndex((function(e){return e===(t.isGigantamax?t.baseSpecies:t.name)}))}}]),t}();t.Specie=l,l.EXCLUDE=new Set(["abilities","cosmeticFormes","evos","gender","genderRatio","nfe","otherFormes","prevo"]);var v=function(){function t(t,e){this.dex=t,this.exists=e}return t.prototype.get=function(t){var e=this.dex.conditions.get(t);return this.exists(e)?e:void 0},t}();t.Conditions=v;var p=function(t){function e(t,e){this.dex=t,this.exists=e}var i=e.prototype;return i.get=function(t){if(!(this.dex.gen<3)){var e=this.dex.natures.get(t);return this.exists(e)?e:void 0}},i[t]=function*(){for(var t in this.dex.data.Natures){var e=this.get(t);e&&(yield e)}},e}(Symbol.iterator);t.Natures=p;var g={"-2":.25,"-1":.5,0:1,1:2,2:4},y=function(t){function e(t,e){this.cache=Object.create(null),this.dex=t,this.exists=e,this.unknown=new S({effectType:"Type",kind:"Type",id:"",name:"???",exists:t.gen<=4,gen:1,damageTaken:{},HPivs:{},HPdvs:{}},t,this)}var i=e.prototype;return i.get=function(t){if("???"===t)return this.unknown;var e=this.dex.types.get(t);if(this.exists(e)){var i=this.cache[e.id];return i||(this.cache[e.id]=new S(e,this.dex,this))}},i[t]=function*(){for(var t in this.dex.data.Types){var e=this.get(t);e&&(yield e)}this.dex.gen>=2&&this.dex.gen<=4&&(yield this.unknown)},i.getHiddenPower=function(t){return this.dex.getHiddenPower(t)},i.canDamage=function(t,e){return this.dex.getImmunity(t,e)},i.totalEffectiveness=function(t,e){if(!this.canDamage(t,e))return 0;var i=""+this.dex.getEffectiveness(t,e);return g[i]},e}(Symbol.iterator);t.Types=y;var x=[1,2,.5,0],m=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],S=function(){function t(t,e,i){for(var n in Object.assign(this,t),this.types=i,this.category="Fairy"===this.name?void 0:m.includes(this.name)?"Special":"Physical",this.effectiveness={"???":1},e.data.Types){var s=n.charAt(0).toUpperCase()+n.slice(1);this.effectiveness[s]=x[e.data.Types[n].damageTaken[this.name]||0]}}var e=t.prototype;return e.canDamage=function(t){return this.types.canDamage(this.name,t)},e.totalEffectiveness=function(t){return this.types.totalEffectiveness(this.name,t)},e.toString=function(){return this.name},e.toJSON=function(){return r({},this,new Set(["types"]))},t}();t.Type=S;var b=new Set(["cut","fly","surf","strength","flash","rocksmash","waterfall","dive"]),w=new Set(["cut","fly","surf","strength","rocksmash","waterfall","rockclimb"]),k=function(t){function s(t,e,i){this.cache=Object.create(null),this.gen=t,this.dex=e,this.exists=i}var r=s.prototype;return r.get=async function(t){var e=await this.dex.learnsets.get(o(t));return this.exists(e)?e:void 0},r[t]=function(){return i(this,arguments,(function*(){for(var t in this.dex.data.Learnsets||(yield e(this.dex.learnsets.get("LOAD"))),this.dex.data.Learnsets){var i=yield e(this.get(t));i&&(yield yield e(i))}}))},r.all=function(t){return i(this,arguments,(function*(){var i=t.id,n=yield e(this.get(i));for(n||(i="string"==typeof t.battleOnly&&t.battleOnly!==t.baseSpecies?o(t.battleOnly):o(t.baseSpecies),n=yield e(this.get(i)));n&&(yield yield e(n),i="lycanrocdusk"===i||"rockruff"===t.id&&"rockruff"===i?"rockruffdusk":"gastrodoneast"===t.id?"gastrodon":"pumpkaboosuper"===t.id?"pumpkaboo":o(t.battleOnly||t.changesFrom||t.prevo));){var s=this.gen.species.get(i);if(!s)break;t=s,n=yield e(this.get(i))}}))},r.learnable=async function(t,e){var i,s,r=this,o=this.gen.species.get(t);if(o){if(!e){var a=this.cache[o.id];if(a)return a}var h={};try{for(var c,u=n(this.all(o));!(c=await u.next()).done;){var d=c.value;if(d.learnset)for(var f in d.learnset){var l=this.gen.moves.get(f);if(l){var v=d.learnset[f];this.isLegal(l,v,e||this.gen)&&(h[l.id]=v.filter((function(t){return+t.charAt(0)<=r.gen.num})))}}}}catch(t){i={error:t}}finally{try{c&&!c.done&&(s=u.return)&&await s.call(u)}finally{if(i)throw i.error}}return e||(this.cache[o.id]=h),h}},r.canLearn=async function(t,e,i){var s,r,o,a=this.gen.species.get(t);if(!a)return!1;if("string"==typeof(e="string"==typeof e&&this.gen.moves.get(e)||e))return!1;try{for(var h,c=n(this.all(a));!(h=await c.next()).done;){var u=h.value;if(this.isLegal(e,null===(o=u.learnset)||void 0===o?void 0:o[e.id],i||this.gen))return!0}}catch(t){s={error:t}}finally{try{h&&!h.done&&(r=c.return)&&await r.call(c)}finally{if(s)throw s.error}}return!1},r.isLegal=function(t,e,i){if(e){var n=e.map((function(t){return Number(t[0])})),s=Math.min.apply(Math,n),r=7===s&&e.every((function(t){return"7"!==t[0]||"7V"===t}))||8===s&&e.every((function(t){return"8"!==t[0]||"8V"===t}));if("Pentagon"===i)return n.includes(6);if("Plus"===i)return n.includes(7)&&!r;if("Galar"===i)return n.includes(8)&&!r;if(this.gen.num>=3&&s<=4&&(b.has(t.id)||w.has(t.id))){var o="",a=!1;3===s&&(o+="3",a=!0),a&&(a=!b.has(t.id)),(a||n.includes(4))&&(o+="4",a=!0),a&&(a=!w.has(t.id));var h=a?5:Math.min.apply(Math,n.filter((function(t){return t>4})));return(o+="012345678".slice(h)).includes(""+i.num)}return"012345678".slice(s).includes(""+i.num)}},s}(Symbol.iterator);t.Learnsets=k;var D=["hp","atk","def","spe","spa","spd"],O={HP:"hp",hp:"hp",Attack:"atk",Atk:"atk",atk:"atk",Defense:"def",Def:"def",def:"def","Special Attack":"spa",SpA:"spa",SAtk:"spa",SpAtk:"spa",spa:"spa",Special:"spa",spc:"spa",Spc:"spa","Special Defense":"spd",SpD:"spd",SDef:"spd",SpDef:"spd",spd:"spd",Speed:"spe",Spe:"spe",Spd:"spe",spe:"spe"},_={hp:["HP","HP"],atk:["Atk","Attack"],def:["Def","Defense"],spa:["SpA","Special Attack"],spd:["SpD","Special Defense"],spe:["Spe","Speed"],spc:["Spc","Special"]},P=function(t){function e(t){this.dex=t}var i=e.prototype;return i.calc=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:31,n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:100,o=arguments.length>5?arguments[5]:void 0;if(void 0===n&&(n=this.dex.gen<3?252:0),this.dex.gen<3&&(i=2*this.toDV(i),o=void 0),"hp"===t)return 1===e?e:s(s(2*e+i+s(n/4)+100)*r/100+10);var a=s(s(2*e+i+s(n/4))*r/100+5);if(void 0!==o){if(o.plus===t)return s(s(110*a,16)/100);if(o.minus===t)return s(s(90*a,16)/100)}return a},i.get=function(t){return O[t]},i.display=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=O[t];return void 0===i?t:(1===this.dex.gen&&"spa"===i&&(i="spc"),_[i][+e])},i.fill=function(t,e){for(var i=0;i<D.length;i++){var n=D[i];n in t||(t[n]=e)}return t},i.getHPDV=function(t){return this.toDV(void 0===t.atk?31:t.atk)%2*8+this.toDV(void 0===t.def?31:t.def)%2*4+this.toDV(void 0===t.spe?31:t.spe)%2*2+this.toDV(void 0===t.spa?31:t.spa)%2},i[t]=function*(){for(var t=0;t<D.length;t++){var e=D[t];yield e}},i.toDV=function(t){return Math.floor(t/2)},i.toIV=function(t){return 2*t+1},e}(Symbol.iterator);t.Stats=P,window.Generations=t.Generations}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pkmn/data",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "unpkg": "build/production.min.js",
@@ -16,12 +16,12 @@
16
16
  "index.ts"
17
17
  ],
18
18
  "dependencies": {
19
- "@pkmn/dex-types": "^0.5.2"
19
+ "@pkmn/dex-types": "^0.5.3"
20
20
  },
21
21
  "devDependencies": {
22
- "@pkmn/dex": "^0.5.2",
23
- "@pkmn/mods": "^0.5.2",
24
- "@pkmn/sim": "^0.5.2",
22
+ "@pkmn/dex": "^0.5.3",
23
+ "@pkmn/mods": "^0.5.3",
24
+ "@pkmn/sim": "^0.5.3",
25
25
  "@smogon/calc": "^0.6.0"
26
26
  },
27
27
  "scripts": {