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.7 to 0.9.8

2

build/index.d.ts

@@ -203,3 +203,3 @@ import * as _pkmn_dex_types from '@pkmn/dex-types';

[speciesid: string]: {
[moveid: string]: string[];
[moveid: string]: MoveSource[];
};

@@ -206,0 +206,0 @@ };

"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
var DEFAULT_EXISTS = (d) => {
if (!d.exists)
return false;
if ("isNonstandard" in d && d.isNonstandard)
return false;
if (d.kind === "Ability" && d.id === "noability")
return false;
if (!d.exists) return false;
if ("isNonstandard" in d && d.isNonstandard) return false;
if (d.kind === "Ability" && d.id === "noability") return false;
return !("tier" in d && ["Illegal", "Unreleased"].includes(d.tier));

@@ -21,6 +18,4 @@ };

function toID(text) {
if (text == null ? void 0 : text.id)
text = text.id;
if (typeof text !== "string" && typeof text !== "number")
return "";
if (text == null ? void 0 : text.id) text = text.id;
if (typeof text !== "string" && typeof text !== "number") return "";
return ("" + text).toLowerCase().replace(/[^a-z0-9]+/g, "");

@@ -37,6 +32,4 @@ }

const gen = typeof g === "string" ? parseInt(g.slice(g.search(/\d/))) : g;
if (isNaN(+gen))
throw new Error(`Invalid gen ${g}`);
if (this.cache[gen])
return this.cache[gen];
if (isNaN(+gen)) throw new Error(`Invalid gen ${g}`);
if (this.cache[gen]) return this.cache[gen];
return this.cache[gen] = new Generation(this.dex.forGen(gen), (d) => this.exists(d, gen));

@@ -91,4 +84,3 @@ }

const a = this.get(ability);
if (a)
yield a;
if (a) yield a;
}

@@ -109,4 +101,3 @@ }

const i = this.get(item);
if (i)
yield i;
if (i) yield i;
}

@@ -127,4 +118,3 @@ }

const m = this.get(move);
if (m)
yield m;
if (m) yield m;
}

@@ -142,8 +132,6 @@ }

const species = this.dex.species.get(name);
if (!this.exists(species))
return void 0;
if (!this.exists(species)) return void 0;
const id = species.speciesid || species.id;
const cached = this.cache[id];
if (cached)
return cached;
if (cached) return cached;
return this.cache[id] = new Specie(this.dex, this.exists, species);

@@ -154,4 +142,3 @@ }

const s = this.get(species);
if (s)
yield s;
if (s) yield s;
}

@@ -176,6 +163,4 @@ }

}
if (this.dex.gen >= 5 && species.abilities.H)
this.abilities.H = species.abilities.H;
if (this.dex.gen >= 7 && species.abilities.S)
this.abilities.S = species.abilities.S;
if (this.dex.gen >= 5 && species.abilities.H) this.abilities.H = species.abilities.H;
if (this.dex.gen >= 7 && species.abilities.S) this.abilities.S = species.abilities.S;
} else {

@@ -186,13 +171,9 @@ this.abilities = { 0: "" };

this.nfe = !!((_b = this.evos) == null ? void 0 : _b.length);
if (!this.nfe)
this.evos = void 0;
if (!this.nfe) this.evos = void 0;
this.cosmeticFormes = (_c = species.cosmeticFormes) == null ? void 0 : _c.filter((s) => exists(this.dex.species.get(s)));
if (!((_d = this.cosmeticFormes) == null ? void 0 : _d.length))
this.cosmeticFormes = void 0;
if (!((_d = this.cosmeticFormes) == null ? void 0 : _d.length)) this.cosmeticFormes = void 0;
this.otherFormes = (_e = species.otherFormes) == null ? void 0 : _e.filter((s) => exists(this.dex.species.get(s)));
if (!((_f = this.otherFormes) == null ? void 0 : _f.length))
this.otherFormes = void 0;
if (!((_f = this.otherFormes) == null ? void 0 : _f.length)) this.otherFormes = void 0;
this.formeOrder = (_g = species.formeOrder) == null ? void 0 : _g.filter((s) => exists(this.dex.species.get(s)));
if (!this.formeOrder || this.formeOrder.length <= 1)
this.formeOrder = void 0;
if (!this.formeOrder || this.formeOrder.length <= 1) this.formeOrder = void 0;
this.formes = (_h = this.formeOrder) == null ? void 0 : _h.filter((s) => this.dex.species.get(s).isNonstandard !== "Gigantamax");

@@ -242,4 +223,3 @@ this.prevo = species.prevo && exists(this.dex.species.get(species.prevo)) ? species.prevo : void 0;

get(name) {
if (this.dex.gen < 3)
return void 0;
if (this.dex.gen < 3) return void 0;
const nature = this.dex.natures.get(name);

@@ -251,4 +231,3 @@ return this.exists(nature) ? nature : void 0;

const n = this.get(nature);
if (n)
yield n;
if (n) yield n;
}

@@ -289,10 +268,7 @@ }

get(name) {
if (name === "???")
return this.unknown;
if (name === "???") return this.unknown;
const type = this.dex.types.get(name);
if (!this.exists(type))
return void 0;
if (!this.exists(type)) return void 0;
const cached = this.cache[type.id];
if (cached)
return cached;
if (cached) return cached;
return this.cache[type.id] = new Type(type, this.dex, this);

@@ -303,4 +279,3 @@ }

const t = this.get(type);
if (t)
yield t;
if (t) yield t;
}

@@ -318,4 +293,3 @@ if (this.dex.gen >= 2 && this.dex.gen <= 4) {

totalEffectiveness(source, target) {
if (!this.canDamage(source, target))
return 0;
if (!this.canDamage(source, target)) return 0;
const e = `${this.dex.getEffectiveness(source, target)}`;

@@ -366,8 +340,6 @@ return EFFECTIVENESS[e];

async *[Symbol.iterator]() {
if (!this.dex.data.Learnsets)
await this.dex.learnsets.get("LOAD");
if (!this.dex.data.Learnsets) await this.dex.learnsets.get("LOAD");
for (const id in this.dex.data.Learnsets) {
const l = await this.get(id);
if (l)
yield l;
if (l) yield l;
}

@@ -393,7 +365,5 @@ }

}
if (!id)
break;
if (!id) break;
const s = this.gen.species.get(id);
if (!s)
break;
if (!s) break;
species = s;

@@ -407,8 +377,6 @@ learnset = await this.get(id);

const species = this.gen.species.get(name);
if (!species)
return void 0;
if (!species) return void 0;
if (!restriction) {
const cached = this.cache[species.id];
if (cached)
return cached;
if (cached) return cached;
}

@@ -424,14 +392,10 @@ const moves = {};

const filtered = sources.filter((s) => +s.charAt(0) <= this.gen.num);
if (!filtered.length)
continue;
if (!filtered.length) continue;
if (moves[move.id]) {
const unique = [];
loop:
for (const source of filtered) {
const prefix = source.slice(0, 2);
for (const s of moves[move.id])
if (s.startsWith(prefix))
continue loop;
unique.push(source);
}
loop: for (const source of filtered) {
const prefix = source.slice(0, 2);
for (const s of moves[move.id]) if (s.startsWith(prefix)) continue loop;
unique.push(source);
}
moves[move.id].push(...unique);

@@ -446,4 +410,3 @@ } else {

}
if (!restriction)
this.cache[species.id] = moves;
if (!restriction) this.cache[species.id] = moves;
return moves;

@@ -456,7 +419,5 @@ }

const species = this.gen.species.get(name);
if (!species)
return false;
if (!species) return false;
move = typeof move === "string" && this.gen.moves.get(move) || move;
if (typeof move === "string")
return false;
if (typeof move === "string") return false;
for await (const learnset of this.all(species)) {

@@ -472,15 +433,10 @@ if (this.isLegal(move, (_a = learnset.learnset) == null ? void 0 : _a[move.id], restriction || this.gen)) {

isLegal(move, sources, gen) {
if (!sources)
return void 0;
if (!sources) return void 0;
const gens = sources.map((x) => Number(x[0]));
const minGen = Math.min(...gens);
const vcOnly = minGen === 7 && sources.every((x) => x[0] !== "7" || x === "7V") || minGen === 8 && sources.every((x) => x[0] !== "8" || x === "8V");
if (gen === "Pentagon")
return gens.includes(6);
if (gen === "Plus")
return gens.includes(7) && !vcOnly;
if (gen === "Galar")
return gens.includes(8) && !vcOnly;
if (gen === "Paldea")
return gens.includes(9);
if (gen === "Pentagon") return gens.includes(6);
if (gen === "Plus") return gens.includes(7) && !vcOnly;
if (gen === "Galar") return gens.includes(8) && !vcOnly;
if (gen === "Paldea") return gens.includes(9);
if (this.gen.num >= 3 && minGen <= 4 && (GEN3_HMS.has(move.id) || GEN4_HMS.has(move.id))) {

@@ -493,4 +449,3 @@ let legalGens = "";

}
if (available)
available = !GEN3_HMS.has(move.id);
if (available) available = !GEN3_HMS.has(move.id);
if (available || gens.includes(4)) {

@@ -500,4 +455,3 @@ legalGens += "4";

}
if (available)
available = !GEN4_HMS.has(move.id);
if (available) available = !GEN4_HMS.has(move.id);
const minUpperGen = available ? 5 : Math.min(...gens.filter((g) => g > 4));

@@ -553,4 +507,3 @@ legalGens += "0123456789".slice(minUpperGen);

calc(stat, base, iv = 31, ev, level = 100, nature) {
if (ev === void 0)
ev = this.dex.gen < 3 ? 252 : 0;
if (ev === void 0) ev = this.dex.gen < 3 ? 252 : 0;
if (this.dex.gen < 3) {

@@ -565,6 +518,4 @@ iv = this.toDV(iv) * 2;

if (nature !== void 0) {
if (nature.plus === stat)
return tr(tr(val * 110, 16) / 100);
if (nature.minus === stat)
return tr(tr(val * 90, 16) / 100);
if (nature.plus === stat) return tr(tr(val * 110, 16) / 100);
if (nature.minus === stat) return tr(tr(val * 90, 16) / 100);
}

@@ -579,6 +530,4 @@ return val;

let s = NAMES[str];
if (s === void 0)
return str;
if (this.dex.gen === 1 && s === "spa")
s = "spc";
if (s === void 0) return str;
if (this.dex.gen === 1 && s === "spa") s = "spc";
return DISPLAY[s][+full];

@@ -588,4 +537,3 @@ }

for (const stat of STATS) {
if (!(stat in stats))
stats[stat] = val;
if (!(stat in stats)) stats[stat] = val;
}

@@ -592,0 +540,0 @@ return stats;

{
"name": "@pkmn/data",
"version": "0.9.7",
"version": "0.9.8",
"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.7"
"@pkmn/dex-types": "^0.9.8"
},
"devDependencies": {
"@pkmn/dex": "^0.9.7",
"@pkmn/mods": "^0.9.7",
"@pkmn/sim": "^0.9.7",
"@pkmn/dex": "^0.9.8",
"@pkmn/mods": "^0.9.8",
"@pkmn/sim": "^0.9.8",
"@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

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