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

@pkmn/data

Package Overview
Dependencies
Maintainers
0
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pkmn/data - npm Package Compare versions

Comparing version 0.9.8 to 0.9.9

3

build/index.js

@@ -295,3 +295,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts

const t = k.charAt(0).toUpperCase() + k.slice(1);
this.effectiveness[t] = DAMAGE_TAKEN[dex.data.Types[k].damageTaken[this.name] || 0];
const data = dex.data.Types[k];
this.effectiveness[t] = DAMAGE_TAKEN[data.damageTaken[this.name] || 0];
}

@@ -298,0 +299,0 @@ }

@@ -1,1 +0,1 @@

window.pkmn=window.pkmn||{};window.pkmn.data=(()=>{var F=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var R=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of C(e))!L.call(n,i)&&i!==t&&F(n,i,{get:()=>e[i],enumerable:!(s=H(e,i))||s.enumerable});return n};var U=n=>V(F({},"__esModule",{value:!0}),n);var W={};R(W,{Abilities:()=>m,Conditions:()=>D,Generation:()=>p,Generations:()=>u,Items:()=>x,Learnsets:()=>E,Moves:()=>g,Natures:()=>T,Specie:()=>b,Species:()=>S,Stats:()=>v,Type:()=>f,Types:()=>N,toID:()=>y});var M=n=>!n.exists||"isNonstandard"in n&&n.isNonstandard||n.kind==="Ability"&&n.id==="noability"?!1:!("tier"in n&&["Illegal","Unreleased"].includes(n.tier)),l=(n,e=0)=>e?(n>>>0)%2**e:n>>>0;function I(n,e,t){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&!t.has(s)&&(n[s]=e[s]);return n}function y(n){return n?.id&&(n=n.id),typeof n!="string"&&typeof n!="number"?"":(""+n).toLowerCase().replace(/[^a-z0-9]+/g,"")}var u=class n{constructor(e,t=n.DEFAULT_EXISTS){this.cache=Object.create(null);this.dex=e,this.exists=t}static{this.DEFAULT_EXISTS=M}get(e){let t=typeof e=="string"?parseInt(e.slice(e.search(/\d/))):e;if(isNaN(+t))throw new Error(`Invalid gen ${e}`);return this.cache[t]?this.cache[t]:this.cache[t]=new p(this.dex.forGen(t),s=>this.exists(s,t))}*[Symbol.iterator](){for(let e=1;e<=9;e++)yield this.get(e)}},p=class{static get(e,t,s=M){return new u(e,s).get(t)}constructor(e,t){this.dex=e,this.exists=t,this.abilities=new m(this.dex,this.exists),this.items=new x(this.dex,this.exists),this.moves=new g(this.dex,this.exists),this.species=new S(this.dex,this.exists),this.natures=new T(this.dex,this.exists),this.types=new N(this.dex,this.exists),this.learnsets=new E(this,this.dex,this.exists),this.conditions=new D(this.dex,this.exists),this.stats=new v(this.dex)}get num(){return this.dex.gen}toString(){return`[Generation:${this.num}]`}toJSON(){return this.toString()}},m=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.abilities.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Abilities){let t=this.get(e);t&&(yield t)}}},x=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.items.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Items){let t=this.get(e);t&&(yield t)}}},g=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.moves.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Moves){let t=this.get(e);t&&(yield t)}}},S=class{constructor(e,t){this.cache=Object.create(null);this.dex=e,this.exists=t}get(e){let t=this.dex.species.get(e);if(!this.exists(t))return;let s=t.speciesid||t.id,i=this.cache[s];return i||(this.cache[s]=new b(this.dex,this.exists,t))}*[Symbol.iterator](){for(let e in this.dex.data.Species){let t=this.get(e);t&&(yield t)}}},b=class n{static{this.EXCLUDE=new Set(["abilities","cosmeticFormes","evos","formeOrder","gender","genderRatio","nfe","otherFormes","prevo"])}constructor(e,t,s){I(this,s,n.EXCLUDE),this.dex=e,this.dex.gen>=2?(this.gender=s.gender,this.genderRatio=s.genderRatio):this.genderRatio={M:0,F:0},this.dex.gen>=3?(this.abilities={0:s.abilities[0]},s.abilities[1]&&this.dex.abilities.get(s.abilities[1]).gen<=this.dex.gen&&(this.abilities[1]=s.abilities[1]),this.dex.gen>=5&&s.abilities.H&&(this.abilities.H=s.abilities.H),this.dex.gen>=7&&s.abilities.S&&(this.abilities.S=s.abilities.S)):this.abilities={0:""},this.evos=s.evos?.filter(i=>t(this.dex.species.get(i))),this.nfe=!!this.evos?.length,this.nfe||(this.evos=void 0),this.cosmeticFormes=s.cosmeticFormes?.filter(i=>t(this.dex.species.get(i))),this.cosmeticFormes?.length||(this.cosmeticFormes=void 0),this.otherFormes=s.otherFormes?.filter(i=>t(this.dex.species.get(i))),this.otherFormes?.length||(this.otherFormes=void 0),this.formeOrder=s.formeOrder?.filter(i=>t(this.dex.species.get(i))),(!this.formeOrder||this.formeOrder.length<=1)&&(this.formeOrder=void 0),this.formes=this.formeOrder?.filter(i=>this.dex.species.get(i).isNonstandard!=="Gigantamax"),this.prevo=s.prevo&&t(this.dex.species.get(s.prevo))?s.prevo:void 0}get formeNum(){return this.baseSpecies===this.name?this.formeOrder?this.formeOrder.findIndex(e=>e===this.name):0:this.dex.species.get(this.baseSpecies).formeOrder.findIndex(e=>e===(this.isNonstandard==="Gigantamax"?this.baseSpecies:this.name))}toString(){return this.name}toJSON(){return I({},this,new Set(["dex"]))}},D=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.conditions.get(e);return this.exists(t)?t:void 0}},T=class{constructor(e,t){this.dex=e,this.exists=t}get(e){if(this.dex.gen<3)return;let t=this.dex.natures.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Natures){let t=this.get(e);t&&(yield t)}}},j={"-3":.125,"-2":.25,"-1":.5,0:1,1:2,2:4,3:8},N=class{constructor(e,t){this.cache=Object.create(null);this.dex=e,this.exists=t,this.unknown=new f({effectType:"Type",kind:"Type",id:"",name:"???",exists:e.gen<=4,gen:1,damageTaken:{},HPivs:{},HPdvs:{}},e,this)}get(e){if(e==="???")return this.unknown;let t=this.dex.types.get(e);if(!this.exists(t))return;let s=this.cache[t.id];return s||(this.cache[t.id]=new f(t,this.dex,this))}*[Symbol.iterator](){for(let e in this.dex.data.Types){let t=this.get(e);t&&(yield t)}this.dex.gen>=2&&this.dex.gen<=4&&(yield this.unknown)}getHiddenPower(e){return this.dex.getHiddenPower(e)}canDamage(e,t){return this.dex.getImmunity(e,t)}totalEffectiveness(e,t){if(!this.canDamage(e,t))return 0;let s=`${this.dex.getEffectiveness(e,t)}`;return j[s]}},q=[1,2,.5,0],X=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],f=class{constructor(e,t,s){Object.assign(this,e),this.types=s,this.category=this.name==="Fairy"?void 0:X.includes(this.name)?"Special":"Physical",this.effectiveness={"???":1};for(let i in t.data.Types){let r=i.charAt(0).toUpperCase()+i.slice(1);this.effectiveness[r]=q[t.data.Types[i].damageTaken[this.name]||0]}}canDamage(e){return this.types.canDamage(this.name,e)}totalEffectiveness(e){return this.types.totalEffectiveness(this.name,e)}toString(){return this.name}toJSON(){return I({},this,new Set(["types"]))}},w=new Set(["cut","fly","surf","strength","flash","rocksmash","waterfall","dive"]),A=new Set(["cut","fly","surf","strength","rocksmash","waterfall","rockclimb"]),E=class{constructor(e,t,s){this.cache=Object.create(null);this.gen=e,this.dex=t,this.exists=s}async get(e){let t=await this.dex.learnsets.get(y(e));return this.exists(t)?t:void 0}async*[Symbol.iterator](){this.dex.data.Learnsets||await this.dex.learnsets.get("LOAD");for(let e in this.dex.data.Learnsets){let t=await this.get(e);t&&(yield t)}}async*all(e){let t=e.id,s=await this.get(t);for(s||(t=typeof e.battleOnly=="string"&&e.battleOnly!==e.baseSpecies?y(e.battleOnly):y(e.baseSpecies),s=await this.get(t));s&&(yield s,t==="lycanrocdusk"||e.id==="rockruff"&&t==="rockruff"?t="rockruffdusk":e.id==="gastrodoneast"?t="gastrodon":e.id==="pumpkaboosuper"?t="pumpkaboo":t=y(e.battleOnly||e.changesFrom||e.prevo),!!t);){let i=this.gen.species.get(t);if(!i)break;e=i,s=await this.get(t)}}async learnable(e,t){let s=this.gen.species.get(e);if(!s)return;if(!t){let r=this.cache[s.id];if(r)return r}let i={};for await(let r of this.all(s))if(r.learnset)for(let d in r.learnset){let a=this.gen.moves.get(d);if(a){let o=r.learnset[d];if(this.isLegal(a,o,t||this.gen)){let h=o.filter(c=>+c.charAt(0)<=this.gen.num);if(!h.length)continue;if(i[a.id]){let c=[];e:for(let k of h){let O=k.slice(0,2);for(let B of i[a.id])if(B.startsWith(O))continue e;c.push(k)}i[a.id].push(...c)}else i[a.id]=h}}}return t||(this.cache[s.id]=i),i}async canLearn(e,t,s){let i=this.gen.species.get(e);if(!i||(t=typeof t=="string"&&this.gen.moves.get(t)||t,typeof t=="string"))return!1;for await(let r of this.all(i))if(this.isLegal(t,r.learnset?.[t.id],s||this.gen))return!0;return!1}isLegal(e,t,s){if(!t)return;let i=t.map(a=>Number(a[0])),r=Math.min(...i),d=r===7&&t.every(a=>a[0]!=="7"||a==="7V")||r===8&&t.every(a=>a[0]!=="8"||a==="8V");if(s==="Pentagon")return i.includes(6);if(s==="Plus")return i.includes(7)&&!d;if(s==="Galar")return i.includes(8)&&!d;if(s==="Paldea")return i.includes(9);if(this.gen.num>=3&&r<=4&&(w.has(e.id)||A.has(e.id))){let a="",o=!1;r===3&&(a+="3",o=!0),o&&(o=!w.has(e.id)),(o||i.includes(4))&&(a+="4",o=!0),o&&(o=!A.has(e.id));let h=o?5:Math.min(...i.filter(c=>c>4));return a+="0123456789".slice(h),a.includes(`${s.num}`)}else return"0123456789".slice(r).includes(`${s.num}`)}},P=["hp","atk","def","spe","spa","spd"],G={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"]},v=class{constructor(e){this.dex=e}calc(e,t,s=31,i,r=100,d){if(i===void 0&&(i=this.dex.gen<3?252:0),this.dex.gen<3&&(s=this.toDV(s)*2,d=void 0),e==="hp")return t===1?t:l(l(2*t+s+l(i/4)+100)*r/100+10);{let a=l(l(2*t+s+l(i/4))*r/100+5);if(d!==void 0){if(d.plus===e)return l(l(a*110,16)/100);if(d.minus===e)return l(l(a*90,16)/100)}return a}}get(e){return G[e]}display(e,t=!1){let s=G[e];return s===void 0?e:(this.dex.gen===1&&s==="spa"&&(s="spc"),$[s][+t])}fill(e,t){for(let s of P)s in e||(e[s]=t);return e}getHPDV(e){return this.toDV(e.atk===void 0?31:e.atk)%2*8+this.toDV(e.def===void 0?31:e.def)%2*4+this.toDV(e.spe===void 0?31:e.spe)%2*2+this.toDV(e.spa===void 0?31:e.spa)%2}*[Symbol.iterator](){for(let e of P)yield e}toDV(e){return Math.floor(e/2)}toIV(e){return e*2+1}};return U(W);})();
window.pkmn=window.pkmn||{};window.pkmn.data=(()=>{var F=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var R=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},V=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!C.call(n,i)&&i!==t&&F(n,i,{get:()=>e[i],enumerable:!(s=H(e,i))||s.enumerable});return n};var U=n=>V(F({},"__esModule",{value:!0}),n);var W={};R(W,{Abilities:()=>m,Conditions:()=>D,Generation:()=>p,Generations:()=>u,Items:()=>x,Learnsets:()=>E,Moves:()=>g,Natures:()=>T,Specie:()=>b,Species:()=>S,Stats:()=>v,Type:()=>f,Types:()=>N,toID:()=>y});var M=n=>!n.exists||"isNonstandard"in n&&n.isNonstandard||n.kind==="Ability"&&n.id==="noability"?!1:!("tier"in n&&["Illegal","Unreleased"].includes(n.tier)),l=(n,e=0)=>e?(n>>>0)%2**e:n>>>0;function I(n,e,t){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&!t.has(s)&&(n[s]=e[s]);return n}function y(n){return n?.id&&(n=n.id),typeof n!="string"&&typeof n!="number"?"":(""+n).toLowerCase().replace(/[^a-z0-9]+/g,"")}var u=class n{constructor(e,t=n.DEFAULT_EXISTS){this.cache=Object.create(null);this.dex=e,this.exists=t}static{this.DEFAULT_EXISTS=M}get(e){let t=typeof e=="string"?parseInt(e.slice(e.search(/\d/))):e;if(isNaN(+t))throw new Error(`Invalid gen ${e}`);return this.cache[t]?this.cache[t]:this.cache[t]=new p(this.dex.forGen(t),s=>this.exists(s,t))}*[Symbol.iterator](){for(let e=1;e<=9;e++)yield this.get(e)}},p=class{static get(e,t,s=M){return new u(e,s).get(t)}constructor(e,t){this.dex=e,this.exists=t,this.abilities=new m(this.dex,this.exists),this.items=new x(this.dex,this.exists),this.moves=new g(this.dex,this.exists),this.species=new S(this.dex,this.exists),this.natures=new T(this.dex,this.exists),this.types=new N(this.dex,this.exists),this.learnsets=new E(this,this.dex,this.exists),this.conditions=new D(this.dex,this.exists),this.stats=new v(this.dex)}get num(){return this.dex.gen}toString(){return`[Generation:${this.num}]`}toJSON(){return this.toString()}},m=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.abilities.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Abilities){let t=this.get(e);t&&(yield t)}}},x=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.items.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Items){let t=this.get(e);t&&(yield t)}}},g=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.moves.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Moves){let t=this.get(e);t&&(yield t)}}},S=class{constructor(e,t){this.cache=Object.create(null);this.dex=e,this.exists=t}get(e){let t=this.dex.species.get(e);if(!this.exists(t))return;let s=t.speciesid||t.id,i=this.cache[s];return i||(this.cache[s]=new b(this.dex,this.exists,t))}*[Symbol.iterator](){for(let e in this.dex.data.Species){let t=this.get(e);t&&(yield t)}}},b=class n{static{this.EXCLUDE=new Set(["abilities","cosmeticFormes","evos","formeOrder","gender","genderRatio","nfe","otherFormes","prevo"])}constructor(e,t,s){I(this,s,n.EXCLUDE),this.dex=e,this.dex.gen>=2?(this.gender=s.gender,this.genderRatio=s.genderRatio):this.genderRatio={M:0,F:0},this.dex.gen>=3?(this.abilities={0:s.abilities[0]},s.abilities[1]&&this.dex.abilities.get(s.abilities[1]).gen<=this.dex.gen&&(this.abilities[1]=s.abilities[1]),this.dex.gen>=5&&s.abilities.H&&(this.abilities.H=s.abilities.H),this.dex.gen>=7&&s.abilities.S&&(this.abilities.S=s.abilities.S)):this.abilities={0:""},this.evos=s.evos?.filter(i=>t(this.dex.species.get(i))),this.nfe=!!this.evos?.length,this.nfe||(this.evos=void 0),this.cosmeticFormes=s.cosmeticFormes?.filter(i=>t(this.dex.species.get(i))),this.cosmeticFormes?.length||(this.cosmeticFormes=void 0),this.otherFormes=s.otherFormes?.filter(i=>t(this.dex.species.get(i))),this.otherFormes?.length||(this.otherFormes=void 0),this.formeOrder=s.formeOrder?.filter(i=>t(this.dex.species.get(i))),(!this.formeOrder||this.formeOrder.length<=1)&&(this.formeOrder=void 0),this.formes=this.formeOrder?.filter(i=>this.dex.species.get(i).isNonstandard!=="Gigantamax"),this.prevo=s.prevo&&t(this.dex.species.get(s.prevo))?s.prevo:void 0}get formeNum(){return this.baseSpecies===this.name?this.formeOrder?this.formeOrder.findIndex(e=>e===this.name):0:this.dex.species.get(this.baseSpecies).formeOrder.findIndex(e=>e===(this.isNonstandard==="Gigantamax"?this.baseSpecies:this.name))}toString(){return this.name}toJSON(){return I({},this,new Set(["dex"]))}},D=class{constructor(e,t){this.dex=e,this.exists=t}get(e){let t=this.dex.conditions.get(e);return this.exists(t)?t:void 0}},T=class{constructor(e,t){this.dex=e,this.exists=t}get(e){if(this.dex.gen<3)return;let t=this.dex.natures.get(e);return this.exists(t)?t:void 0}*[Symbol.iterator](){for(let e in this.dex.data.Natures){let t=this.get(e);t&&(yield t)}}},j={"-3":.125,"-2":.25,"-1":.5,0:1,1:2,2:4,3:8},N=class{constructor(e,t){this.cache=Object.create(null);this.dex=e,this.exists=t,this.unknown=new f({effectType:"Type",kind:"Type",id:"",name:"???",exists:e.gen<=4,gen:1,damageTaken:{},HPivs:{},HPdvs:{}},e,this)}get(e){if(e==="???")return this.unknown;let t=this.dex.types.get(e);if(!this.exists(t))return;let s=this.cache[t.id];return s||(this.cache[t.id]=new f(t,this.dex,this))}*[Symbol.iterator](){for(let e in this.dex.data.Types){let t=this.get(e);t&&(yield t)}this.dex.gen>=2&&this.dex.gen<=4&&(yield this.unknown)}getHiddenPower(e){return this.dex.getHiddenPower(e)}canDamage(e,t){return this.dex.getImmunity(e,t)}totalEffectiveness(e,t){if(!this.canDamage(e,t))return 0;let s=`${this.dex.getEffectiveness(e,t)}`;return j[s]}},q=[1,2,.5,0],X=["Fire","Water","Grass","Electric","Ice","Psychic","Dark","Dragon"],f=class{constructor(e,t,s){Object.assign(this,e),this.types=s,this.category=this.name==="Fairy"?void 0:X.includes(this.name)?"Special":"Physical",this.effectiveness={"???":1};for(let i in t.data.Types){let r=i.charAt(0).toUpperCase()+i.slice(1),o=t.data.Types[i];this.effectiveness[r]=q[o.damageTaken[this.name]||0]}}canDamage(e){return this.types.canDamage(this.name,e)}totalEffectiveness(e){return this.types.totalEffectiveness(this.name,e)}toString(){return this.name}toJSON(){return I({},this,new Set(["types"]))}},w=new Set(["cut","fly","surf","strength","flash","rocksmash","waterfall","dive"]),A=new Set(["cut","fly","surf","strength","rocksmash","waterfall","rockclimb"]),E=class{constructor(e,t,s){this.cache=Object.create(null);this.gen=e,this.dex=t,this.exists=s}async get(e){let t=await this.dex.learnsets.get(y(e));return this.exists(t)?t:void 0}async*[Symbol.iterator](){this.dex.data.Learnsets||await this.dex.learnsets.get("LOAD");for(let e in this.dex.data.Learnsets){let t=await this.get(e);t&&(yield t)}}async*all(e){let t=e.id,s=await this.get(t);for(s||(t=typeof e.battleOnly=="string"&&e.battleOnly!==e.baseSpecies?y(e.battleOnly):y(e.baseSpecies),s=await this.get(t));s&&(yield s,t==="lycanrocdusk"||e.id==="rockruff"&&t==="rockruff"?t="rockruffdusk":e.id==="gastrodoneast"?t="gastrodon":e.id==="pumpkaboosuper"?t="pumpkaboo":t=y(e.battleOnly||e.changesFrom||e.prevo),!!t);){let i=this.gen.species.get(t);if(!i)break;e=i,s=await this.get(t)}}async learnable(e,t){let s=this.gen.species.get(e);if(!s)return;if(!t){let r=this.cache[s.id];if(r)return r}let i={};for await(let r of this.all(s))if(r.learnset)for(let o in r.learnset){let a=this.gen.moves.get(o);if(a){let d=r.learnset[o];if(this.isLegal(a,d,t||this.gen)){let h=d.filter(c=>+c.charAt(0)<=this.gen.num);if(!h.length)continue;if(i[a.id]){let c=[];e:for(let k of h){let O=k.slice(0,2);for(let B of i[a.id])if(B.startsWith(O))continue e;c.push(k)}i[a.id].push(...c)}else i[a.id]=h}}}return t||(this.cache[s.id]=i),i}async canLearn(e,t,s){let i=this.gen.species.get(e);if(!i||(t=typeof t=="string"&&this.gen.moves.get(t)||t,typeof t=="string"))return!1;for await(let r of this.all(i))if(this.isLegal(t,r.learnset?.[t.id],s||this.gen))return!0;return!1}isLegal(e,t,s){if(!t)return;let i=t.map(a=>Number(a[0])),r=Math.min(...i),o=r===7&&t.every(a=>a[0]!=="7"||a==="7V")||r===8&&t.every(a=>a[0]!=="8"||a==="8V");if(s==="Pentagon")return i.includes(6);if(s==="Plus")return i.includes(7)&&!o;if(s==="Galar")return i.includes(8)&&!o;if(s==="Paldea")return i.includes(9);if(this.gen.num>=3&&r<=4&&(w.has(e.id)||A.has(e.id))){let a="",d=!1;r===3&&(a+="3",d=!0),d&&(d=!w.has(e.id)),(d||i.includes(4))&&(a+="4",d=!0),d&&(d=!A.has(e.id));let h=d?5:Math.min(...i.filter(c=>c>4));return a+="0123456789".slice(h),a.includes(`${s.num}`)}else return"0123456789".slice(r).includes(`${s.num}`)}},P=["hp","atk","def","spe","spa","spd"],G={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"]},v=class{constructor(e){this.dex=e}calc(e,t,s=31,i,r=100,o){if(i===void 0&&(i=this.dex.gen<3?252:0),this.dex.gen<3&&(s=this.toDV(s)*2,o=void 0),e==="hp")return t===1?t:l(l(2*t+s+l(i/4)+100)*r/100+10);{let a=l(l(2*t+s+l(i/4))*r/100+5);if(o!==void 0){if(o.plus===e)return l(l(a*110,16)/100);if(o.minus===e)return l(l(a*90,16)/100)}return a}}get(e){return G[e]}display(e,t=!1){let s=G[e];return s===void 0?e:(this.dex.gen===1&&s==="spa"&&(s="spc"),$[s][+t])}fill(e,t){for(let s of P)s in e||(e[s]=t);return e}getHPDV(e){return this.toDV(e.atk===void 0?31:e.atk)%2*8+this.toDV(e.def===void 0?31:e.def)%2*4+this.toDV(e.spe===void 0?31:e.spe)%2*2+this.toDV(e.spa===void 0?31:e.spa)%2}*[Symbol.iterator](){for(let e of P)yield e}toDV(e){return Math.floor(e/2)}toIV(e){return e*2+1}};return U(W);})();
{
"name": "@pkmn/data",
"version": "0.9.8",
"version": "0.9.9",
"description": "A forked implementation of the Pokémon Showdown client's data layer",

@@ -19,8 +19,8 @@ "repository": "github:pkmn/ps",

"dependencies": {
"@pkmn/dex-types": "^0.9.8"
"@pkmn/dex-types": "^0.9.9"
},
"devDependencies": {
"@pkmn/dex": "^0.9.8",
"@pkmn/mods": "^0.9.8",
"@pkmn/sim": "^0.9.8",
"@pkmn/dex": "^0.9.9",
"@pkmn/mods": "^0.9.9",
"@pkmn/sim": "^0.9.9",
"@smogon/calc": "^0.10.0"

@@ -27,0 +27,0 @@ },

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