Socket
Socket
Sign inDemoInstall

@pkmn/client

Package Overview
Dependencies
Maintainers
1
Versions
53
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.3.2 to 0.3.3

3

build/battle.d.ts

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

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

@@ -80,2 +80,3 @@ getSwitchedPokemon(pokemonid: PokemonIdent | SideID, details: PokemonDetails): Pokemon;

getSide(sidename: string): Side;
swapSideConditions(): void;
getPokemon(pokemonid?: '' | 'null' | PokemonIdent | SideID): Pokemon | null;

@@ -82,0 +83,0 @@ checkActive(poke: Pokemon): boolean;

@@ -19,2 +19,7 @@ "use strict";

]);
const SIDE_CONDITIONS = [
'mist', 'lightscreen', 'reflect', 'spikes', 'safeguard', 'tailwind', 'toxicspikes', 'stealthrock',
'waterpledge', 'firepledge', 'grasspledge', 'stickyweb', 'auroraveil', 'gmaxsteelsurge',
'gmaxcannonade', 'gmaxvinelash', 'gmaxwildfire',
];
class Battle {

@@ -387,2 +392,26 @@ constructor(gens, player = null, sets, field = (b) => new field_1.Field(b), side = (b, n, s) => new side_1.Side(b, n, s)) {

}
swapSideConditions() {
if (this.gameType === 'freeforall') {
// TODO: Add FFA support
return;
}
else {
const side1 = this.sides[0];
const side2 = this.sides[1];
for (const id of SIDE_CONDITIONS) {
if (side1.sideConditions[id] && side2.sideConditions[id]) {
[side1.sideConditions[id], side2.sideConditions[id]] =
[side2.sideConditions[id], side1.sideConditions[id]];
}
else if (side1.sideConditions[id] && !side2.sideConditions[id]) {
side2.sideConditions[id] = side1.sideConditions[id];
side1.removeSideCondition(id);
}
else if (side2.sideConditions[id] && !side1.sideConditions[id]) {
side1.sideConditions[id] = side2.sideConditions[id];
side2.removeSideCondition(id);
}
}
}
}
getPokemon(pokemonid) {

@@ -389,0 +418,0 @@ if (!pokemonid || pokemonid === '??' || pokemonid === 'null' || pokemonid === 'false') {

@@ -291,2 +291,3 @@ import { BoostID, Effect, ID, Item, Specie, StatusName } from '@pkmn/data';

'|-sideend|'(args: Args['|-sideend|']): void;
'|-swapsideconditions|'(): void;
'|-weather|'(args: Args['|-weather|'], kwArgs: KWArgs['|-weather|']): void;

@@ -293,0 +294,0 @@ '|-fieldstart|'(args: Args['|-fieldstart|'], kwArgs: KWArgs['|-fieldstart|']): void;

@@ -881,2 +881,5 @@ "use strict";

}
'|-swapsideconditions|'() {
this.battle.swapSideConditions();
}
'|-weather|'(args, kwArgs) {

@@ -883,0 +886,0 @@ const c = this.context = {

@@ -336,5 +336,37 @@ "use strict";

let pp = 1;
if (move.target === 'all') {
for (const active of this.side.foe.active) {
if (active && data_1.toID(active.ability) === 'pressure') {
let ngasActive = false;
for (const side of this.side.battle.sides) {
for (const active of side.active) {
if (active && !active.fainted &&
data_1.toID(active.ability) === 'neutralizinggas' && !active.volatiles['gastroacid']) {
ngasActive = true;
break;
}
}
}
// Sticky Web is never affected by pressure
if (!ngasActive && move.id !== 'stickyweb') {
const foeTargets = [];
const singles = ['self', 'allies', 'allySide', 'adjacentAlly', 'adjacentAllyOrSelf'];
const ffa = ['all', 'allAdjacent', 'allAdjacentFoes', 'foeSide'];
if (!target && this.side.battle.gameType === 'singles' && !singles.includes(move.target)) {
// Hardcode for moves without a target in singles
foeTargets.push(this.side.foe.active[0]);
}
else if (ffa.includes(move.target)) {
// We loop through all sides here for FFA
for (const side of this.side.battle.sides) {
if (side === this.side || side === this.side.ally)
continue;
for (const active of side.active) {
foeTargets.push(active);
}
}
}
else if (target && target.side !== this.side) {
foeTargets.push(target);
}
for (const foe of foeTargets) {
if (foe && !foe.fainted && data_1.toID(foe.ability) === 'pressure' &&
!foe.volatiles['gastroacid']) {
pp += 1;

@@ -344,5 +376,2 @@ }

}
else if (target && target.side !== this.side && data_1.toID(target.ability) === 'pressure') {
pp += 1;
}
this.rememberMove(moveName, pp);

@@ -349,0 +378,0 @@ }

{
"name": "@pkmn/client",
"version": "0.3.2",
"version": "0.3.3",
"main": "build/index.js",

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

"dependencies": {
"@pkmn/data": "^0.4.4",
"@pkmn/protocol": "^0.3.2"
"@pkmn/data": "^0.4.6",
"@pkmn/protocol": "^0.3.3"
},
"devDependencies": {
"@pkmn/dex": "^0.4.4"
"@pkmn/dex": "^0.4.6"
},

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

@@ -46,2 +46,8 @@ import {

const SIDE_CONDITIONS = [
'mist', 'lightscreen', 'reflect', 'spikes', 'safeguard', 'tailwind', 'toxicspikes', 'stealthrock',
'waterpledge', 'firepledge', 'grasspledge', 'stickyweb', 'auroraveil', 'gmaxsteelsurge',
'gmaxcannonade', 'gmaxvinelash', 'gmaxwildfire',
];
export type Context<T extends keyof HandlerContext> = [

@@ -484,2 +490,24 @@ {

swapSideConditions() {
if (this.gameType === 'freeforall') {
// TODO: Add FFA support
return;
} else {
const side1 = this.sides[0];
const side2 = this.sides[1];
for (const id of SIDE_CONDITIONS) {
if (side1.sideConditions[id] && side2.sideConditions[id]) {
[side1.sideConditions[id], side2.sideConditions[id]] =
[side2.sideConditions[id], side1.sideConditions[id]];
} else if (side1.sideConditions[id] && !side2.sideConditions[id]) {
side2.sideConditions[id] = side1.sideConditions[id];
side1.removeSideCondition(id as ID);
} else if (side2.sideConditions[id] && !side1.sideConditions[id]) {
side1.sideConditions[id] = side2.sideConditions[id];
side2.removeSideCondition(id as ID);
}
}
}
}
getPokemon(pokemonid?: '' | 'null' | PokemonIdent | SideID) {

@@ -486,0 +514,0 @@ if (!pokemonid || pokemonid === '??' || pokemonid === 'null' || pokemonid === 'false') {

@@ -997,2 +997,6 @@ import {

'|-swapsideconditions|'() {
this.battle.swapSideConditions();
}
'|-weather|'(args: Args['|-weather|'], kwArgs: KWArgs['|-weather|']) {

@@ -999,0 +1003,0 @@ const c = this.context = {

@@ -504,10 +504,39 @@ import {

let pp = 1;
if (move.target === 'all') {
for (const active of this.side.foe.active) {
if (active && toID(active.ability) === 'pressure') {
let ngasActive = false;
for (const side of this.side.battle.sides) {
for (const active of side.active) {
if (active && !active.fainted &&
toID(active.ability) === 'neutralizinggas' && !active.volatiles['gastroacid']) {
ngasActive = true;
break;
}
}
}
// Sticky Web is never affected by pressure
if (!ngasActive && move.id !== 'stickyweb') {
const foeTargets = [];
const singles = ['self', 'allies', 'allySide', 'adjacentAlly', 'adjacentAllyOrSelf'];
const ffa = ['all', 'allAdjacent', 'allAdjacentFoes', 'foeSide'];
if (!target && this.side.battle.gameType === 'singles' && !singles.includes(move.target!)) {
// Hardcode for moves without a target in singles
foeTargets.push(this.side.foe.active[0]);
} else if (ffa.includes(move.target!)) {
// We loop through all sides here for FFA
for (const side of this.side.battle.sides) {
if (side === this.side || side === this.side.ally) continue;
for (const active of side.active) {
foeTargets.push(active);
}
}
} else if (target && target.side !== this.side) {
foeTargets.push(target);
}
for (const foe of foeTargets) {
if (foe && !foe.fainted && toID(foe.ability) === 'pressure' &&
!foe.volatiles['gastroacid']) {
pp += 1;
}
}
} else if (target && target.side !== this.side && toID(target.ability) === 'pressure') {
pp += 1;
}

@@ -514,0 +543,0 @@ this.rememberMove(moveName, pp);

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