@pkmn/sim 0.5.1 → 0.5.5
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.
- package/build/config/formats.js +373 -289
- package/build/config/formats.js.map +1 -1
- package/build/data/abilities.js +5 -1
- package/build/data/abilities.js.map +1 -1
- package/build/data/aliases.js +2 -2
- package/build/data/aliases.js.map +1 -1
- package/build/data/formats-data.js +91 -92
- package/build/data/formats-data.js.map +1 -1
- package/build/data/items.js +5 -5
- package/build/data/items.js.map +1 -1
- package/build/data/learnsets.js +1 -1
- package/build/data/learnsets.js.map +1 -1
- package/build/data/mods/gen1/formats-data.js +190 -190
- package/build/data/mods/gen1/formats-data.js.map +1 -1
- package/build/data/mods/gen1/moves.js +1 -2
- package/build/data/mods/gen1/moves.js.map +1 -1
- package/build/data/mods/gen1/scripts.js +12 -0
- package/build/data/mods/gen1/scripts.js.map +1 -1
- package/build/data/mods/gen2/formats-data.js +2 -2
- package/build/data/mods/gen2/formats-data.js.map +1 -1
- package/build/data/mods/gen3/formats-data.js +12 -12
- package/build/data/mods/gen3/formats-data.js.map +1 -1
- package/build/data/mods/gen4/moves.js +22 -0
- package/build/data/mods/gen4/moves.js.map +1 -1
- package/build/data/mods/gen5/formats-data.js +172 -155
- package/build/data/mods/gen5/formats-data.js.map +1 -1
- package/build/data/mods/gen6/formats-data.js +1 -1
- package/build/data/mods/gen7/formats-data.js +1 -1
- package/build/data/mods/gen7/formats-data.js.map +1 -1
- package/build/data/mods/gen7/moves.js +154 -0
- package/build/data/mods/gen7/moves.js.map +1 -1
- package/build/data/moves.js +47 -20
- package/build/data/moves.js.map +1 -1
- package/build/data/pokedex.js +3 -3
- package/build/data/pokedex.js.map +1 -1
- package/build/data/rulesets.js +48 -5
- package/build/data/rulesets.js.map +1 -1
- package/build/data/tags.d.ts +1 -0
- package/build/data/tags.js +4 -3
- package/build/data/tags.js.map +1 -1
- package/build/data/text/abilities.js +4 -4
- package/build/data/text/abilities.js.map +1 -1
- package/build/data/text/moves.js +19 -19
- package/build/data/text/moves.js.map +1 -1
- package/build/sim/battle-actions.js +12 -4
- package/build/sim/battle-actions.js.map +1 -1
- package/build/sim/dex-formats.d.ts +1 -0
- package/build/sim/dex-formats.js +3 -2
- package/build/sim/dex-formats.js.map +1 -1
- package/build/sim/exported-global-types.d.ts +1 -0
- package/build/sim/global-types.d.ts +1 -0
- package/build/sim/index.d.ts +1 -0
- package/build/sim/index.js +3 -1
- package/build/sim/index.js.map +1 -1
- package/build/sim/pokemon.js +1 -1
- package/build/sim/pokemon.js.map +1 -1
- package/build/sim/team-validator.js +16 -0
- package/build/sim/team-validator.js.map +1 -1
- package/config/formats.ts +379 -292
- package/data/abilities.ts +3 -1
- package/data/aliases.ts +2 -2
- package/data/formats-data.ts +91 -92
- package/data/items.ts +5 -5
- package/data/learnsets.ts +1 -1
- package/data/mods/gen1/formats-data.ts +190 -190
- package/data/mods/gen1/moves.ts +1 -2
- package/data/mods/gen1/scripts.ts +11 -0
- package/data/mods/gen2/formats-data.ts +2 -2
- package/data/mods/gen3/formats-data.ts +12 -12
- package/data/mods/gen4/moves.ts +21 -0
- package/data/mods/gen5/formats-data.ts +172 -155
- package/data/mods/gen6/formats-data.ts +1 -1
- package/data/mods/gen7/formats-data.ts +1 -1
- package/data/mods/gen7/moves.ts +150 -0
- package/data/moves.ts +46 -20
- package/data/pokedex.ts +3 -3
- package/data/rulesets.ts +44 -6
- package/data/tags.ts +6 -3
- package/data/text/abilities.ts +4 -4
- package/data/text/moves.ts +19 -19
- package/package.json +2 -2
- package/sim/battle-actions.ts +12 -4
- package/sim/dex-formats.ts +4 -1
- package/sim/exported-global-types.ts +1 -0
- package/sim/global-types.ts +1 -0
- package/sim/index.ts +1 -0
- package/sim/pokemon.ts +1 -1
- package/sim/team-validator.ts +15 -0
package/sim/battle-actions.ts
CHANGED
|
@@ -438,7 +438,8 @@ export class BattleActions {
|
|
|
438
438
|
target = targets[targets.length - 1]; // in case of redirection
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
|
|
441
|
+
const callerMoveForPressure = sourceEffect && (sourceEffect as ActiveMove).pp ? sourceEffect as ActiveMove : null;
|
|
442
|
+
if (!sourceEffect || callerMoveForPressure || sourceEffect.id === 'pursuit') {
|
|
442
443
|
let extraPP = 0;
|
|
443
444
|
for (const source of pressureTargets) {
|
|
444
445
|
const ppDrop = this.battle.runEvent('DeductPP', source, pokemon, move);
|
|
@@ -447,7 +448,7 @@ export class BattleActions {
|
|
|
447
448
|
}
|
|
448
449
|
}
|
|
449
450
|
if (extraPP > 0) {
|
|
450
|
-
pokemon.deductPP(moveOrMoveName, extraPP);
|
|
451
|
+
pokemon.deductPP(callerMoveForPressure || moveOrMoveName, extraPP);
|
|
451
452
|
}
|
|
452
453
|
}
|
|
453
454
|
|
|
@@ -1284,7 +1285,10 @@ export class BattleActions {
|
|
|
1284
1285
|
this.battle.runEvent('ModifySecondaries', target, source, moveData, moveData.secondaries.slice());
|
|
1285
1286
|
for (const secondary of secondaries) {
|
|
1286
1287
|
const secondaryRoll = this.battle.random(100);
|
|
1287
|
-
|
|
1288
|
+
// User stat boosts or target stat drops can possibly overflow if it goes beyond 256
|
|
1289
|
+
const secondaryOverflow = (secondary.boosts || secondary.self);
|
|
1290
|
+
if (typeof secondary.chance === 'undefined' ||
|
|
1291
|
+
secondaryRoll < (secondaryOverflow ? secondary.chance % 256 : secondary.chance)) {
|
|
1288
1292
|
this.moveHit(target, source, move, secondary, true, isSelf);
|
|
1289
1293
|
}
|
|
1290
1294
|
}
|
|
@@ -1447,7 +1451,7 @@ export class BattleActions {
|
|
|
1447
1451
|
this.battle.heal(pokemon.maxhp, pokemon, pokemon, zPower);
|
|
1448
1452
|
break;
|
|
1449
1453
|
case 'healreplacement':
|
|
1450
|
-
|
|
1454
|
+
pokemon.side.addSlotCondition(pokemon, 'healreplacement', pokemon, move);
|
|
1451
1455
|
break;
|
|
1452
1456
|
case 'clearnegativeboost':
|
|
1453
1457
|
const boosts: SparseBoostsTable = {};
|
|
@@ -1575,6 +1579,10 @@ export class BattleActions {
|
|
|
1575
1579
|
|
|
1576
1580
|
if (!basePower) return 0;
|
|
1577
1581
|
basePower = this.battle.clampIntRange(basePower, 1);
|
|
1582
|
+
// Hacked Max Moves have 0 base power, even if you Dynamax
|
|
1583
|
+
if ((!source.volatiles['dynamax'] && move.isMax) || (move.isMax && this.dex.moves.get(move.baseMove).isMax)) {
|
|
1584
|
+
basePower = 0;
|
|
1585
|
+
}
|
|
1578
1586
|
|
|
1579
1587
|
const level = source.level;
|
|
1580
1588
|
|
package/sim/dex-formats.ts
CHANGED
|
@@ -340,6 +340,10 @@ export class RuleTable extends Map<string, string> {
|
|
|
340
340
|
throw new Error(`maxForcedLevel is now a rule: "Adjust Level Down = NUMBER"`);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
+
|
|
344
|
+
hasComplexBans() {
|
|
345
|
+
return (this.complexBans?.length > 0) || (this.complexTeamBans?.length > 0);
|
|
346
|
+
}
|
|
343
347
|
}
|
|
344
348
|
|
|
345
349
|
export class Format extends BasicEffect implements Readonly<BasicEffect> {
|
|
@@ -799,7 +803,6 @@ export class DexFormats {
|
|
|
799
803
|
case '-':
|
|
800
804
|
case '*':
|
|
801
805
|
case '+':
|
|
802
|
-
if (format?.team) throw new Error(`We don't currently support bans in generated teams`);
|
|
803
806
|
if (rule.slice(1).includes('>') || rule.slice(1).includes('+')) {
|
|
804
807
|
let buf = rule.slice(1);
|
|
805
808
|
const gtIndex = buf.lastIndexOf('>');
|
|
@@ -309,6 +309,7 @@ export interface ModdedBattlePokemon {
|
|
|
309
309
|
inherit?: true;
|
|
310
310
|
lostItemForDelibird?: Item | null;
|
|
311
311
|
boostBy?: (this: Pokemon, boost: SparseBoostsTable) => boolean | number;
|
|
312
|
+
clearBoosts?: (this: Pokemon) => void;
|
|
312
313
|
calculateStat?: (this: Pokemon, statName: StatIDExceptHP, boost: number, modifier?: number) => number;
|
|
313
314
|
cureStatus?: (this: Pokemon, silent?: boolean) => boolean;
|
|
314
315
|
getAbility?: (this: Pokemon) => Ability;
|
package/sim/global-types.ts
CHANGED
|
@@ -309,6 +309,7 @@ interface ModdedBattlePokemon {
|
|
|
309
309
|
inherit?: true;
|
|
310
310
|
lostItemForDelibird?: Item | null;
|
|
311
311
|
boostBy?: (this: Pokemon, boost: SparseBoostsTable) => boolean | number;
|
|
312
|
+
clearBoosts?: (this: Pokemon) => void;
|
|
312
313
|
calculateStat?: (this: Pokemon, statName: StatIDExceptHP, boost: number, modifier?: number) => number;
|
|
313
314
|
cureStatus?: (this: Pokemon, silent?: boolean) => boolean;
|
|
314
315
|
getAbility?: (this: Pokemon) => Ability;
|
package/sim/index.ts
CHANGED
package/sim/pokemon.ts
CHANGED
|
@@ -794,7 +794,7 @@ export class Pokemon {
|
|
|
794
794
|
for (const pokemon of this.battle.getAllActive()) {
|
|
795
795
|
// can't use hasAbility because it would lead to infinite recursion
|
|
796
796
|
if (pokemon.ability === ('neutralizinggas' as ID) && !pokemon.volatiles['gastroacid'] &&
|
|
797
|
-
!pokemon.abilityState.ending) {
|
|
797
|
+
!pokemon.transformed && !pokemon.abilityState.ending) {
|
|
798
798
|
neutralizinggas = true;
|
|
799
799
|
break;
|
|
800
800
|
}
|
package/sim/team-validator.ts
CHANGED
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
import {Dex, toID} from './dex';
|
|
27
27
|
import {Utils} from '../lib';
|
|
28
28
|
import {Tags} from '../data/tags';
|
|
29
|
+
import {Teams} from './teams';
|
|
30
|
+
import {PRNG} from './prng';
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Describes a possible way to get a pokemon. Is not exhaustive!
|
|
@@ -252,6 +254,16 @@ export class TeamValidator {
|
|
|
252
254
|
`If you're not using a custom client, please report this as a bug. If you are, remember to use \`/utm null\` before starting a game in this format.`,
|
|
253
255
|
];
|
|
254
256
|
}
|
|
257
|
+
const testTeamSeed = PRNG.generateSeed();
|
|
258
|
+
try {
|
|
259
|
+
const testTeamGenerator = Teams.getGenerator(format, testTeamSeed);
|
|
260
|
+
testTeamGenerator.getTeam(options as any); // Throws error if generation fails
|
|
261
|
+
} catch (e) {
|
|
262
|
+
return [
|
|
263
|
+
`${format.name}'s team generator (${format.team}) failed using these rules and seed (${testTeamSeed}):-`,
|
|
264
|
+
`${e}`,
|
|
265
|
+
];
|
|
266
|
+
}
|
|
255
267
|
return null;
|
|
256
268
|
}
|
|
257
269
|
if (!team) {
|
|
@@ -540,6 +552,9 @@ export class TeamValidator {
|
|
|
540
552
|
problem = this.checkItem(set, item, setHas);
|
|
541
553
|
if (problem) problems.push(problem);
|
|
542
554
|
if (ruleTable.has('obtainablemisc')) {
|
|
555
|
+
if (dex.gen === 4 && item.id === 'griseousorb' && species.num !== 487) {
|
|
556
|
+
problems.push(`${set.name} cannot hold the Griseous Orb.`, `(In Gen 4, only Giratina could hold the Griseous Orb).`);
|
|
557
|
+
}
|
|
543
558
|
if (dex.gen <= 1) {
|
|
544
559
|
if (item.id) {
|
|
545
560
|
// no items allowed
|