made enigma berries and lum berries able to proc more than once per turn.

This commit is contained in:
alchemis 2024-05-20 16:21:44 -03:00
parent d2e455cdad
commit f4bd1218ef
2 changed files with 17 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { PokemonHealPhase, StatChangePhase } from "../phases";
import { PokemonHealPhase, StatChangePhase, TurnEndPhase } from "../phases";
import { getPokemonMessage } from "../messages";
import Pokemon, { HitResult } from "../field/pokemon";
import { getBattleStatName } from "./battle-stat";
@ -36,7 +36,7 @@ export type BerryPredicate = (pokemon: Pokemon) => boolean;
export function getBerryPredicate(berryType: BerryType): BerryPredicate {
switch (berryType) {
case BerryType.SITRUS:
return (pokemon: Pokemon) => pokemon.getHpRatio() < 0.5;
return (pokemon: Pokemon) => pokemon.getHpRatio() < 0.5 && pokemon.scene.getCurrentPhase() instanceof TurnEndPhase;
case BerryType.LUM:
return (pokemon: Pokemon) => !!pokemon.status || !!pokemon.getTag(BattlerTagType.CONFUSED);
case BerryType.ENIGMA:
@ -50,19 +50,19 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate {
const threshold = new Utils.NumberHolder(0.25);
const battleStat = (berryType - BerryType.LIECHI) as BattleStat;
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold);
return pokemon.getHpRatio() < threshold.value && pokemon.summonData.battleStats[battleStat] < 6;
return pokemon.getHpRatio() < threshold.value && pokemon.summonData.battleStats[battleStat] < 6 && pokemon.scene.getCurrentPhase() instanceof TurnEndPhase;
};
case BerryType.LANSAT:
return (pokemon: Pokemon) => {
const threshold = new Utils.NumberHolder(0.25);
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold);
return pokemon.getHpRatio() < 0.25 && !pokemon.getTag(BattlerTagType.CRIT_BOOST);
return pokemon.getHpRatio() < 0.25 && !pokemon.getTag(BattlerTagType.CRIT_BOOST) && pokemon.scene.getCurrentPhase() instanceof TurnEndPhase;
};
case BerryType.STARF:
return (pokemon: Pokemon) => {
const threshold = new Utils.NumberHolder(0.25);
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold);
return pokemon.getHpRatio() < 0.25;
return pokemon.getHpRatio() < 0.25 && pokemon.scene.getCurrentPhase() instanceof TurnEndPhase;
};
case BerryType.LEPPA:
return (pokemon: Pokemon) => {

View File

@ -2584,8 +2584,20 @@ export class MoveEffectPhase extends PokemonPhase {
}
end() {
if (this.getTarget()?.isActive()) {
const target = this.getTarget()
const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ target ]), target.isPlayer());
if (hasUsableBerry)
this.scene.unshiftPhase(new BerryPhase(this.scene, target.getBattlerIndex()));
}
const user = this.getUserPokemon();
if (user) {
const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ user ]), user.isPlayer());
if (hasUsableBerry)
this.scene.unshiftPhase(new BerryPhase(this.scene, user.getBattlerIndex()));
if (--user.turnData.hitsLeft >= 1 && this.getTarget()?.isActive())
this.scene.unshiftPhase(this.getNewHitPhase());
else {