@pkmn/sim 0.9.30 → 0.9.31
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/cjs/config/formats.js +58 -43
- package/build/cjs/config/formats.js.map +1 -1
- package/build/cjs/data/abilities.js +41 -41
- package/build/cjs/data/abilities.js.map +1 -1
- package/build/cjs/data/aliases.js +2 -2
- package/build/cjs/data/aliases.js.map +1 -1
- package/build/cjs/data/conditions.js +20 -20
- package/build/cjs/data/conditions.js.map +1 -1
- package/build/cjs/data/formats-data.js +1 -1
- package/build/cjs/data/items.js +5 -5
- package/build/cjs/data/items.js.map +1 -1
- package/build/cjs/data/mods/gen1/conditions.js +1 -2
- package/build/cjs/data/mods/gen1/conditions.js.map +1 -1
- package/build/cjs/data/mods/gen1/moves.js +2 -2
- package/build/cjs/data/mods/gen1/moves.js.map +1 -1
- package/build/cjs/data/mods/gen1/pokedex.js.map +1 -1
- package/build/cjs/data/mods/gen1/scripts.js +6 -6
- package/build/cjs/data/mods/gen1/scripts.js.map +1 -1
- package/build/cjs/data/mods/gen2/conditions.js +2 -2
- package/build/cjs/data/mods/gen2/conditions.js.map +1 -1
- package/build/cjs/data/mods/gen2/moves.js +3 -3
- package/build/cjs/data/mods/gen2/moves.js.map +1 -1
- package/build/cjs/data/mods/gen2/rulesets.js.map +1 -1
- package/build/cjs/data/mods/gen2/scripts.js +2 -2
- package/build/cjs/data/mods/gen2/scripts.js.map +1 -1
- package/build/cjs/data/mods/gen3/abilities.js +1 -1
- package/build/cjs/data/mods/gen3/abilities.js.map +1 -1
- package/build/cjs/data/mods/gen3/conditions.js +1 -1
- package/build/cjs/data/mods/gen3/conditions.js.map +1 -1
- package/build/cjs/data/mods/gen3/moves.js +5 -5
- package/build/cjs/data/mods/gen3/moves.js.map +1 -1
- package/build/cjs/data/mods/gen3/scripts.js +2 -2
- package/build/cjs/data/mods/gen3/scripts.js.map +1 -1
- package/build/cjs/data/mods/gen4/abilities.js +4 -4
- package/build/cjs/data/mods/gen4/abilities.js.map +1 -1
- package/build/cjs/data/mods/gen4/conditions.js +1 -1
- package/build/cjs/data/mods/gen4/conditions.js.map +1 -1
- package/build/cjs/data/mods/gen4/items.js +2 -2
- package/build/cjs/data/mods/gen4/items.js.map +1 -1
- package/build/cjs/data/mods/gen4/moves.js +22 -22
- package/build/cjs/data/mods/gen4/moves.js.map +1 -1
- package/build/cjs/data/mods/gen4/scripts.js +1 -1
- package/build/cjs/data/mods/gen4/scripts.js.map +1 -1
- package/build/cjs/data/mods/gen5/abilities.js +1 -1
- package/build/cjs/data/mods/gen5/abilities.js.map +1 -1
- package/build/cjs/data/mods/gen5/conditions.js +2 -2
- package/build/cjs/data/mods/gen5/conditions.js.map +1 -1
- package/build/cjs/data/mods/gen5/moves.js +6 -6
- package/build/cjs/data/mods/gen5/moves.js.map +1 -1
- package/build/cjs/data/mods/gen5/pokedex.js.map +1 -1
- package/build/cjs/data/mods/gen6/abilities.js +2 -2
- package/build/cjs/data/mods/gen6/abilities.js.map +1 -1
- package/build/cjs/data/mods/gen6/moves.js +1 -1
- package/build/cjs/data/mods/gen6/moves.js.map +1 -1
- package/build/cjs/data/mods/gen6/pokedex.js.map +1 -1
- package/build/cjs/data/mods/gen7/abilities.js.map +1 -1
- package/build/cjs/data/mods/gen7/moves.js +8 -8
- package/build/cjs/data/mods/gen7/moves.js.map +1 -1
- package/build/cjs/data/mods/gen7/pokedex.js.map +1 -1
- package/build/cjs/data/mods/gen8/abilities.js.map +1 -1
- package/build/cjs/data/mods/gen8/moves.js.map +1 -1
- package/build/cjs/data/mods/gen8/pokedex.js.map +1 -1
- package/build/cjs/data/moves.js +105 -103
- package/build/cjs/data/moves.js.map +1 -1
- package/build/cjs/data/pokedex.js.map +1 -1
- package/build/cjs/data/pokemongo.js.map +1 -1
- package/build/cjs/data/rulesets.js +0 -1
- package/build/cjs/data/rulesets.js.map +1 -1
- package/build/cjs/data/tags.js.map +1 -1
- package/build/cjs/data/text/abilities.js.map +1 -1
- package/build/cjs/data/text/default.js.map +1 -1
- package/build/cjs/data/text/items.js.map +1 -1
- package/build/cjs/data/text/moves.js.map +1 -1
- package/build/cjs/data/typechart.js.map +1 -1
- package/build/cjs/lib/utils.d.ts +5 -5
- package/build/cjs/lib/utils.js +21 -11
- package/build/cjs/lib/utils.js.map +1 -1
- package/build/cjs/sim/battle-actions.js +8 -8
- package/build/cjs/sim/battle-actions.js.map +1 -1
- package/build/cjs/sim/battle-queue.js +0 -1
- package/build/cjs/sim/battle-queue.js.map +1 -1
- package/build/cjs/sim/battle-stream.d.ts +3 -2
- package/build/cjs/sim/battle-stream.js +1 -1
- package/build/cjs/sim/battle-stream.js.map +1 -1
- package/build/cjs/sim/battle.d.ts +8 -8
- package/build/cjs/sim/battle.js +41 -44
- package/build/cjs/sim/battle.js.map +1 -1
- package/build/cjs/sim/dex-abilities.js.map +1 -1
- package/build/cjs/sim/dex-conditions.js +2 -2
- package/build/cjs/sim/dex-conditions.js.map +1 -1
- package/build/cjs/sim/dex-data.js +1 -1
- package/build/cjs/sim/dex-data.js.map +1 -1
- package/build/cjs/sim/dex-formats.d.ts +1 -0
- package/build/cjs/sim/dex-formats.js +95 -37
- package/build/cjs/sim/dex-formats.js.map +1 -1
- package/build/cjs/sim/dex-items.js.map +1 -1
- package/build/cjs/sim/dex-moves.js +2 -3
- package/build/cjs/sim/dex-moves.js.map +1 -1
- package/build/cjs/sim/exported-global-types.d.ts +1 -9
- package/build/cjs/sim/field.d.ts +1 -1
- package/build/cjs/sim/field.js +3 -3
- package/build/cjs/sim/field.js.map +1 -1
- package/build/cjs/sim/global-types.d.ts +1 -9
- package/build/cjs/sim/pokemon.d.ts +14 -25
- package/build/cjs/sim/pokemon.js +21 -22
- package/build/cjs/sim/pokemon.js.map +1 -1
- package/build/cjs/sim/side.d.ts +105 -11
- package/build/cjs/sim/side.js +6 -6
- package/build/cjs/sim/side.js.map +1 -1
- package/build/cjs/sim/state.d.ts +1 -1
- package/build/cjs/sim/state.js +3 -3
- package/build/cjs/sim/state.js.map +1 -1
- package/build/cjs/sim/team-validator.d.ts +2 -1
- package/build/cjs/sim/team-validator.js +37 -27
- package/build/cjs/sim/team-validator.js.map +1 -1
- package/build/cjs/sim/tools/random-player-ai.d.ts +4 -3
- package/build/cjs/sim/tools/random-player-ai.js +6 -7
- package/build/cjs/sim/tools/random-player-ai.js.map +1 -1
- package/build/cjs/sim/tools/runner.d.ts +2 -2
- package/build/cjs/sim/tools/runner.js +1 -1
- package/build/cjs/sim/tools/runner.js.map +1 -1
- package/build/esm/config/formats.mjs +58 -43
- package/build/esm/config/formats.mjs.map +1 -1
- package/build/esm/data/abilities.mjs +41 -41
- package/build/esm/data/abilities.mjs.map +1 -1
- package/build/esm/data/aliases.mjs +2 -2
- package/build/esm/data/aliases.mjs.map +1 -1
- package/build/esm/data/conditions.mjs +20 -20
- package/build/esm/data/conditions.mjs.map +1 -1
- package/build/esm/data/formats-data.mjs +1 -1
- package/build/esm/data/items.mjs +5 -5
- package/build/esm/data/items.mjs.map +1 -1
- package/build/esm/data/mods/gen1/conditions.mjs +1 -2
- package/build/esm/data/mods/gen1/conditions.mjs.map +1 -1
- package/build/esm/data/mods/gen1/moves.mjs +2 -2
- package/build/esm/data/mods/gen1/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen1/pokedex.mjs.map +1 -1
- package/build/esm/data/mods/gen1/scripts.mjs +6 -6
- package/build/esm/data/mods/gen1/scripts.mjs.map +1 -1
- package/build/esm/data/mods/gen2/conditions.mjs +2 -2
- package/build/esm/data/mods/gen2/conditions.mjs.map +1 -1
- package/build/esm/data/mods/gen2/moves.mjs +3 -3
- package/build/esm/data/mods/gen2/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen2/rulesets.mjs.map +1 -1
- package/build/esm/data/mods/gen2/scripts.mjs +2 -2
- package/build/esm/data/mods/gen2/scripts.mjs.map +1 -1
- package/build/esm/data/mods/gen3/abilities.mjs +1 -1
- package/build/esm/data/mods/gen3/abilities.mjs.map +1 -1
- package/build/esm/data/mods/gen3/conditions.mjs +1 -1
- package/build/esm/data/mods/gen3/conditions.mjs.map +1 -1
- package/build/esm/data/mods/gen3/moves.mjs +5 -5
- package/build/esm/data/mods/gen3/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen3/scripts.mjs +2 -2
- package/build/esm/data/mods/gen3/scripts.mjs.map +1 -1
- package/build/esm/data/mods/gen4/abilities.mjs +4 -4
- package/build/esm/data/mods/gen4/abilities.mjs.map +1 -1
- package/build/esm/data/mods/gen4/conditions.mjs +1 -1
- package/build/esm/data/mods/gen4/conditions.mjs.map +1 -1
- package/build/esm/data/mods/gen4/items.mjs +2 -2
- package/build/esm/data/mods/gen4/items.mjs.map +1 -1
- package/build/esm/data/mods/gen4/moves.mjs +22 -22
- package/build/esm/data/mods/gen4/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen4/scripts.mjs +1 -1
- package/build/esm/data/mods/gen4/scripts.mjs.map +1 -1
- package/build/esm/data/mods/gen5/abilities.mjs +1 -1
- package/build/esm/data/mods/gen5/abilities.mjs.map +1 -1
- package/build/esm/data/mods/gen5/conditions.mjs +2 -2
- package/build/esm/data/mods/gen5/conditions.mjs.map +1 -1
- package/build/esm/data/mods/gen5/moves.mjs +6 -6
- package/build/esm/data/mods/gen5/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen5/pokedex.mjs.map +1 -1
- package/build/esm/data/mods/gen6/abilities.mjs +2 -2
- package/build/esm/data/mods/gen6/abilities.mjs.map +1 -1
- package/build/esm/data/mods/gen6/moves.mjs +1 -1
- package/build/esm/data/mods/gen6/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen6/pokedex.mjs.map +1 -1
- package/build/esm/data/mods/gen7/abilities.mjs.map +1 -1
- package/build/esm/data/mods/gen7/moves.mjs +8 -8
- package/build/esm/data/mods/gen7/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen7/pokedex.mjs.map +1 -1
- package/build/esm/data/mods/gen8/abilities.mjs.map +1 -1
- package/build/esm/data/mods/gen8/moves.mjs.map +1 -1
- package/build/esm/data/mods/gen8/pokedex.mjs.map +1 -1
- package/build/esm/data/moves.mjs +105 -103
- package/build/esm/data/moves.mjs.map +1 -1
- package/build/esm/data/pokedex.mjs.map +1 -1
- package/build/esm/data/pokemongo.mjs.map +1 -1
- package/build/esm/data/rulesets.mjs +0 -1
- package/build/esm/data/rulesets.mjs.map +1 -1
- package/build/esm/data/tags.mjs.map +1 -1
- package/build/esm/data/text/abilities.mjs.map +1 -1
- package/build/esm/data/text/default.mjs.map +1 -1
- package/build/esm/data/text/items.mjs.map +1 -1
- package/build/esm/data/text/moves.mjs.map +1 -1
- package/build/esm/data/typechart.mjs.map +1 -1
- package/build/esm/lib/utils.d.mts +5 -5
- package/build/esm/lib/utils.mjs +21 -11
- package/build/esm/lib/utils.mjs.map +1 -1
- package/build/esm/sim/battle-actions.mjs +8 -8
- package/build/esm/sim/battle-actions.mjs.map +1 -1
- package/build/esm/sim/battle-queue.mjs +0 -1
- package/build/esm/sim/battle-queue.mjs.map +1 -1
- package/build/esm/sim/battle-stream.d.mts +3 -2
- package/build/esm/sim/battle-stream.mjs +1 -1
- package/build/esm/sim/battle-stream.mjs.map +1 -1
- package/build/esm/sim/battle.d.mts +8 -8
- package/build/esm/sim/battle.mjs +41 -44
- package/build/esm/sim/battle.mjs.map +1 -1
- package/build/esm/sim/dex-abilities.mjs.map +1 -1
- package/build/esm/sim/dex-conditions.mjs +2 -2
- package/build/esm/sim/dex-conditions.mjs.map +1 -1
- package/build/esm/sim/dex-data.mjs +1 -1
- package/build/esm/sim/dex-data.mjs.map +1 -1
- package/build/esm/sim/dex-formats.d.mts +1 -0
- package/build/esm/sim/dex-formats.mjs +95 -37
- package/build/esm/sim/dex-formats.mjs.map +1 -1
- package/build/esm/sim/dex-items.mjs.map +1 -1
- package/build/esm/sim/dex-moves.mjs +2 -3
- package/build/esm/sim/dex-moves.mjs.map +1 -1
- package/build/esm/sim/exported-global-types.d.mts +1 -9
- package/build/esm/sim/field.d.mts +1 -1
- package/build/esm/sim/field.mjs +3 -3
- package/build/esm/sim/field.mjs.map +1 -1
- package/build/esm/sim/global-types.d.mts +1 -9
- package/build/esm/sim/pokemon.d.mts +14 -25
- package/build/esm/sim/pokemon.mjs +21 -22
- package/build/esm/sim/pokemon.mjs.map +1 -1
- package/build/esm/sim/side.d.mts +105 -11
- package/build/esm/sim/side.mjs +6 -6
- package/build/esm/sim/side.mjs.map +1 -1
- package/build/esm/sim/state.d.mts +1 -1
- package/build/esm/sim/state.mjs +3 -3
- package/build/esm/sim/state.mjs.map +1 -1
- package/build/esm/sim/team-validator.d.mts +2 -1
- package/build/esm/sim/team-validator.mjs +37 -27
- package/build/esm/sim/team-validator.mjs.map +1 -1
- package/build/esm/sim/tools/random-player-ai.d.mts +4 -3
- package/build/esm/sim/tools/random-player-ai.mjs +6 -7
- package/build/esm/sim/tools/random-player-ai.mjs.map +1 -1
- package/build/esm/sim/tools/runner.d.mts +2 -2
- package/build/esm/sim/tools/runner.mjs +1 -1
- package/build/esm/sim/tools/runner.mjs.map +1 -1
- package/package.json +1 -1
package/build/esm/sim/battle.mjs
CHANGED
|
@@ -348,7 +348,7 @@ export class Battle {
|
|
|
348
348
|
if (!(handler.state?.isSlotCondition))
|
|
349
349
|
continue;
|
|
350
350
|
}
|
|
351
|
-
if (eventid === 'Residual' && handler.end && handler.state
|
|
351
|
+
if (eventid === 'Residual' && handler.end && handler.state?.duration) {
|
|
352
352
|
handler.state.duration--;
|
|
353
353
|
if (!handler.state.duration) {
|
|
354
354
|
const endCallArgs = handler.endCallArgs || [handler.effectHolder, effect.id];
|
|
@@ -564,7 +564,6 @@ export class Battle {
|
|
|
564
564
|
if (onEffect) {
|
|
565
565
|
if (!sourceEffect)
|
|
566
566
|
throw new Error("onEffect passed without an effect");
|
|
567
|
-
// @ts-ignore - dynamic lookup
|
|
568
567
|
const callback = sourceEffect[`on${eventid}`];
|
|
569
568
|
if (callback !== undefined) {
|
|
570
569
|
if (Array.isArray(target))
|
|
@@ -733,11 +732,8 @@ export class Battle {
|
|
|
733
732
|
}
|
|
734
733
|
resolvePriority(h, callbackName) {
|
|
735
734
|
const handler = h;
|
|
736
|
-
// @ts-ignore
|
|
737
735
|
handler.order = handler.effect[`${callbackName}Order`] || false;
|
|
738
|
-
// @ts-ignore
|
|
739
736
|
handler.priority = handler.effect[`${callbackName}Priority`] || 0;
|
|
740
|
-
// @ts-ignore
|
|
741
737
|
handler.subOrder = handler.effect[`${callbackName}SubOrder`] || 0;
|
|
742
738
|
if (!handler.subOrder) {
|
|
743
739
|
// https://www.smogon.com/forums/threads/sword-shield-battle-mechanics-research.3655528/page-59#post-8685465
|
|
@@ -806,7 +802,7 @@ export class Battle {
|
|
|
806
802
|
let handlers = [];
|
|
807
803
|
if (Array.isArray(target)) {
|
|
808
804
|
for (const [i, pokemon] of target.entries()) {
|
|
809
|
-
// console.log(`Event: ${eventName}, Target: ${
|
|
805
|
+
// console.log(`Event: ${eventName}, Target: ${pokemon}, ${i}`);
|
|
810
806
|
const curHandlers = this.findEventHandlers(pokemon, eventName, source);
|
|
811
807
|
for (const handler of curHandlers) {
|
|
812
808
|
handler.target = pokemon; // Original "effectHolder"
|
|
@@ -856,7 +852,7 @@ export class Battle {
|
|
|
856
852
|
findPokemonEventHandlers(pokemon, callbackName, getKey) {
|
|
857
853
|
const handlers = [];
|
|
858
854
|
const status = pokemon.getStatus();
|
|
859
|
-
// @ts-
|
|
855
|
+
// @ts-expect-error dynamic lookup
|
|
860
856
|
let callback = status[callbackName];
|
|
861
857
|
if (callback !== undefined || (getKey && pokemon.statusState[getKey])) {
|
|
862
858
|
handlers.push(this.resolvePriority({
|
|
@@ -866,7 +862,7 @@ export class Battle {
|
|
|
866
862
|
for (const id in pokemon.volatiles) {
|
|
867
863
|
const volatileState = pokemon.volatiles[id];
|
|
868
864
|
const volatile = this.dex.conditions.getByID(id);
|
|
869
|
-
// @ts-
|
|
865
|
+
// @ts-expect-error dynamic lookup
|
|
870
866
|
callback = volatile[callbackName];
|
|
871
867
|
if (callback !== undefined || (getKey && volatileState[getKey])) {
|
|
872
868
|
handlers.push(this.resolvePriority({
|
|
@@ -875,7 +871,7 @@ export class Battle {
|
|
|
875
871
|
}
|
|
876
872
|
else if (['ability', 'item'].includes(volatile.id.split(':')[0])) {
|
|
877
873
|
// Innate abilities/items; see comment below
|
|
878
|
-
// @ts-
|
|
874
|
+
// @ts-expect-error dynamic lookup
|
|
879
875
|
if (this.gen >= 5 && callbackName === 'onSwitchIn' && !volatile.onAnySwitchIn) {
|
|
880
876
|
callback = volatile.onStart;
|
|
881
877
|
if (callback !== undefined || (getKey && volatileState[getKey])) {
|
|
@@ -890,16 +886,16 @@ export class Battle {
|
|
|
890
886
|
// during the SwitchIn event instead of running the Start event during switch-ins
|
|
891
887
|
// gens 4 and before still use the old system, though
|
|
892
888
|
const ability = pokemon.getAbility();
|
|
893
|
-
// @ts-
|
|
889
|
+
// @ts-expect-error dynamic lookup
|
|
894
890
|
callback = ability[callbackName];
|
|
895
891
|
if (callback !== undefined || (getKey && pokemon.abilityState[getKey])) {
|
|
896
892
|
handlers.push(this.resolvePriority({
|
|
897
893
|
effect: ability, callback, state: pokemon.abilityState, end: pokemon.clearAbility, effectHolder: pokemon,
|
|
898
894
|
}, callbackName));
|
|
899
|
-
// @ts-
|
|
895
|
+
// @ts-expect-error dynamic lookup
|
|
900
896
|
}
|
|
901
897
|
else if (this.gen >= 5 && callbackName === 'onSwitchIn' && !ability.onAnySwitchIn) {
|
|
902
|
-
// @ts-
|
|
898
|
+
// @ts-expect-error dynamic lookup
|
|
903
899
|
callback = ability.onStart;
|
|
904
900
|
if (callback !== undefined || (getKey && pokemon.abilityState[getKey])) {
|
|
905
901
|
handlers.push(this.resolvePriority({
|
|
@@ -908,16 +904,15 @@ export class Battle {
|
|
|
908
904
|
}
|
|
909
905
|
}
|
|
910
906
|
const item = pokemon.getItem();
|
|
911
|
-
// @ts-
|
|
907
|
+
// @ts-expect-error dynamic lookup
|
|
912
908
|
callback = item[callbackName];
|
|
913
909
|
if (callback !== undefined || (getKey && pokemon.itemState[getKey])) {
|
|
914
910
|
handlers.push(this.resolvePriority({
|
|
915
911
|
effect: item, callback, state: pokemon.itemState, end: pokemon.clearItem, effectHolder: pokemon,
|
|
916
912
|
}, callbackName));
|
|
917
|
-
// @ts-
|
|
913
|
+
// @ts-expect-error dynamic lookup
|
|
918
914
|
}
|
|
919
915
|
else if (this.gen >= 5 && callbackName === 'onSwitchIn' && !item.onAnySwitchIn) {
|
|
920
|
-
// @ts-ignore - dynamic lookup
|
|
921
916
|
callback = item.onStart;
|
|
922
917
|
if (callback !== undefined || (getKey && pokemon.itemState[getKey])) {
|
|
923
918
|
handlers.push(this.resolvePriority({
|
|
@@ -926,7 +921,7 @@ export class Battle {
|
|
|
926
921
|
}
|
|
927
922
|
}
|
|
928
923
|
const species = pokemon.baseSpecies;
|
|
929
|
-
// @ts-
|
|
924
|
+
// @ts-expect-error dynamic lookup
|
|
930
925
|
callback = species[callbackName];
|
|
931
926
|
if (callback !== undefined) {
|
|
932
927
|
handlers.push(this.resolvePriority({
|
|
@@ -937,7 +932,7 @@ export class Battle {
|
|
|
937
932
|
for (const conditionid in side.slotConditions[pokemon.position]) {
|
|
938
933
|
const slotConditionState = side.slotConditions[pokemon.position][conditionid];
|
|
939
934
|
const slotCondition = this.dex.conditions.getByID(conditionid);
|
|
940
|
-
// @ts-
|
|
935
|
+
// @ts-expect-error dynamic lookup
|
|
941
936
|
callback = slotCondition[callbackName];
|
|
942
937
|
if (callback !== undefined || (getKey && slotConditionState[getKey])) {
|
|
943
938
|
handlers.push(this.resolvePriority({
|
|
@@ -956,7 +951,7 @@ export class Battle {
|
|
|
956
951
|
const handlers = [];
|
|
957
952
|
let callback;
|
|
958
953
|
const format = this.format;
|
|
959
|
-
// @ts-
|
|
954
|
+
// @ts-expect-error dynamic lookup
|
|
960
955
|
callback = format[callbackName];
|
|
961
956
|
if (callback !== undefined || (getKey && this.formatData[getKey])) {
|
|
962
957
|
handlers.push(this.resolvePriority({
|
|
@@ -980,7 +975,7 @@ export class Battle {
|
|
|
980
975
|
for (const id in field.pseudoWeather) {
|
|
981
976
|
const pseudoWeatherState = field.pseudoWeather[id];
|
|
982
977
|
const pseudoWeather = this.dex.conditions.getByID(id);
|
|
983
|
-
// @ts-
|
|
978
|
+
// @ts-expect-error dynamic lookup
|
|
984
979
|
callback = pseudoWeather[callbackName];
|
|
985
980
|
if (callback !== undefined || (getKey && pseudoWeatherState[getKey])) {
|
|
986
981
|
handlers.push(this.resolvePriority({
|
|
@@ -990,7 +985,7 @@ export class Battle {
|
|
|
990
985
|
}
|
|
991
986
|
}
|
|
992
987
|
const weather = field.getWeather();
|
|
993
|
-
// @ts-
|
|
988
|
+
// @ts-expect-error dynamic lookup
|
|
994
989
|
callback = weather[callbackName];
|
|
995
990
|
if (callback !== undefined || (getKey && this.field.weatherState[getKey])) {
|
|
996
991
|
handlers.push(this.resolvePriority({
|
|
@@ -999,7 +994,7 @@ export class Battle {
|
|
|
999
994
|
}, callbackName));
|
|
1000
995
|
}
|
|
1001
996
|
const terrain = field.getTerrain();
|
|
1002
|
-
// @ts-
|
|
997
|
+
// @ts-expect-error dynamic lookup
|
|
1003
998
|
callback = terrain[callbackName];
|
|
1004
999
|
if (callback !== undefined || (getKey && field.terrainState[getKey])) {
|
|
1005
1000
|
handlers.push(this.resolvePriority({
|
|
@@ -1014,7 +1009,7 @@ export class Battle {
|
|
|
1014
1009
|
for (const id in side.sideConditions) {
|
|
1015
1010
|
const sideConditionData = side.sideConditions[id];
|
|
1016
1011
|
const sideCondition = this.dex.conditions.getByID(id);
|
|
1017
|
-
// @ts-
|
|
1012
|
+
// @ts-expect-error dynamic lookup
|
|
1018
1013
|
const callback = sideCondition[callbackName];
|
|
1019
1014
|
if (callback !== undefined || (getKey && sideConditionData[getKey])) {
|
|
1020
1015
|
handlers.push(this.resolvePriority({
|
|
@@ -1140,7 +1135,7 @@ export class Battle {
|
|
|
1140
1135
|
// the entire team order, unlike `pickedTeamSize = undefined` which
|
|
1141
1136
|
// will only ask the user to select their lead(s).
|
|
1142
1137
|
const pickedTeamSize = this.ruleTable.pickedTeamSize;
|
|
1143
|
-
this.add(
|
|
1138
|
+
this.add(`teampreview${pickedTeamSize ? `|${pickedTeamSize}` : ''}`);
|
|
1144
1139
|
}
|
|
1145
1140
|
const requests = this.getRequests(type);
|
|
1146
1141
|
for (let i = 0; i < this.sides.length; i++) {
|
|
@@ -1833,10 +1828,10 @@ export class Battle {
|
|
|
1833
1828
|
this.add('-damage', target, target.getHealth);
|
|
1834
1829
|
}
|
|
1835
1830
|
else if (source && (source !== target || effect.effectType === 'Ability')) {
|
|
1836
|
-
this.add('-damage', target, target.getHealth,
|
|
1831
|
+
this.add('-damage', target, target.getHealth, `[from] ${name}`, `[of] ${source}`);
|
|
1837
1832
|
}
|
|
1838
1833
|
else {
|
|
1839
|
-
this.add('-damage', target, target.getHealth,
|
|
1834
|
+
this.add('-damage', target, target.getHealth, `[from] ${name}`);
|
|
1840
1835
|
}
|
|
1841
1836
|
break;
|
|
1842
1837
|
}
|
|
@@ -1865,7 +1860,7 @@ export class Battle {
|
|
|
1865
1860
|
if (!retVals[i] || !target)
|
|
1866
1861
|
continue;
|
|
1867
1862
|
if (target.hp <= 0) {
|
|
1868
|
-
this.debug(
|
|
1863
|
+
this.debug(`instafaint: ${this.faintQueue.map(entry => entry.target.name)}`);
|
|
1869
1864
|
this.faintMessages(true);
|
|
1870
1865
|
if (this.gen <= 2) {
|
|
1871
1866
|
target.faint();
|
|
@@ -1873,7 +1868,7 @@ export class Battle {
|
|
|
1873
1868
|
this.queue.clear();
|
|
1874
1869
|
// Fainting clears accumulated Bide damage
|
|
1875
1870
|
for (const pokemon of this.getAllActive()) {
|
|
1876
|
-
if (pokemon.volatiles['bide']
|
|
1871
|
+
if (pokemon.volatiles['bide']?.damage) {
|
|
1877
1872
|
pokemon.volatiles['bide'].damage = 0;
|
|
1878
1873
|
this.hint("Desync Clause Mod activated!");
|
|
1879
1874
|
this.hint("In Gen 1, Bide's accumulated damage is reset to 0 when a Pokemon faints.");
|
|
@@ -1978,7 +1973,7 @@ export class Battle {
|
|
|
1978
1973
|
this.add('-heal', target, target.getHealth, '[silent]');
|
|
1979
1974
|
break;
|
|
1980
1975
|
case 'drain':
|
|
1981
|
-
this.add('-heal', target, target.getHealth, '[from] drain',
|
|
1976
|
+
this.add('-heal', target, target.getHealth, '[from] drain', `[of] ${source}`);
|
|
1982
1977
|
break;
|
|
1983
1978
|
case 'wish':
|
|
1984
1979
|
break;
|
|
@@ -1992,10 +1987,10 @@ export class Battle {
|
|
|
1992
1987
|
this.add('-heal', target, target.getHealth);
|
|
1993
1988
|
}
|
|
1994
1989
|
else if (source && source !== target) {
|
|
1995
|
-
this.add('-heal', target, target.getHealth,
|
|
1990
|
+
this.add('-heal', target, target.getHealth, `[from] ${effect.fullname}`, `[of] ${source}`);
|
|
1996
1991
|
}
|
|
1997
1992
|
else {
|
|
1998
|
-
this.add('-heal', target, target.getHealth,
|
|
1993
|
+
this.add('-heal', target, target.getHealth, `[from] ${effect.fullname}`);
|
|
1999
1994
|
}
|
|
2000
1995
|
break;
|
|
2001
1996
|
}
|
|
@@ -2130,7 +2125,7 @@ export class Battle {
|
|
|
2130
2125
|
// we need to manually check for Stalwart here
|
|
2131
2126
|
if (pokemon.hasAbility(['stalwart', 'propellertail']))
|
|
2132
2127
|
tracksTarget = true;
|
|
2133
|
-
if (tracksTarget && originalTarget
|
|
2128
|
+
if (tracksTarget && originalTarget?.isActive) {
|
|
2134
2129
|
// smart-tracking move's original target is on the field: target it
|
|
2135
2130
|
return originalTarget;
|
|
2136
2131
|
}
|
|
@@ -2231,8 +2226,7 @@ export class Battle {
|
|
|
2231
2226
|
faintQueueLeft = this.faintQueue.length;
|
|
2232
2227
|
faintData = this.faintQueue.shift();
|
|
2233
2228
|
const pokemon = faintData.target;
|
|
2234
|
-
if (!pokemon.fainted &&
|
|
2235
|
-
this.runEvent('BeforeFaint', pokemon, faintData.source, faintData.effect)) {
|
|
2229
|
+
if (!pokemon.fainted && this.runEvent('BeforeFaint', pokemon, faintData.source, faintData.effect)) {
|
|
2236
2230
|
this.add('faint', pokemon);
|
|
2237
2231
|
if (pokemon.side.pokemonLeft)
|
|
2238
2232
|
pokemon.side.pokemonLeft--;
|
|
@@ -2268,7 +2262,7 @@ export class Battle {
|
|
|
2268
2262
|
this.queue.clear();
|
|
2269
2263
|
// Fainting clears accumulated Bide damage
|
|
2270
2264
|
for (const pokemon of this.getAllActive()) {
|
|
2271
|
-
if (pokemon.volatiles['bide']
|
|
2265
|
+
if (pokemon.volatiles['bide']?.damage) {
|
|
2272
2266
|
pokemon.volatiles['bide'].damage = 0;
|
|
2273
2267
|
this.hint("Desync Clause Mod activated!");
|
|
2274
2268
|
this.hint("In Gen 1, Bide's accumulated damage is reset to 0 when a Pokemon faints.");
|
|
@@ -2388,8 +2382,8 @@ export class Battle {
|
|
|
2388
2382
|
pokemon.baseMoveSlots[ironHead] = {
|
|
2389
2383
|
move: move.name,
|
|
2390
2384
|
id: move.id,
|
|
2391
|
-
pp:
|
|
2392
|
-
maxpp:
|
|
2385
|
+
pp: move.noPPBoosts ? move.pp : move.pp * 8 / 5,
|
|
2386
|
+
maxpp: move.noPPBoosts ? move.pp : move.pp * 8 / 5,
|
|
2393
2387
|
target: move.target,
|
|
2394
2388
|
disabled: false,
|
|
2395
2389
|
disabledSource: '',
|
|
@@ -2548,7 +2542,8 @@ export class Battle {
|
|
|
2548
2542
|
this.updateSpeed();
|
|
2549
2543
|
residualPokemon = this.getAllActive().map(pokemon => [pokemon, pokemon.getUndynamaxedHP()]);
|
|
2550
2544
|
this.fieldEvent('Residual');
|
|
2551
|
-
this.
|
|
2545
|
+
if (!this.ended)
|
|
2546
|
+
this.add('upkeep');
|
|
2552
2547
|
break;
|
|
2553
2548
|
}
|
|
2554
2549
|
// phazing (Roar, etc)
|
|
@@ -2818,6 +2813,7 @@ export class Battle {
|
|
|
2818
2813
|
}
|
|
2819
2814
|
addMove(...args) {
|
|
2820
2815
|
this.lastMoveLine = this.log.length;
|
|
2816
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
2821
2817
|
this.log.push(`|${args.join('|')}`);
|
|
2822
2818
|
}
|
|
2823
2819
|
attrLastMove(...args) {
|
|
@@ -2836,6 +2832,7 @@ export class Battle {
|
|
|
2836
2832
|
parts[4] = '';
|
|
2837
2833
|
this.log[this.lastMoveLine] = parts.join('|');
|
|
2838
2834
|
}
|
|
2835
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
2839
2836
|
this.log[this.lastMoveLine] += `|${args.join('|')}`;
|
|
2840
2837
|
}
|
|
2841
2838
|
retargetLastMove(newTarget) {
|
|
@@ -2929,7 +2926,7 @@ export class Battle {
|
|
|
2929
2926
|
const team = this.getTeam(options);
|
|
2930
2927
|
side = new Side(options.name || `Player ${slotNum + 1}`, this, slotNum, team);
|
|
2931
2928
|
if (options.avatar)
|
|
2932
|
-
side.avatar =
|
|
2929
|
+
side.avatar = `${options.avatar}`;
|
|
2933
2930
|
this.sides[slotNum] = side;
|
|
2934
2931
|
}
|
|
2935
2932
|
else {
|
|
@@ -2940,8 +2937,8 @@ export class Battle {
|
|
|
2940
2937
|
side.name = options.name;
|
|
2941
2938
|
didSomething = true;
|
|
2942
2939
|
}
|
|
2943
|
-
if (options.avatar && side.avatar !==
|
|
2944
|
-
side.avatar =
|
|
2940
|
+
if (options.avatar && side.avatar !== `${options.avatar}`) {
|
|
2941
|
+
side.avatar = `${options.avatar}`;
|
|
2945
2942
|
didSomething = true;
|
|
2946
2943
|
}
|
|
2947
2944
|
if (options.team)
|
|
@@ -2975,12 +2972,12 @@ export class Battle {
|
|
|
2975
2972
|
turns: this.turn,
|
|
2976
2973
|
p1: this.sides[0].name,
|
|
2977
2974
|
p2: this.sides[1].name,
|
|
2978
|
-
p3: this.sides[2]
|
|
2979
|
-
p4: this.sides[3]
|
|
2975
|
+
p3: this.sides[2]?.name,
|
|
2976
|
+
p4: this.sides[3]?.name,
|
|
2980
2977
|
p1team: this.sides[0].team,
|
|
2981
2978
|
p2team: this.sides[1].team,
|
|
2982
|
-
p3team: this.sides[2]
|
|
2983
|
-
p4team: this.sides[3]
|
|
2979
|
+
p3team: this.sides[2]?.team,
|
|
2980
|
+
p4team: this.sides[3]?.team,
|
|
2984
2981
|
score: [this.sides[0].pokemonLeft, this.sides[1].pokemonLeft],
|
|
2985
2982
|
inputLog: this.inputLog,
|
|
2986
2983
|
};
|