mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-27 17:26:11 +00:00
[Beta][P2] Several Unburden bug fixes (#4820)
* [P2][Beta] Several Unburden bug fixes * Unburden test adjustments * Some further test cleanup * Add suggested `.bypassFaint()` to Unburden --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
2968059814
commit
63ffab027d
@ -2572,14 +2572,15 @@ export default class BattleScene extends SceneBase {
|
|||||||
* The quantity to transfer is automatically capped at how much the recepient can take before reaching the maximum stack size for the item.
|
* The quantity to transfer is automatically capped at how much the recepient can take before reaching the maximum stack size for the item.
|
||||||
* A transfer that moves a quantity smaller than what is specified in the transferQuantity parameter is still considered successful.
|
* A transfer that moves a quantity smaller than what is specified in the transferQuantity parameter is still considered successful.
|
||||||
* @param itemModifier {@linkcode PokemonHeldItemModifier} item to transfer (represents the whole stack)
|
* @param itemModifier {@linkcode PokemonHeldItemModifier} item to transfer (represents the whole stack)
|
||||||
* @param target {@linkcode Pokemon} pokemon recepient in this transfer
|
* @param target {@linkcode Pokemon} recepient in this transfer
|
||||||
* @param playSound {boolean}
|
* @param playSound `true` to play a sound when transferring the item
|
||||||
* @param transferQuantity {@linkcode integer} how many items of the stack to transfer. Optional, defaults to 1
|
* @param transferQuantity How many items of the stack to transfer. Optional, defaults to `1`
|
||||||
* @param instant {boolean}
|
* @param instant ??? (Optional)
|
||||||
* @param ignoreUpdate {boolean}
|
* @param ignoreUpdate ??? (Optional)
|
||||||
* @returns true if the transfer was successful
|
* @param itemLost If `true`, treat the item's current holder as losing the item (for now, this simply enables Unburden). Default is `true`.
|
||||||
|
* @returns `true` if the transfer was successful
|
||||||
*/
|
*/
|
||||||
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: integer = 1, instant?: boolean, ignoreUpdate?: boolean): Promise<boolean> {
|
tryTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, transferQuantity: number = 1, instant?: boolean, ignoreUpdate?: boolean, itemLost: boolean = true): Promise<boolean> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null;
|
const source = itemModifier.pokemonId ? itemModifier.getPokemon(target.scene) : null;
|
||||||
const cancelled = new Utils.BooleanHolder(false);
|
const cancelled = new Utils.BooleanHolder(false);
|
||||||
@ -2612,14 +2613,14 @@ export default class BattleScene extends SceneBase {
|
|||||||
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
|
if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) {
|
||||||
if (target.isPlayer()) {
|
if (target.isPlayer()) {
|
||||||
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => {
|
this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant).then(() => {
|
||||||
if (source) {
|
if (source && itemLost) {
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => {
|
this.addEnemyModifier(newItemModifier, ignoreUpdate, instant).then(() => {
|
||||||
if (source) {
|
if (source && itemLost) {
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false);
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@ -2791,7 +2792,15 @@ export default class BattleScene extends SceneBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
removeModifier(modifier: PersistentModifier, enemy?: boolean): boolean {
|
/**
|
||||||
|
* Removes a currently owned item. If the item is stacked, the entire item stack
|
||||||
|
* gets removed. This function does NOT apply in-battle effects, such as Unburden.
|
||||||
|
* If in-battle effects are needed, use {@linkcode Pokemon.loseHeldItem} instead.
|
||||||
|
* @param modifier The item to be removed.
|
||||||
|
* @param enemy If `true`, remove an item owned by the enemy. If `false`, remove an item owned by the player. Default is `false`.
|
||||||
|
* @returns `true` if the item exists and was successfully removed, `false` otherwise.
|
||||||
|
*/
|
||||||
|
removeModifier(modifier: PersistentModifier, enemy: boolean = false): boolean {
|
||||||
const modifiers = !enemy ? this.modifiers : this.enemyModifiers;
|
const modifiers = !enemy ? this.modifiers : this.enemyModifiers;
|
||||||
const modifierIndex = modifiers.indexOf(modifier);
|
const modifierIndex = modifiers.indexOf(modifier);
|
||||||
if (modifierIndex > -1) {
|
if (modifierIndex > -1) {
|
||||||
|
@ -4152,7 +4152,7 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
|||||||
if (!simulated && postBattleLoot.length) {
|
if (!simulated && postBattleLoot.length) {
|
||||||
const randItem = Utils.randSeedItem(postBattleLoot);
|
const randItem = Utils.randSeedItem(postBattleLoot);
|
||||||
//@ts-ignore - TODO see below
|
//@ts-ignore - TODO see below
|
||||||
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true)) { // TODO: fix. This is a promise!?
|
if (pokemon.scene.tryTransferHeldItemModifier(randItem, pokemon, true, 1, true, undefined, false)) { // TODO: fix. This is a promise!?
|
||||||
postBattleLoot.splice(postBattleLoot.indexOf(randItem), 1);
|
postBattleLoot.splice(postBattleLoot.indexOf(randItem), 1);
|
||||||
pokemon.scene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
|
pokemon.scene.queueMessage(i18next.t("abilityTriggers:postBattleLoot", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), itemName: randItem.type.name }));
|
||||||
return true;
|
return true;
|
||||||
@ -5616,7 +5616,9 @@ export function initAbilities() {
|
|||||||
new Ability(Abilities.ANGER_POINT, 4)
|
new Ability(Abilities.ANGER_POINT, 4)
|
||||||
.attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6),
|
.attr(PostDefendCritStatStageChangeAbAttr, Stat.ATK, 6),
|
||||||
new Ability(Abilities.UNBURDEN, 4)
|
new Ability(Abilities.UNBURDEN, 4)
|
||||||
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN),
|
.attr(PostItemLostApplyBattlerTagAbAttr, BattlerTagType.UNBURDEN)
|
||||||
|
.bypassFaint() // Allows reviver seed to activate Unburden
|
||||||
|
.edgeCase(), // Should not restore Unburden boost if Pokemon loses then regains Unburden ability
|
||||||
new Ability(Abilities.HEATPROOF, 4)
|
new Ability(Abilities.HEATPROOF, 4)
|
||||||
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
|
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
|
||||||
.attr(ReduceBurnDamageAbAttr, 0.5)
|
.attr(ReduceBurnDamageAbAttr, 0.5)
|
||||||
|
@ -61,13 +61,13 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BerryEffectFunc = (pokemon: Pokemon) => void;
|
export type BerryEffectFunc = (pokemon: Pokemon, berryOwner?: Pokemon) => void;
|
||||||
|
|
||||||
export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||||
switch (berryType) {
|
switch (berryType) {
|
||||||
case BerryType.SITRUS:
|
case BerryType.SITRUS:
|
||||||
case BerryType.ENIGMA:
|
case BerryType.ENIGMA:
|
||||||
return (pokemon: Pokemon) => {
|
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||||
if (pokemon.battleData) {
|
if (pokemon.battleData) {
|
||||||
pokemon.battleData.berriesEaten.push(berryType);
|
pokemon.battleData.berriesEaten.push(berryType);
|
||||||
}
|
}
|
||||||
@ -75,10 +75,10 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed);
|
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed);
|
||||||
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
|
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, pokemon.getBattlerIndex(),
|
||||||
hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true));
|
hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true));
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||||
};
|
};
|
||||||
case BerryType.LUM:
|
case BerryType.LUM:
|
||||||
return (pokemon: Pokemon) => {
|
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||||
if (pokemon.battleData) {
|
if (pokemon.battleData) {
|
||||||
pokemon.battleData.berriesEaten.push(berryType);
|
pokemon.battleData.berriesEaten.push(berryType);
|
||||||
}
|
}
|
||||||
@ -87,14 +87,14 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||||||
}
|
}
|
||||||
pokemon.resetStatus(true, true);
|
pokemon.resetStatus(true, true);
|
||||||
pokemon.updateInfo();
|
pokemon.updateInfo();
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||||
};
|
};
|
||||||
case BerryType.LIECHI:
|
case BerryType.LIECHI:
|
||||||
case BerryType.GANLON:
|
case BerryType.GANLON:
|
||||||
case BerryType.PETAYA:
|
case BerryType.PETAYA:
|
||||||
case BerryType.APICOT:
|
case BerryType.APICOT:
|
||||||
case BerryType.SALAC:
|
case BerryType.SALAC:
|
||||||
return (pokemon: Pokemon) => {
|
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||||
if (pokemon.battleData) {
|
if (pokemon.battleData) {
|
||||||
pokemon.battleData.berriesEaten.push(berryType);
|
pokemon.battleData.berriesEaten.push(berryType);
|
||||||
}
|
}
|
||||||
@ -103,18 +103,18 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||||||
const statStages = new Utils.NumberHolder(1);
|
const statStages = new Utils.NumberHolder(1);
|
||||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statStages);
|
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statStages);
|
||||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], statStages.value));
|
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ stat ], statStages.value));
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||||
};
|
};
|
||||||
case BerryType.LANSAT:
|
case BerryType.LANSAT:
|
||||||
return (pokemon: Pokemon) => {
|
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||||
if (pokemon.battleData) {
|
if (pokemon.battleData) {
|
||||||
pokemon.battleData.berriesEaten.push(berryType);
|
pokemon.battleData.berriesEaten.push(berryType);
|
||||||
}
|
}
|
||||||
pokemon.addTag(BattlerTagType.CRIT_BOOST);
|
pokemon.addTag(BattlerTagType.CRIT_BOOST);
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||||
};
|
};
|
||||||
case BerryType.STARF:
|
case BerryType.STARF:
|
||||||
return (pokemon: Pokemon) => {
|
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||||
if (pokemon.battleData) {
|
if (pokemon.battleData) {
|
||||||
pokemon.battleData.berriesEaten.push(berryType);
|
pokemon.battleData.berriesEaten.push(berryType);
|
||||||
}
|
}
|
||||||
@ -122,10 +122,10 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||||||
const stages = new Utils.NumberHolder(2);
|
const stages = new Utils.NumberHolder(2);
|
||||||
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, stages);
|
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, stages);
|
||||||
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ randStat ], stages.value));
|
pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ randStat ], stages.value));
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||||
};
|
};
|
||||||
case BerryType.LEPPA:
|
case BerryType.LEPPA:
|
||||||
return (pokemon: Pokemon) => {
|
return (pokemon: Pokemon, berryOwner?: Pokemon) => {
|
||||||
if (pokemon.battleData) {
|
if (pokemon.battleData) {
|
||||||
pokemon.battleData.berriesEaten.push(berryType);
|
pokemon.battleData.berriesEaten.push(berryType);
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
|||||||
if (ppRestoreMove !== undefined) {
|
if (ppRestoreMove !== undefined) {
|
||||||
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
|
ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0);
|
||||||
pokemon.scene.queueMessage(i18next.t("battle:ppHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: ppRestoreMove!.getName(), berryName: getBerryName(berryType) }));
|
pokemon.scene.queueMessage(i18next.t("battle:ppHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: ppRestoreMove!.getName(), berryName: getBerryName(berryType) }));
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false);
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2417,9 +2417,8 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
|
|||||||
const removedItem = heldItems[user.randSeedInt(heldItems.length)];
|
const removedItem = heldItems[user.randSeedInt(heldItems.length)];
|
||||||
|
|
||||||
// Decrease item amount and update icon
|
// Decrease item amount and update icon
|
||||||
!--removedItem.stackCount;
|
target.loseHeldItem(removedItem);
|
||||||
target.scene.updateModifiers(target.isPlayer());
|
target.scene.updateModifiers(target.isPlayer());
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false);
|
|
||||||
|
|
||||||
|
|
||||||
if (this.berriesOnly) {
|
if (this.berriesOnly) {
|
||||||
@ -2489,18 +2488,15 @@ export class EatBerryAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reduceBerryModifier(target: Pokemon) {
|
reduceBerryModifier(target: Pokemon) {
|
||||||
if (this.chosenBerry?.stackCount === 1) {
|
if (this.chosenBerry) {
|
||||||
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
|
target.loseHeldItem(this.chosenBerry);
|
||||||
} else if (this.chosenBerry !== undefined && this.chosenBerry.stackCount > 1) {
|
|
||||||
this.chosenBerry.stackCount--;
|
|
||||||
}
|
}
|
||||||
target.scene.updateModifiers(target.isPlayer());
|
target.scene.updateModifiers(target.isPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
eatBerry(consumer: Pokemon) {
|
eatBerry(consumer: Pokemon, berryOwner?: Pokemon) {
|
||||||
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer); // consumer eats the berry
|
getBerryEffectFunc(this.chosenBerry!.berryType)(consumer, berryOwner); // consumer eats the berry
|
||||||
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
|
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
|
||||||
applyPostItemLostAbAttrs(PostItemLostAbAttr, consumer, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2540,7 +2536,7 @@ export class StealEatBerryAttr extends EatBerryAttr {
|
|||||||
const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name });
|
const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name });
|
||||||
user.scene.queueMessage(message);
|
user.scene.queueMessage(message);
|
||||||
this.reduceBerryModifier(target);
|
this.reduceBerryModifier(target);
|
||||||
this.eatBerry(user);
|
this.eatBerry(user, target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -477,12 +477,9 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
|
|||||||
.withOptionPhase(async (scene: BattleScene) => {
|
.withOptionPhase(async (scene: BattleScene) => {
|
||||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||||
const modifier = encounter.misc.chosenModifier;
|
const modifier = encounter.misc.chosenModifier;
|
||||||
|
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||||
|
|
||||||
// Remove the modifier if its stacks go to 0
|
chosenPokemon.loseHeldItem(modifier, false);
|
||||||
modifier.stackCount -= 1;
|
|
||||||
if (modifier.stackCount === 0) {
|
|
||||||
scene.removeModifier(modifier);
|
|
||||||
}
|
|
||||||
scene.updateModifiers(true, true);
|
scene.updateModifiers(true, true);
|
||||||
|
|
||||||
const bugNet = generateModifierTypeOption(scene, modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!;
|
const bugNet = generateModifierTypeOption(scene, modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!;
|
||||||
|
@ -8,7 +8,7 @@ import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/u
|
|||||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||||
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
|
import Pokemon, { PlayerPokemon } from "#app/field/pokemon";
|
||||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||||
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PreserveBerryModifier } from "#app/modifier/modifier";
|
import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonHeldItemModifier, PokemonInstantReviveModifier, PreserveBerryModifier } from "#app/modifier/modifier";
|
||||||
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||||
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
||||||
import i18next from "#app/plugins/i18n";
|
import i18next from "#app/plugins/i18n";
|
||||||
@ -197,7 +197,8 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||||||
})
|
})
|
||||||
.withOptionPhase(async (scene: BattleScene) => {
|
.withOptionPhase(async (scene: BattleScene) => {
|
||||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||||
const modifier: BerryModifier | HealingBoosterModifier = encounter.misc.chosenModifier;
|
const modifier: BerryModifier | PokemonInstantReviveModifier = encounter.misc.chosenModifier;
|
||||||
|
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||||
|
|
||||||
// Give the player a Candy Jar if they gave a Berry, and a Berry Pouch for Reviver Seed
|
// Give the player a Candy Jar if they gave a Berry, and a Berry Pouch for Reviver Seed
|
||||||
if (modifier instanceof BerryModifier) {
|
if (modifier instanceof BerryModifier) {
|
||||||
@ -228,11 +229,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the modifier if its stacks go to 0
|
chosenPokemon.loseHeldItem(modifier, false);
|
||||||
modifier.stackCount -= 1;
|
|
||||||
if (modifier.stackCount === 0) {
|
|
||||||
scene.removeModifier(modifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
leaveEncounterWithoutBattle(scene, true);
|
leaveEncounterWithoutBattle(scene, true);
|
||||||
})
|
})
|
||||||
@ -292,6 +289,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||||||
.withOptionPhase(async (scene: BattleScene) => {
|
.withOptionPhase(async (scene: BattleScene) => {
|
||||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||||
const modifier = encounter.misc.chosenModifier;
|
const modifier = encounter.misc.chosenModifier;
|
||||||
|
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||||
|
|
||||||
// Check if the player has max stacks of Healing Charm already
|
// Check if the player has max stacks of Healing Charm already
|
||||||
const existing = scene.findModifier(m => m instanceof HealingBoosterModifier) as HealingBoosterModifier;
|
const existing = scene.findModifier(m => m instanceof HealingBoosterModifier) as HealingBoosterModifier;
|
||||||
@ -306,11 +304,7 @@ export const DelibirdyEncounter: MysteryEncounter =
|
|||||||
scene.unshiftPhase(new ModifierRewardPhase(scene, modifierTypes.HEALING_CHARM));
|
scene.unshiftPhase(new ModifierRewardPhase(scene, modifierTypes.HEALING_CHARM));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the modifier if its stacks go to 0
|
chosenPokemon.loseHeldItem(modifier, false);
|
||||||
modifier.stackCount -= 1;
|
|
||||||
if (modifier.stackCount === 0) {
|
|
||||||
scene.removeModifier(modifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
leaveEncounterWithoutBattle(scene, true);
|
leaveEncounterWithoutBattle(scene, true);
|
||||||
})
|
})
|
||||||
|
@ -345,6 +345,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||||||
// Pokemon and item selected
|
// Pokemon and item selected
|
||||||
encounter.setDialogueToken("chosenItem", modifier.type.name);
|
encounter.setDialogueToken("chosenItem", modifier.type.name);
|
||||||
encounter.misc.chosenModifier = modifier;
|
encounter.misc.chosenModifier = modifier;
|
||||||
|
encounter.misc.chosenPokemon = pokemon;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -370,6 +371,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||||||
const encounter = scene.currentBattle.mysteryEncounter!;
|
const encounter = scene.currentBattle.mysteryEncounter!;
|
||||||
const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier;
|
const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier;
|
||||||
const party = scene.getPlayerParty();
|
const party = scene.getPlayerParty();
|
||||||
|
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||||
|
|
||||||
// Check tier of the traded item, the received item will be one tier up
|
// Check tier of the traded item, the received item will be one tier up
|
||||||
const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party);
|
const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party);
|
||||||
@ -397,11 +399,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
|||||||
encounter.setDialogueToken("itemName", item.type.name);
|
encounter.setDialogueToken("itemName", item.type.name);
|
||||||
setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ item ], fillRemaining: false });
|
setEncounterRewards(scene, { guaranteedModifierTypeOptions: [ item ], fillRemaining: false });
|
||||||
|
|
||||||
// Remove the chosen modifier if its stacks go to 0
|
chosenPokemon.loseHeldItem(modifier, false);
|
||||||
modifier.stackCount -= 1;
|
|
||||||
if (modifier.stackCount === 0) {
|
|
||||||
scene.removeModifier(modifier);
|
|
||||||
}
|
|
||||||
await scene.updateModifiers(true, true);
|
await scene.updateModifiers(true, true);
|
||||||
|
|
||||||
// Generate a trainer name
|
// Generate a trainer name
|
||||||
|
@ -23,7 +23,7 @@ import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "#app/data/balance/
|
|||||||
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags";
|
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
|
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
|
||||||
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, CommanderAbAttr } from "#app/data/ability";
|
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr } from "#app/data/ability";
|
||||||
import PokemonData from "#app/system/pokemon-data";
|
import PokemonData from "#app/system/pokemon-data";
|
||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
import { Mode } from "#app/ui/ui";
|
import { Mode } from "#app/ui/ui";
|
||||||
@ -985,7 +985,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
if (this.status && this.status.effect === StatusEffect.PARALYSIS) {
|
if (this.status && this.status.effect === StatusEffect.PARALYSIS) {
|
||||||
ret >>= 1;
|
ret >>= 1;
|
||||||
}
|
}
|
||||||
if (this.getTag(BattlerTagType.UNBURDEN) && !this.scene.getField(true).some(pokemon => pokemon !== this && pokemon.hasAbilityWithAttr(SuppressFieldAbilitiesAbAttr))) {
|
if (this.getTag(BattlerTagType.UNBURDEN) && this.hasAbility(Abilities.UNBURDEN)) {
|
||||||
ret *= 2;
|
ret *= 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4102,6 +4102,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reduces one of this Pokemon's held item stacks by 1, and removes the item if applicable.
|
||||||
|
* Does nothing if this Pokemon is somehow not the owner of the held item.
|
||||||
|
* @param heldItem The item stack to be reduced by 1.
|
||||||
|
* @param forBattle If `false`, do not trigger in-battle effects (such as Unburden) from losing the item. For example, set this to `false` if the Pokemon is giving away the held item for a Mystery Encounter. Default is `true`.
|
||||||
|
* @returns `true` if the item was removed successfully, `false` otherwise.
|
||||||
|
*/
|
||||||
|
public loseHeldItem(heldItem: PokemonHeldItemModifier, forBattle: boolean = true): boolean {
|
||||||
|
if (heldItem.pokemonId === -1 || heldItem.pokemonId === this.id) {
|
||||||
|
heldItem.stackCount--;
|
||||||
|
if (heldItem.stackCount <= 0) {
|
||||||
|
this.scene.removeModifier(heldItem, !this.isPlayer());
|
||||||
|
}
|
||||||
|
if (forBattle) {
|
||||||
|
applyPostItemLostAbAttrs(PostItemLostAbAttr, this, false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default interface Pokemon {
|
export default interface Pokemon {
|
||||||
@ -4544,7 +4566,7 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
&& m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
|
&& m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[];
|
||||||
const transferModifiers: Promise<boolean>[] = [];
|
const transferModifiers: Promise<boolean>[] = [];
|
||||||
for (const modifier of fusedPartyMemberHeldModifiers) {
|
for (const modifier of fusedPartyMemberHeldModifiers) {
|
||||||
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true));
|
transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true, false));
|
||||||
}
|
}
|
||||||
Promise.allSettled(transferModifiers).then(() => {
|
Promise.allSettled(transferModifiers).then(() => {
|
||||||
this.scene.updateModifiers(true, true).then(() => {
|
this.scene.updateModifiers(true, true).then(() => {
|
||||||
|
@ -31,11 +31,8 @@ export class BerryPhase extends FieldPhase {
|
|||||||
|
|
||||||
for (const berryModifier of this.scene.applyModifiers(BerryModifier, pokemon.isPlayer(), pokemon)) {
|
for (const berryModifier of this.scene.applyModifiers(BerryModifier, pokemon.isPlayer(), pokemon)) {
|
||||||
if (berryModifier.consumed) {
|
if (berryModifier.consumed) {
|
||||||
if (!--berryModifier.stackCount) {
|
berryModifier.consumed = false;
|
||||||
this.scene.removeModifier(berryModifier);
|
pokemon.loseHeldItem(berryModifier);
|
||||||
} else {
|
|
||||||
berryModifier.consumed = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.scene.eventTarget.dispatchEvent(new BerryUsedEvent(berryModifier)); // Announce a berry was used
|
this.scene.eventTarget.dispatchEvent(new BerryUsedEvent(berryModifier)); // Announce a berry was used
|
||||||
}
|
}
|
||||||
|
@ -55,21 +55,21 @@ export class FaintPhase extends PokemonPhase {
|
|||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
|
const faintPokemon = this.getPokemon();
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.destinyTag) && !isNullOrUndefined(this.source)) {
|
if (!isNullOrUndefined(this.destinyTag) && !isNullOrUndefined(this.source)) {
|
||||||
this.destinyTag.lapse(this.source, BattlerTagLapseType.CUSTOM);
|
this.destinyTag.lapse(this.source, BattlerTagLapseType.CUSTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNullOrUndefined(this.grudgeTag) && !isNullOrUndefined(this.source)) {
|
if (!isNullOrUndefined(this.grudgeTag) && !isNullOrUndefined(this.source)) {
|
||||||
this.grudgeTag.lapse(this.getPokemon(), BattlerTagLapseType.CUSTOM, this.source);
|
this.grudgeTag.lapse(faintPokemon, BattlerTagLapseType.CUSTOM, this.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.preventEndure) {
|
if (!this.preventEndure) {
|
||||||
const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, this.getPokemon()) as PokemonInstantReviveModifier;
|
const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, faintPokemon) as PokemonInstantReviveModifier;
|
||||||
|
|
||||||
if (instantReviveModifier) {
|
if (instantReviveModifier) {
|
||||||
if (!--instantReviveModifier.stackCount) {
|
faintPokemon.loseHeldItem(instantReviveModifier);
|
||||||
this.scene.removeModifier(instantReviveModifier);
|
|
||||||
}
|
|
||||||
this.scene.updateModifiers(this.player);
|
this.scene.updateModifiers(this.player);
|
||||||
return this.end();
|
return this.end();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||||
&& m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
|
&& m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[];
|
||||||
const itemModifier = itemModifiers[itemIndex];
|
const itemModifier = itemModifiers[itemIndex];
|
||||||
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity);
|
this.scene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity, undefined, undefined, false);
|
||||||
} else {
|
} else {
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(this.scene.lockModifierTiers));
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(this.scene.lockModifierTiers));
|
||||||
}
|
}
|
||||||
|
@ -125,10 +125,7 @@ export class StatStageChangePhase extends PokemonPhase {
|
|||||||
const whiteHerb = this.scene.applyModifier(ResetNegativeStatStageModifier, this.player, pokemon) as ResetNegativeStatStageModifier;
|
const whiteHerb = this.scene.applyModifier(ResetNegativeStatStageModifier, this.player, pokemon) as ResetNegativeStatStageModifier;
|
||||||
// If the White Herb was applied, consume it
|
// If the White Herb was applied, consume it
|
||||||
if (whiteHerb) {
|
if (whiteHerb) {
|
||||||
whiteHerb.stackCount--;
|
pokemon.loseHeldItem(whiteHerb);
|
||||||
if (whiteHerb.stackCount <= 0) {
|
|
||||||
this.scene.removeModifier(whiteHerb);
|
|
||||||
}
|
|
||||||
this.scene.updateModifiers(this.player);
|
this.scene.updateModifiers(this.player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ export class SwitchSummonPhase extends SummonPhase {
|
|||||||
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
|
const batonPassModifier = this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier
|
||||||
&& (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier;
|
&& (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier;
|
||||||
if (batonPassModifier && !this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
|
if (batonPassModifier && !this.scene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) {
|
||||||
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false);
|
this.scene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false, undefined, undefined, undefined, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,35 @@
|
|||||||
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
import { PostItemLostAbAttr } from "#app/data/ability";
|
||||||
|
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
|
||||||
|
import Pokemon from "#app/field/pokemon";
|
||||||
|
import type { ContactHeldItemTransferChanceModifier } from "#app/modifier/modifier";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
|
import { BerryType } from "#enums/berry-type";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
|
import { Stat } from "#enums/stat";
|
||||||
import GameManager from "#test/utils/gameManager";
|
import GameManager from "#test/utils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { Stat } from "#enums/stat";
|
|
||||||
import { BerryType } from "#app/enums/berry-type";
|
|
||||||
import { allMoves, StealHeldItemChanceAttr } from "#app/data/move";
|
|
||||||
|
|
||||||
|
|
||||||
describe("Abilities - Unburden", () => {
|
describe("Abilities - Unburden", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of held items a Pokemon has, accounting for stacks of multiple items.
|
||||||
|
*/
|
||||||
|
function getHeldItemCount(pokemon: Pokemon): number {
|
||||||
|
const stackCounts = pokemon.getHeldItems().map(m => m.getStackCount());
|
||||||
|
if (stackCounts.length) {
|
||||||
|
return stackCounts.reduce((a, b) => a + b);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
type: Phaser.HEADLESS,
|
type: Phaser.HEADLESS,
|
||||||
@ -27,9 +44,9 @@ describe("Abilities - Unburden", () => {
|
|||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override
|
game.override
|
||||||
.battleType("single")
|
.battleType("single")
|
||||||
.starterSpecies(Species.TREECKO)
|
|
||||||
.startingLevel(1)
|
.startingLevel(1)
|
||||||
.moveset([ Moves.POPULATION_BOMB, Moves.KNOCK_OFF, Moves.PLUCK, Moves.THIEF ])
|
.ability(Abilities.UNBURDEN)
|
||||||
|
.moveset([ Moves.SPLASH, Moves.KNOCK_OFF, Moves.PLUCK, Moves.FALSE_SWIPE ])
|
||||||
.startingHeldItems([
|
.startingHeldItems([
|
||||||
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
||||||
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
||||||
@ -37,209 +54,348 @@ describe("Abilities - Unburden", () => {
|
|||||||
])
|
])
|
||||||
.enemySpecies(Species.NINJASK)
|
.enemySpecies(Species.NINJASK)
|
||||||
.enemyLevel(100)
|
.enemyLevel(100)
|
||||||
.enemyMoveset([ Moves.FALSE_SWIPE ])
|
.enemyMoveset(Moves.SPLASH)
|
||||||
.enemyAbility(Abilities.UNBURDEN)
|
.enemyAbility(Abilities.UNBURDEN)
|
||||||
.enemyPassiveAbility(Abilities.NO_GUARD)
|
.enemyPassiveAbility(Abilities.NO_GUARD)
|
||||||
.enemyHeldItems([
|
.enemyHeldItems([
|
||||||
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
||||||
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
||||||
]);
|
]);
|
||||||
|
// For the various tests that use Thief, give it a 100% steal rate
|
||||||
|
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when a berry is eaten", async () => {
|
it("should activate when a berry is eaten", async () => {
|
||||||
await game.classicMode.startBattle();
|
game.override.enemyMoveset(Moves.FALSE_SWIPE);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
playerPokemon.abilityIndex = 2;
|
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
|
||||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
game.move.select(Moves.FALSE_SWIPE);
|
// Player gets hit by False Swipe and eats its own Sitrus Berry
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when a berry is stolen", async () => {
|
it("should activate when a berry is eaten, even if Berry Pouch preserves the berry", async () => {
|
||||||
await game.classicMode.startBattle();
|
game.override.enemyMoveset(Moves.FALSE_SWIPE)
|
||||||
|
.startingModifier([{ name: "BERRY_POUCH", count: 5850 }]);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||||
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player gets hit by False Swipe and eats its own Sitrus Berry
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(getHeldItemCount(playerPokemon)).toBe(playerHeldItems);
|
||||||
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should activate for the target, and not the stealer, when a berry is stolen", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player uses Pluck and eats the opponent's berry
|
||||||
game.move.select(Moves.PLUCK);
|
game.move.select(Moves.PLUCK);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||||
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when an item is knocked off", async () => {
|
it("should activate when an item is knocked off", async () => {
|
||||||
await game.classicMode.startBattle();
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player uses Knock Off and removes the opponent's item
|
||||||
game.move.select(Moves.KNOCK_OFF);
|
game.move.select(Moves.KNOCK_OFF);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when an item is stolen via attacking ability", async () => {
|
it("should activate when an item is stolen via attacking ability", async () => {
|
||||||
game.override
|
game.override
|
||||||
.ability(Abilities.MAGICIAN)
|
.ability(Abilities.MAGICIAN)
|
||||||
.startingHeldItems([
|
.startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items
|
||||||
{ name: "MULTI_LENS", count: 3 },
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
]);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
game.move.select(Moves.POPULATION_BOMB);
|
// Player steals the opponent's item via ability Magician
|
||||||
|
game.move.select(Moves.FALSE_SWIPE);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when an item is stolen via defending ability", async () => {
|
it("should activate when an item is stolen via defending ability", async () => {
|
||||||
game.override
|
game.override
|
||||||
.startingLevel(45)
|
|
||||||
.enemyAbility(Abilities.PICKPOCKET)
|
.enemyAbility(Abilities.PICKPOCKET)
|
||||||
.startingHeldItems([
|
.enemyHeldItems([]); // Remove opponent's full stacks of held items so it can steal player's held items
|
||||||
{ name: "MULTI_LENS", count: 3 },
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
{ name: "SOUL_DEW", count: 1 },
|
|
||||||
{ name: "LUCKY_EGG", count: 1 },
|
|
||||||
]);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
playerPokemon.abilityIndex = 2;
|
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
|
||||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
game.move.select(Moves.POPULATION_BOMB);
|
// Player's item gets stolen via ability Pickpocket
|
||||||
|
game.move.select(Moves.FALSE_SWIPE);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when an item is stolen via move", async () => {
|
it("should activate when an item is stolen via move", async () => {
|
||||||
vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]); // give Thief 100% steal rate
|
game.override.moveset(Moves.THIEF)
|
||||||
game.override.startingHeldItems([
|
.startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items
|
||||||
{ name: "MULTI_LENS", count: 3 },
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
]);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player uses Thief and steals the opponent's item
|
||||||
game.move.select(Moves.THIEF);
|
game.move.select(Moves.THIEF);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when an item is stolen via grip claw", async () => {
|
it("should activate when an item is stolen via grip claw", async () => {
|
||||||
game.override
|
game.override
|
||||||
.startingLevel(5)
|
|
||||||
.startingHeldItems([
|
.startingHeldItems([
|
||||||
{ name: "GRIP_CLAW", count: 5 },
|
|
||||||
{ name: "MULTI_LENS", count: 3 },
|
|
||||||
])
|
|
||||||
.enemyHeldItems([
|
|
||||||
{ name: "SOUL_DEW", count: 1 },
|
|
||||||
{ name: "LUCKY_EGG", count: 1 },
|
|
||||||
{ name: "LEFTOVERS", count: 1 },
|
|
||||||
{ name: "GRIP_CLAW", count: 1 },
|
{ name: "GRIP_CLAW", count: 1 },
|
||||||
{ name: "MULTI_LENS", count: 1 },
|
|
||||||
{ name: "BERRY", type: BerryType.SITRUS, count: 1 },
|
|
||||||
{ name: "BERRY", type: BerryType.LUM, count: 1 },
|
|
||||||
]);
|
]);
|
||||||
await game.classicMode.startBattle();
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
||||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
|
||||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
|
||||||
|
|
||||||
while (enemyPokemon.getHeldItems().length === enemyHeldItemCt) {
|
|
||||||
game.move.select(Moves.POPULATION_BOMB);
|
|
||||||
await game.toNextTurn();
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
|
||||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should not activate when a neutralizing ability is present", async () => {
|
|
||||||
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
const playerHeldItems = playerPokemon.getHeldItems().length;
|
const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier;
|
||||||
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
const enemyHeldItemCt = getHeldItemCount(enemyPokemon);
|
||||||
|
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player steals the opponent's item using Grip Claw
|
||||||
game.move.select(Moves.FALSE_SWIPE);
|
game.move.select(Moves.FALSE_SWIPE);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(playerPokemon.getHeldItems().length).toBeLessThan(playerHeldItems);
|
expect(getHeldItemCount(enemyPokemon)).toBeLessThan(enemyHeldItemCt);
|
||||||
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
|
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(initialEnemySpeed * 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not activate when a neutralizing ability is present", async () => {
|
||||||
|
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS)
|
||||||
|
.enemyMoveset(Moves.FALSE_SWIPE);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||||
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player gets hit by False Swipe and eats Sitrus Berry, which should not trigger Unburden
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||||
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||||
|
expect(playerPokemon.getTag(BattlerTagType.UNBURDEN)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should activate when a move that consumes a berry is used", async () => {
|
it("should activate when a move that consumes a berry is used", async () => {
|
||||||
game.override.enemyMoveset([ Moves.STUFF_CHEEKS ]);
|
game.override.moveset(Moves.STUFF_CHEEKS);
|
||||||
await game.classicMode.startBattle();
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
const enemyHeldItemCt = enemyPokemon.getHeldItems().length;
|
const playerHeldItemCt = getHeldItemCount(playerPokemon);
|
||||||
const initialEnemySpeed = enemyPokemon.getStat(Stat.SPD);
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Player uses Stuff Cheeks and eats its own berry
|
||||||
|
// Caution: Do not test this using opponent, there is a known issue where opponent can randomly generate with Salac Berry
|
||||||
game.move.select(Moves.STUFF_CHEEKS);
|
game.move.select(Moves.STUFF_CHEEKS);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyPokemon.getHeldItems().length).toBeLessThan(enemyHeldItemCt);
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItemCt);
|
||||||
expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialEnemySpeed * 2);
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should deactivate when a neutralizing gas user enters the field", async () => {
|
it("should deactivate temporarily when a neutralizing gas user is on the field", async () => {
|
||||||
game.override
|
game.override
|
||||||
.battleType("double")
|
.battleType("double")
|
||||||
.moveset([ Moves.SPLASH ]);
|
.ability(Abilities.NONE); // Disable ability override so that we can properly set abilities below
|
||||||
await game.classicMode.startBattle([ Species.TREECKO, Species.MEOWTH, Species.WEEZING ]);
|
await game.classicMode.startBattle([ Species.TREECKO, Species.MEOWTH, Species.WEEZING ]);
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerParty();
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const treecko = playerPokemon[0];
|
const [ treecko, _meowth, weezing ] = game.scene.getPlayerParty();
|
||||||
const weezing = playerPokemon[2];
|
treecko.abilityIndex = 2; // Treecko has Unburden
|
||||||
treecko.abilityIndex = 2;
|
weezing.abilityIndex = 1; // Weezing has Neutralizing Gas
|
||||||
weezing.abilityIndex = 1;
|
const playerHeldItems = getHeldItemCount(treecko);
|
||||||
const playerHeldItems = treecko.getHeldItems().length;
|
|
||||||
const initialPlayerSpeed = treecko.getStat(Stat.SPD);
|
const initialPlayerSpeed = treecko.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Turn 1: Treecko gets hit by False Swipe and eats Sitrus Berry, activating Unburden
|
||||||
game.move.select(Moves.SPLASH);
|
game.move.select(Moves.SPLASH);
|
||||||
game.move.select(Moves.SPLASH);
|
game.move.select(Moves.SPLASH, 1);
|
||||||
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
||||||
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
await game.forceEnemyMove(Moves.FALSE_SWIPE, 0);
|
||||||
await game.phaseInterceptor.to("TurnEndPhase");
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
|
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
|
||||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed * 2);
|
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
|
|
||||||
|
// Turn 2: Switch Meowth to Weezing, activating Neutralizing Gas
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
game.move.select(Moves.SPLASH);
|
game.move.select(Moves.SPLASH);
|
||||||
game.doSwitchPokemon(2);
|
game.doSwitchPokemon(2);
|
||||||
await game.phaseInterceptor.to("TurnEndPhase");
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
expect(treecko.getHeldItems().length).toBeLessThan(playerHeldItems);
|
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
|
||||||
expect(treecko.getEffectiveStat(Stat.SPD)).toBeCloseTo(initialPlayerSpeed);
|
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||||
|
|
||||||
|
// Turn 3: Switch Weezing to Meowth, deactivating Neutralizing Gas
|
||||||
|
await game.toNextTurn();
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
game.doSwitchPokemon(2);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
|
expect(getHeldItemCount(treecko)).toBeLessThan(playerHeldItems);
|
||||||
|
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not activate when passing a baton to a teammate switching in", async () => {
|
||||||
|
game.override.startingHeldItems([{ name: "BATON" }])
|
||||||
|
.moveset(Moves.BATON_PASS);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO, Species.PURRLOIN ]);
|
||||||
|
|
||||||
|
const [ treecko, purrloin ] = game.scene.getPlayerParty();
|
||||||
|
const initialTreeckoSpeed = treecko.getStat(Stat.SPD);
|
||||||
|
const initialPurrloinSpeed = purrloin.getStat(Stat.SPD);
|
||||||
|
const unburdenAttr = treecko.getAbilityAttrs(PostItemLostAbAttr)[0];
|
||||||
|
vi.spyOn(unburdenAttr, "applyPostItemLost");
|
||||||
|
|
||||||
|
// Player uses Baton Pass, which also passes the Baton item
|
||||||
|
game.move.select(Moves.BATON_PASS);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(getHeldItemCount(treecko)).toBe(0);
|
||||||
|
expect(getHeldItemCount(purrloin)).toBe(1);
|
||||||
|
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialTreeckoSpeed);
|
||||||
|
expect(purrloin.getEffectiveStat(Stat.SPD)).toBe(initialPurrloinSpeed);
|
||||||
|
expect(unburdenAttr.applyPostItemLost).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not speed up a Pokemon after it loses the ability Unburden", async () => {
|
||||||
|
game.override.enemyMoveset([ Moves.FALSE_SWIPE, Moves.WORRY_SEED ]);
|
||||||
|
await game.classicMode.startBattle([ Species.PURRLOIN ]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||||
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Turn 1: Get hit by False Swipe and eat Sitrus Berry, activating Unburden
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.FALSE_SWIPE);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||||
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
|
|
||||||
|
// Turn 2: Get hit by Worry Seed, deactivating Unburden
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.WORRY_SEED);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||||
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should activate when a reviver seed is used", async () => {
|
||||||
|
game.override.startingHeldItems([{ name: "REVIVER_SEED" }])
|
||||||
|
.enemyMoveset([ Moves.WING_ATTACK ]);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO ]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
const playerHeldItems = getHeldItemCount(playerPokemon);
|
||||||
|
const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
// Turn 1: Get hit by Wing Attack and faint, activating Reviver Seed
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(getHeldItemCount(playerPokemon)).toBeLessThan(playerHeldItems);
|
||||||
|
expect(playerPokemon.getEffectiveStat(Stat.SPD)).toBe(initialPlayerSpeed * 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
// test for `.bypassFaint()` - singles
|
||||||
|
it("shouldn't persist when revived normally if activated while fainting", async () => {
|
||||||
|
game.override.enemyMoveset([ Moves.SPLASH, Moves.THIEF ]);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS ]);
|
||||||
|
|
||||||
|
const treecko = game.scene.getPlayerPokemon()!;
|
||||||
|
const treeckoInitialHeldItems = getHeldItemCount(treecko);
|
||||||
|
const initialSpeed = treecko.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.THIEF);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.doRevivePokemon(1);
|
||||||
|
game.doSwitchPokemon(1);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()!).toBe(treecko);
|
||||||
|
expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems);
|
||||||
|
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed);
|
||||||
|
});
|
||||||
|
|
||||||
|
// test for `.bypassFaint()` - doubles
|
||||||
|
it("shouldn't persist when revived by revival blessing if activated while fainting", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.enemyMoveset([ Moves.SPLASH, Moves.THIEF ])
|
||||||
|
.moveset([ Moves.SPLASH, Moves.REVIVAL_BLESSING ])
|
||||||
|
.startingHeldItems([{ name: "WIDE_LENS" }]);
|
||||||
|
await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS, Species.MILOTIC ]);
|
||||||
|
|
||||||
|
const treecko = game.scene.getPlayerField()[0];
|
||||||
|
const treeckoInitialHeldItems = getHeldItemCount(treecko);
|
||||||
|
const initialSpeed = treecko.getStat(Stat.SPD);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
game.move.select(Moves.REVIVAL_BLESSING, 1);
|
||||||
|
await game.forceEnemyMove(Moves.THIEF, BattlerIndex.PLAYER);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]);
|
||||||
|
game.doSelectPartyPokemon(0, "MoveEffectPhase");
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerField()[0]).toBe(treecko);
|
||||||
|
expect(getHeldItemCount(treecko)).toBeLessThan(treeckoInitialHeldItems);
|
||||||
|
expect(treecko.getEffectiveStat(Stat.SPD)).toBe(initialSpeed);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user