bug fixes

This commit is contained in:
muscode13 2024-10-22 23:24:52 -06:00
parent bf6e4963a2
commit e01b9095dc
2 changed files with 9 additions and 40 deletions

View File

@ -4914,20 +4914,19 @@ export class PostDamageForceSwitchAttr extends PostDamageAbAttr {
if (moveHistory.length > 0) { if (moveHistory.length > 0) {
const lastMoveUsed = moveHistory[moveHistory.length - 1]; const lastMoveUsed = moveHistory[moveHistory.length - 1];
// Will not activate if the Pokémon's HP falls below half while it is in the air during Sky Drop. // Will not activate if the Pokémon's HP falls below half while it is in the air during Sky Drop.
if (fordbiddenAttackingMoves.includes(lastMoveUsed.move) || (lastMoveUsed.move === Moves.SKY_DROP && lastMoveUsed.result === MoveResult.OTHER)) { if (fordbiddenAttackingMoves.includes(lastMoveUsed.move)) {
return false;
// Will not activate if the Pokémon's HP falls below half due to hurting itself in confusion
} else if (lastMoveUsed.move === 0 && pokemon.getTag(BattlerTagType.CONFUSED)) {
return false; return false;
} }
} }
// Dragon Tail and Circle Throw switch out Pokémon before the Ability activates. // Dragon Tail and Circle Throw switch out Pokémon before the Ability activates.
const fordbiddenDefendingMoves = [ Moves.DRAGON_TAIL, Moves.CIRCLE_THROW ]; const fordbiddenDefendingMoves = [ Moves.DRAGON_TAIL, Moves.CIRCLE_THROW ];
for (const opponent of pokemon.getOpponents()) { const getField = [ ...pokemon.getOpponents(), ...pokemon.getAlliedField() ];
for (const opponent of getField) {
const enemyMoveHistory = opponent.getMoveHistory(); const enemyMoveHistory = opponent.getMoveHistory();
if (enemyMoveHistory.length > 0) { if (enemyMoveHistory.length > 0) {
const enemyLastMoveUsed = enemyMoveHistory[enemyMoveHistory.length - 1]; const enemyLastMoveUsed = enemyMoveHistory[enemyMoveHistory.length - 1];
if (fordbiddenDefendingMoves.includes(enemyLastMoveUsed.move)) { if (fordbiddenDefendingMoves.includes(enemyLastMoveUsed.move) || enemyLastMoveUsed.move === Moves.SKY_DROP && enemyLastMoveUsed.result === MoveResult.OTHER) {
return false; return false;
// Will not activate if the Pokémon's HP falls below half by a move affected by Sheer Force. // Will not activate if the Pokémon's HP falls below half by a move affected by Sheer Force.
} else if (allMoves[enemyLastMoveUsed.move].chance >= 0 && opponent.hasAbility(Abilities.SHEER_FORCE)) { } else if (allMoves[enemyLastMoveUsed.move].chance >= 0 && opponent.hasAbility(Abilities.SHEER_FORCE)) {
@ -5746,11 +5745,11 @@ export function initAbilities() {
new Ability(Abilities.STAMINA, 7) new Ability(Abilities.STAMINA, 7)
.attr(PostDefendStatStageChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS, Stat.DEF, 1), .attr(PostDefendStatStageChangeAbAttr, (target, user, move) => move.category !== MoveCategory.STATUS, Stat.DEF, 1),
new Ability(Abilities.WIMP_OUT, 7) new Ability(Abilities.WIMP_OUT, 7)
.attr(PostDamageForceSwitchAttr), .attr(PostDamageForceSwitchAttr)
// .condition(getSheerForceHitDisableAbCondition()), .edgeCase(), // Should not trigger when hurting itself in confusion
new Ability(Abilities.EMERGENCY_EXIT, 7) new Ability(Abilities.EMERGENCY_EXIT, 7)
.attr(PostDamageForceSwitchAttr), .attr(PostDamageForceSwitchAttr)
// .condition(getSheerForceHitDisableAbCondition()), .edgeCase(), // Should not trigger when hurting itself in confusion
new Ability(Abilities.WATER_COMPACTION, 7) new Ability(Abilities.WATER_COMPACTION, 7)
.attr(PostDefendStatStageChangeAbAttr, (target, user, move) => user.getMoveType(move) === Type.WATER && move.category !== MoveCategory.STATUS, Stat.DEF, 2), .attr(PostDefendStatStageChangeAbAttr, (target, user, move) => user.getMoveType(move) === Type.WATER && move.category !== MoveCategory.STATUS, Stat.DEF, 2),
new Ability(Abilities.MERCILESS, 7) new Ability(Abilities.MERCILESS, 7)

View File

@ -4,7 +4,6 @@ import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities"; import { Abilities } from "#app/enums/abilities";
import { ArenaTagType } from "#app/enums/arena-tag-type"; import { ArenaTagType } from "#app/enums/arena-tag-type";
import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Stat } from "#app/enums/stat";
import { StatusEffect } from "#app/enums/status-effect"; import { StatusEffect } from "#app/enums/status-effect";
import { WeatherType } from "#app/enums/weather-type"; import { WeatherType } from "#app/enums/weather-type";
import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
@ -477,35 +476,6 @@ describe("Abilities - Wimp Out", () => {
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.TYRUNT); expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.TYRUNT);
}); });
it("Wimp Out will not activate if the Pokémon's HP falls below half due to hurting itself in confusion", async () => {
// arrange
game.override
.moveset([ Moves.SWORDS_DANCE ])
.enemyMoveset([ Moves.SWAGGER ]);
await game.startBattle([
Species.WIMPOD,
Species.TYRUNT
]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const playerHp = playerPokemon.hp;
playerPokemon.hp = playerHp * 0.51;
playerPokemon.setStatStage(Stat.ATK, 6);
playerPokemon.addTag(BattlerTagType.CONFUSED);
vi.spyOn(playerPokemon, "randSeedInt").mockReturnValue(0);
vi.spyOn(allMoves[Moves.SWAGGER], "accuracy", "get").mockReturnValue(100);
// act
while (playerPokemon.getHpRatio() > 0.49) {
game.move.select(Moves.SWORDS_DANCE);
game.move.select(Moves.SWAGGER);
await game.phaseInterceptor.to(TurnEndPhase);
}
// assert
expect(playerPokemon.getHpRatio()).toBeLessThan(0.5);
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
expect(playerPokemon.species.speciesId).toBe(Species.WIMPOD);
});
it("Magic Guard passive should not allow indirect damage to trigger Wimp Out", async () => { it("Magic Guard passive should not allow indirect damage to trigger Wimp Out", async () => {
// arrange // arrange
game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0, ArenaTagSide.ENEMY); game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0, ArenaTagSide.ENEMY);