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

@pkmn/client

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pkmn/client - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

4

build/battle.d.ts

@@ -62,3 +62,3 @@ import { DataKind, GameType, Generation, Generations, ID, PokemonSet, SideID } from '@pkmn/data';

private findIllusion;
get(type: 'abilities' | 'items' | 'moves' | 'species' | 'effects', s?: string): {
get(type: 'abilities' | 'items' | 'moves' | 'species' | 'conditions', s?: string): {
name: string;

@@ -74,3 +74,3 @@ id: ID;

slot: number;
pokemonid: SideID | Protocol.PokemonIdent;
pokemonid: Protocol.PokemonIdent | SideID;
};

@@ -77,0 +77,0 @@ getSwitchedPokemon(pokemonid: PokemonIdent | SideID, details: PokemonDetails): Pokemon;

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

import { BoostName, Effect, ID, Item, Specie, StatusName } from '@pkmn/data';
import { BoostID, Effect, ID, Item, Specie, StatusName } from '@pkmn/data';
import { Ability, Move } from '@pkmn/dex';

@@ -58,3 +58,3 @@ import { Protocol, Args, KWArgs } from '@pkmn/protocol';

poke: Pokemon;
boost: BoostName;
boost: BoostID;
amount: number;

@@ -66,3 +66,3 @@ fromEffect?: Effect | NA;

poke: Pokemon;
boost: BoostName;
boost: BoostID;
amount: number;

@@ -74,3 +74,3 @@ fromEffect?: Effect | NA;

poke: Pokemon;
boost: BoostName;
boost: BoostID;
amount: number;

@@ -81,3 +81,3 @@ };

poke2: Pokemon;
boosts: BoostName[];
boosts: BoostID[];
};

@@ -93,3 +93,3 @@ '|-clearpositiveboost|': {

poke2: Pokemon;
boosts: BoostName[];
boosts: BoostID[];
};

@@ -96,0 +96,0 @@ '|-clearboost|': {

@@ -41,15 +41,18 @@ "use strict";

switch (args[1]) {
default:
this.battle.p1.active = [null];
this.battle.p2.active = [null];
break;
case 'multi':
case 'freeforall':
// @ts-ignore readonly
this.battle.p3 = this.battle.createSide(3);
if (!this.battle.p3)
this.battle.p3 = this.battle.createSide(3);
// @ts-ignore readonly
this.battle.p4 = this.battle.createSide(4);
this.battle.p3.foe = this.battle.p4.ally = this.battle.p2;
this.battle.p3.ally = this.battle.p4.foe = this.battle.p1;
this.battle.p1.ally = this.battle.p3;
this.battle.p2.ally = this.battle.p4;
if (!this.battle.p4)
this.battle.p4 = this.battle.createSide(4);
this.battle.p3.foe = this.battle.p2;
this.battle.p4.foe = this.battle.p1;
if (this.battle.gameType === 'multi') {
this.battle.p1.ally = this.battle.p3;
this.battle.p2.ally = this.battle.p4;
this.battle.p3.ally = this.battle.p1;
this.battle.p4.ally = this.battle.p2;
}
this.battle.sides.push(this.battle.p3, this.battle.p4);

@@ -69,2 +72,6 @@ // intentionally sync p1/p3 and p2/p4's active arrays

break;
default:
for (const side of this.battle.sides)
side.active = [null];
break;
}

@@ -189,3 +196,3 @@ }

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
move: this.battle.get('moves', args[3]),

@@ -207,3 +214,3 @@ };

if (kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.ofPoke = this.battle.getPokemon(kwArgs.of);

@@ -228,3 +235,3 @@ if (c.ofPoke)

if (kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.poke.activateAbility(c.fromEffect);

@@ -282,3 +289,3 @@ if (c.fromEffect.kind === 'Item' &&

if (!kwArgs.silent && kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.ofPoke = this.battle.getPokemon(kwArgs.of);

@@ -358,3 +365,3 @@ (c.ofPoke || c.poke).activateAbility(c.fromEffect);

if (!kwArgs.silent && kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.ofPoke = this.battle.getPokemon(kwArgs.of);

@@ -382,3 +389,3 @@ (c.ofPoke || c.poke).activateAbility(c.fromEffect);

poke: this.battle.getPokemon(args[1]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -391,3 +398,3 @@ };

poke: this.battle.getPokemon(args[1]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -401,3 +408,3 @@ };

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -426,3 +433,3 @@ };

status: args[2],
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -474,3 +481,3 @@ };

item: this.battle.get('items', args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -521,3 +528,3 @@ };

item: this.battle.get('items', args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
};

@@ -564,3 +571,3 @@ c.poke.item = '';

ability: this.battle.get('abilities', args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -638,3 +645,3 @@ };

poke2: this.battle.getPokemon(args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
};

@@ -665,3 +672,3 @@ if (c.poke === c.poke2)

if (!kwArgs.silent && kwArgs.from) {
c.poke.activateAbility(this.battle.get('effects', kwArgs.from));
c.poke.activateAbility(this.battle.get('conditions', kwArgs.from));
}

@@ -692,5 +699,5 @@ // the formechange volatile reminds us to revert the sprite change on switch-out

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
ofPoke: this.battle.getPokemon(kwArgs.of),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
};

@@ -743,3 +750,3 @@ c.poke.activateAbility(c.effect);

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
};

@@ -755,3 +762,3 @@ c.poke.removeVolatile(c.effect.id);

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
};

@@ -766,3 +773,3 @@ c.poke.addVolatile(c.effect.id, { duration: 'turn' });

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
};

@@ -774,3 +781,3 @@ c.poke.addVolatile(c.effect.id, { duration: 'move' });

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
poke2: this.battle.getPokemon(args[3]),

@@ -873,3 +880,3 @@ };

side: this.battle.getSide(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
};

@@ -881,3 +888,3 @@ c.side.addSideCondition(c.effect);

side: this.battle.getSide(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
};

@@ -888,4 +895,4 @@ c.side.removeSideCondition(c.effect.id);

const c = this.context = {
effect: args[1] === 'none' ? battle_1.NULL : this.battle.get('effects', args[1]),
ability: this.battle.get('effects', kwArgs.from),
effect: args[1] === 'none' ? battle_1.NULL : this.battle.get('conditions', args[1]),
ability: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -897,4 +904,4 @@ };

const c = this.context = {
effect: this.battle.get('effects', args[1]),
fromEffect: this.battle.get('effects', kwArgs.from),
effect: this.battle.get('conditions', args[1]),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -913,3 +920,3 @@ };

const c = this.context = {
effect: this.battle.get('effects', args[1]),
effect: this.battle.get('conditions', args[1]),
};

@@ -916,0 +923,0 @@ if (c.effect.id.endsWith('terrain')) {

@@ -306,3 +306,3 @@ "use strict";

useMove(move, target, from) {
const fromeffect = this.side.battle.get('effects', from);
const fromeffect = this.side.battle.get('conditions', from);
this.activateAbility(fromeffect);

@@ -309,0 +309,0 @@ this.clearMovestatuses();

{
"name": "@pkmn/client",
"version": "0.2.2",
"version": "0.3.0",
"main": "build/index.js",

@@ -13,7 +13,7 @@ "types": "build/index.d.ts",

"dependencies": {
"@pkmn/data": "^0.3.22",
"@pkmn/protocol": "^0.2.2"
"@pkmn/data": "^0.4.0",
"@pkmn/protocol": "^0.3.0"
},
"devDependencies": {
"@pkmn/dex": "^0.3.22"
"@pkmn/dex": "^0.4.0"
},

@@ -20,0 +20,0 @@ "scripts": {

@@ -300,3 +300,3 @@ import {

// truth and if the client is out of date it should degrade gracefully
get(type: 'abilities' | 'items' | 'moves' | 'species' | 'effects', s?: string) {
get(type: 'abilities' | 'items' | 'moves' | 'species' | 'conditions', s?: string) {
return !s ? NULL : (this.gen[type].get(s) || {name: s, id: toID(s), kind: 'Condition'});

@@ -303,0 +303,0 @@ }

import {
BoostName,
BoostID,
Effect,

@@ -20,3 +20,3 @@ ID,

const BOOSTS: BoostName[] = ['atk', 'def', 'spa', 'spd', 'spe', 'accuracy', 'evasion'];
const BOOSTS: BoostID[] = ['atk', 'def', 'spa', 'spd', 'spe', 'accuracy', 'evasion'];
const CONSUMED: LastItemEffect[] = ['eaten', 'popped', 'consumed', 'held up'];

@@ -38,3 +38,3 @@

poke: Pokemon;
boost: BoostName;
boost: BoostID;
amount: number;

@@ -46,3 +46,3 @@ fromEffect?: Effect | NA;

poke: Pokemon;
boost: BoostName;
boost: BoostID;
amount: number;

@@ -52,7 +52,7 @@ fromEffect?: Effect | NA;

};
'|-setboost|': {poke: Pokemon; boost: BoostName; amount: number};
'|-swapboost|': {poke: Pokemon; poke2: Pokemon; boosts: BoostName[]};
'|-setboost|': {poke: Pokemon; boost: BoostID; amount: number};
'|-swapboost|': {poke: Pokemon; poke2: Pokemon; boosts: BoostID[]};
'|-clearpositiveboost|': {poke: Pokemon};
'|-clearnegativeboost|': {poke: Pokemon};
'|-copyboost|': {poke: Pokemon; poke2: Pokemon; boosts: BoostName[]};
'|-copyboost|': {poke: Pokemon; poke2: Pokemon; boosts: BoostID[]};
'|-clearboost|': {poke: Pokemon; fromEffect?: Effect | NA; ofPoke?: Pokemon | null};

@@ -138,15 +138,16 @@ '|-invertboost|': {poke: Pokemon};

switch (args[1]) {
default:
this.battle.p1.active = [null];
this.battle.p2.active = [null];
break;
case 'multi':
case 'freeforall':
// @ts-ignore readonly
this.battle.p3 = this.battle.createSide(3);
if (!this.battle.p3) this.battle.p3 = this.battle.createSide(3);
// @ts-ignore readonly
this.battle.p4 = this.battle.createSide(4);
this.battle.p3.foe = this.battle.p4.ally = this.battle.p2;
this.battle.p3.ally = this.battle.p4.foe = this.battle.p1;
this.battle.p1.ally = this.battle.p3;
this.battle.p2.ally = this.battle.p4;
if (!this.battle.p4) this.battle.p4 = this.battle.createSide(4);
this.battle.p3.foe = this.battle.p2;
this.battle.p4.foe = this.battle.p1;
if (this.battle.gameType === 'multi') {
this.battle.p1.ally = this.battle.p3;
this.battle.p2.ally = this.battle.p4;
this.battle.p3.ally = this.battle.p1;
this.battle.p4.ally = this.battle.p2;
}

@@ -167,2 +168,5 @@ this.battle.sides.push(this.battle.p3, this.battle.p4);

break;
default:
for (const side of this.battle.sides) side.active = [null];
break;
}

@@ -292,3 +296,3 @@ }

poke: this.battle.getPokemon(args[1])!,
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
move: this.battle.get('moves', args[3]),

@@ -311,3 +315,3 @@ } as Context['|cant|'];

if (kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.ofPoke = this.battle.getPokemon(kwArgs.of);

@@ -332,3 +336,3 @@ if (c.ofPoke) c.ofPoke.activateAbility(c.fromEffect);

if (kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.poke.activateAbility(c.fromEffect);

@@ -389,3 +393,3 @@ if (c.fromEffect.kind === 'Item' &&

if (!kwArgs.silent && kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.ofPoke = this.battle.getPokemon(kwArgs.of);

@@ -408,3 +412,3 @@ (c.ofPoke || c.poke).activateAbility(c.fromEffect);

poke2: this.battle.getPokemon(args[2])!,
boosts: args[3] ? args[3].split(', ') as BoostName[] : BOOSTS,
boosts: args[3] ? args[3].split(', ') as BoostID[] : BOOSTS,
} as Context['|-swapboost|'];

@@ -426,3 +430,3 @@

for (const boost in c.poke.boosts) {
const b = boost as BoostName;
const b = boost as BoostID;
if (c.poke.boosts[b]! > 0) delete c.poke.boosts[b];

@@ -437,3 +441,3 @@ }

for (const boost in c.poke.boosts) {
const b = boost as BoostName;
const b = boost as BoostID;
if (c.poke.boosts[b]! < 0) delete c.poke.boosts[b];

@@ -447,3 +451,3 @@ }

poke2: this.battle.getPokemon(args[2])!,
boosts: args[3] ? args[3].split(', ') as BoostName[] : BOOSTS,
boosts: args[3] ? args[3].split(', ') as BoostID[] : BOOSTS,
} as Context['|-copyboost|'];

@@ -471,3 +475,3 @@

if (!kwArgs.silent && kwArgs.from) {
c.fromEffect = this.battle.get('effects', kwArgs.from);
c.fromEffect = this.battle.get('conditions', kwArgs.from);
c.ofPoke = this.battle.getPokemon(kwArgs.of);

@@ -481,3 +485,3 @@ (c.ofPoke || c.poke).activateAbility(c.fromEffect);

for (const boost in c.poke.boosts) {
const b = boost as BoostName;
const b = boost as BoostID;
c.poke.boosts[b] = -c.poke.boosts[b]!;

@@ -498,3 +502,3 @@ }

poke: this.battle.getPokemon(args[1])!,
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -508,3 +512,3 @@ } as Context['|-immune|'];

poke: this.battle.getPokemon(args[1])!,
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -518,3 +522,3 @@ } as Context['|-fail|'];

poke: this.battle.getPokemon(args[1])!,
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -541,3 +545,3 @@ } as Context['|-block|'];

status: args[2],
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -589,3 +593,3 @@ } as Context['|-status|'];

item: this.battle.get('items', args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -638,3 +642,3 @@ } as Context['|-item|'];

item: this.battle.get('items', args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
} as Context['|-enditem|'];

@@ -681,3 +685,3 @@

ability: this.battle.get('abilities', args[2]),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -759,3 +763,3 @@ } as Context['|-ability|'];

poke2: this.battle.getPokemon(args[2])!,
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
} as Context['|-transform|'];

@@ -788,3 +792,3 @@

if (!kwArgs.silent && kwArgs.from) {
c.poke.activateAbility(this.battle.get('effects', kwArgs.from));
c.poke.activateAbility(this.battle.get('conditions', kwArgs.from));
}

@@ -818,5 +822,5 @@ // the formechange volatile reminds us to revert the sprite change on switch-out

poke: this.battle.getPokemon(args[1])!,
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
ofPoke: this.battle.getPokemon(kwArgs.of),
fromEffect: this.battle.get('effects', kwArgs.from),
fromEffect: this.battle.get('conditions', kwArgs.from),
} as Context['|-start|'];

@@ -870,3 +874,3 @@

poke: this.battle.getPokemon(args[1])!,
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
} as Context['|-end|'];

@@ -882,3 +886,3 @@ c.poke.removeVolatile(c.effect.id);

poke: this.battle.getPokemon(args[1])!,
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
} as Context['|-singleturn|'];

@@ -894,3 +898,3 @@ c.poke.addVolatile(c.effect.id, {duration: 'turn'});

poke: this.battle.getPokemon(args[1])!,
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
} as Context['|-singlemove|'];

@@ -903,3 +907,3 @@ c.poke.addVolatile(c.effect.id, {duration: 'move'});

poke: this.battle.getPokemon(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
poke2: this.battle.getPokemon(args[3] as PokemonIdent),

@@ -998,3 +1002,3 @@ } as Context['|-activate|'];

side: this.battle.getSide(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
} as Context['|-sidestart|'];

@@ -1007,3 +1011,3 @@ c.side.addSideCondition(c.effect);

side: this.battle.getSide(args[1]),
effect: this.battle.get('effects', args[2]),
effect: this.battle.get('conditions', args[2]),
} as Context['|-sideend|'];

@@ -1015,4 +1019,4 @@ c.side.removeSideCondition(c.effect.id);

const c = this.context = {
effect: args[1] === 'none' ? NULL : this.battle.get('effects', args[1]),
ability: this.battle.get('effects', kwArgs.from),
effect: args[1] === 'none' ? NULL : this.battle.get('conditions', args[1]),
ability: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -1026,4 +1030,4 @@ } as Context['|-weather|'];

const c = this.context = {
effect: this.battle.get('effects', args[1]),
fromEffect: this.battle.get('effects', kwArgs.from),
effect: this.battle.get('conditions', args[1]),
fromEffect: this.battle.get('conditions', kwArgs.from),
ofPoke: this.battle.getPokemon(kwArgs.of),

@@ -1043,3 +1047,3 @@ } as Context['|-fieldstart|'];

const c = this.context = {
effect: this.battle.get('effects', args[1]),
effect: this.battle.get('conditions', args[1]),
} as Context['|-fieldend|'];

@@ -1046,0 +1050,0 @@ if (c.effect.id.endsWith('terrain')) {

@@ -478,3 +478,3 @@ import {

) {
const fromeffect = this.side.battle.get('effects', from);
const fromeffect = this.side.battle.get('conditions', from);
this.activateAbility(fromeffect);

@@ -481,0 +481,0 @@ this.clearMovestatuses();

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

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