Fix psycho shift interaction causing buggy behaviour

This commit is contained in:
Yiling Kang 2024-07-01 13:00:33 -07:00
parent 7067187532
commit aadc86dd19
3 changed files with 31 additions and 5 deletions

View File

@ -1678,7 +1678,7 @@ export class SynchronizeStatusAbAttr extends PostSetStatusAbAttr {
]);
if (sourcePokemon && syncStatuses.has(effect)) {
return sourcePokemon.trySetStatus(effect, true);
return sourcePokemon.trySetStatus(effect, true, pokemon);
}
return false;
@ -4307,7 +4307,7 @@ export function initAbilities() {
new Ability(Abilities.SYNCHRONIZE, 3)
.attr(SyncEncounterNatureAbAttr)
.attr(SynchronizeStatusAbAttr)
.partial(), // interaction with psycho shift needs work
.partial(), // interaction with psycho shift needs work, keeping to old Gen interaction for now
new Ability(Abilities.CLEAR_BODY, 3)
.attr(ProtectStatAbAttr)
.ignorable(),

View File

@ -1761,13 +1761,14 @@ export class PsychoShiftEffectAttr extends MoveEffectAttr {
return false;
}
if (!target.status || (target.status.effect === statusToApply && move.chance < 0)) {
const statusAfflictResult = target.trySetStatus(statusToApply, true, user);
if (statusAfflictResult) {
const canSetStatus = target.canSetStatus(statusToApply, true, false, user);
if (canSetStatus) {
user.scene.queueMessage(getPokemonMessage(user, getStatusEffectHealText(user.status.effect)));
user.resetStatus();
user.updateInfo();
target.trySetStatus(statusToApply, true, user);
}
return statusAfflictResult;
return canSetStatus;
}
return false;

View File

@ -209,4 +209,29 @@ describe("Abilities - Synchronize", () => {
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(undefined);
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
}, 20000);
it("should activate with Psycho Shift after the move clears the status", async () => {
// Arrange
const moveToUse = Moves.PSYCHO_SHIFT;
// Starter mocks
vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.HOOTHOOT);
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([moveToUse]);
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.KEEN_EYE);
vi.spyOn(overrides, "STATUS_OVERRIDE", "get").mockReturnValue(StatusEffect.PARALYSIS);
// Act
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
await game.phaseInterceptor.to(MoveEffectPhase, false);
vi.spyOn(game.scene.getCurrentPhase() as MoveEffectPhase, "hitCheck").mockReturnValue(true);
await game.phaseInterceptor.to(TurnEndPhase);
// Assert
expect(game.scene.getParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS); // keeping old gen < V impl for now since it's buggy otherwise
expect(game.scene.getEnemyParty()[0].status?.effect).toBe(StatusEffect.PARALYSIS);
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
}, 20000);
});