[Bug][Beta] Fix bugs from Substitute implementation (#4226)

* Fix animation issues with Substitute

* Fix Spirit Shackle, etc. incorrectly being removed by Substitute

* Fix sub tag unit tests
This commit is contained in:
innerthunder 2024-09-13 19:15:12 -07:00 committed by GitHub
parent 63feb88eea
commit eea12a62f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 9 deletions

View File

@ -910,7 +910,7 @@ export abstract class BattleAnim {
const sprites = spriteCache[isUser ? AnimFrameTarget.USER : AnimFrameTarget.TARGET];
const spriteSource = isUser ? userSprite : targetSprite;
if ((isUser ? u : t) === sprites.length) {
if (!isUser && !!targetSubstitute) {
if (isUser || !targetSubstitute) {
const sprite = scene.addPokemonSprite(isUser ? user! : target, 0, 0, spriteSource!.texture, spriteSource!.frame.name, true); // TODO: are those bangs correct?
[ "spriteColors", "fusionSpriteColors" ].map(k => sprite.pipelineData[k] = (isUser ? user! : target).getSprite().pipelineData[k]); // TODO: are those bangs correct?
sprite.setPipelineData("spriteKey", (isUser ? user! : target).getBattleSpriteKey());

View File

@ -2238,8 +2238,8 @@ export class SubstituteTag extends BattlerTag {
pokemon.scene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_ADD);
pokemon.scene.queueMessage(i18next.t("battlerTags:substituteOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500);
// Remove any trapping effects from the user
pokemon.findAndRemoveTags(tag => tag instanceof TrappedTag);
// Remove any binding effects from the user
pokemon.findAndRemoveTags(tag => tag instanceof DamagingTrapTag);
}
/** Queues an on-remove battle animation that removes the Substitute's sprite. */

View File

@ -124,9 +124,6 @@ export class FaintPhase extends PokemonPhase {
this.scene.redirectPokemonMoves(pokemon, allyPokemon);
}
pokemon.lapseTags(BattlerTagLapseType.FAINT);
this.scene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id));
pokemon.faintCry(() => {
if (pokemon instanceof PlayerPokemon) {
pokemon.addFriendship(-10);
@ -140,6 +137,9 @@ export class FaintPhase extends PokemonPhase {
ease: "Sine.easeIn",
onComplete: () => {
pokemon.resetSprite();
pokemon.lapseTags(BattlerTagLapseType.FAINT);
this.scene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id));
pokemon.y -= 150;
pokemon.trySetStatus(StatusEffect.FAINT);
if (pokemon.isPlayer()) {

View File

@ -1,8 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import Pokemon, { MoveResult, PokemonTurnData, TurnMove, PokemonMove } from "#app/field/pokemon";
import BattleScene from "#app/battle-scene";
import { BattlerTagLapseType, SubstituteTag, TrappedTag } from "#app/data/battler-tags";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { BattlerTagLapseType, BindTag, SubstituteTag } from "#app/data/battler-tags";
import { Moves } from "#app/enums/moves";
import { PokemonAnimType } from "#app/enums/pokemon-anim-type";
import * as messages from "#app/messages";
@ -25,7 +24,7 @@ describe("BattlerTag - SubstituteTag", () => {
getMaxHp: vi.fn().mockReturnValue(101) as Pokemon["getMaxHp"],
findAndRemoveTags: vi.fn().mockImplementation((tagFilter) => {
// simulate a Trapped tag set by another Pokemon, then expect the filter to catch it.
const trapTag = new TrappedTag(BattlerTagType.TRAPPED, BattlerTagLapseType.CUSTOM, 0, Moves.NONE, 1);
const trapTag = new BindTag(5, 0);
expect(tagFilter(trapTag)).toBeTruthy();
return true;
}) as Pokemon["findAndRemoveTags"]