diff --git a/src/battle-scene.ts b/src/battle-scene.ts index dec6abb4f30..46996e9d0d2 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -791,10 +791,11 @@ export default class BattleScene extends SceneBase { /** * Returns the ModifierBar of this scene, which is declared private and therefore not accessible elsewhere + * @param isEnemy Whether to return the enemy's modifier bar * @returns {ModifierBar} */ - getModifierBar(): ModifierBar { - return this.modifierBar; + getModifierBar(isEnemy?: boolean): ModifierBar { + return isEnemy ? this.enemyModifierBar : this.modifierBar; } // store info toggles to be accessible by the ui diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 93ea067e424..a32f3c019f4 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -22,12 +22,12 @@ import { FormChangeItem, SpeciesFormChangeItemTrigger } from "../data/pokemon-fo import { Nature } from "#app/data/nature"; import Overrides from "#app/overrides"; import { ModifierType, modifierTypes } from "./modifier-type"; -import { Command } from "#app/ui/command-ui-handler.js"; +import { Command } from "#app/ui/command-ui-handler"; import { Species } from "#enums/species"; import i18next from "i18next"; -import { allMoves } from "#app/data/move.js"; -import { Abilities } from "#app/enums/abilities.js"; +import { allMoves } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; export type ModifierPredicate = (modifier: Modifier) => boolean; @@ -506,6 +506,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { if (pokemon) { const pokemonIcon = scene.addPokemonIcon(pokemon, -2, 10, 0, 0.5); container.add(pokemonIcon); + container.setName(pokemon.id.toString()); } const item = scene.add.sprite(16, this.virtualStackCount ? 8 : 16, "items"); diff --git a/src/ui/target-select-ui-handler.ts b/src/ui/target-select-ui-handler.ts index 9a0922715e8..42c7fef5660 100644 --- a/src/ui/target-select-ui-handler.ts +++ b/src/ui/target-select-ui-handler.ts @@ -6,7 +6,8 @@ import * as Utils from "../utils"; import { getMoveTargets } from "../data/move"; import {Button} from "#enums/buttons"; import { Moves } from "#enums/moves"; -import Pokemon from "#app/field/pokemon.js"; +import Pokemon from "#app/field/pokemon"; +import { ModifierBar } from "#app/modifier/modifier"; export type TargetSelectCallback = (targets: BattlerIndex[]) => void; @@ -19,6 +20,7 @@ export default class TargetSelectUiHandler extends UiHandler { private targets: BattlerIndex[]; private targetsHighlighted: Pokemon[]; private targetFlashTween: Phaser.Tweens.Tween | null; + private enemyModifiers: ModifierBar; private targetBattleInfoMoveTween: Phaser.Tweens.Tween[] = []; constructor(scene: BattleScene) { @@ -48,6 +50,8 @@ export default class TargetSelectUiHandler extends UiHandler { return false; } + this.enemyModifiers = this.scene.getModifierBar(true); + this.setCursor(this.targets.includes(this.cursor) ? this.cursor : this.targets[0]); return true; @@ -108,22 +112,26 @@ export default class TargetSelectUiHandler extends UiHandler { this.targetFlashTween.stop(); for (const pokemon of multipleTargets) { pokemon.setAlpha(1); + this.highlightItems(pokemon.id, 1); } } this.targetFlashTween = this.scene.tweens.add({ targets: this.targetsHighlighted, - alpha: 0, + key: { start: 0.55, to: 1 }, loop: -1, - duration: Utils.fixedInt(250), - ease: "Sine.easeIn", + loopDelay: 150, + duration: Utils.fixedInt(450), + ease: "Sine.easeInOut", yoyo: true, onUpdate: t => { for (const target of this.targetsHighlighted) { target.setAlpha(t.getValue()); + this.highlightItems(target.id, t.getValue()); } } }); + if (this.targetBattleInfoMoveTween.length >= 1) { this.targetBattleInfoMoveTween.filter(t => t !== undefined).forEach(tween => tween.stop()); for (const pokemon of multipleTargets) { @@ -152,8 +160,10 @@ export default class TargetSelectUiHandler extends UiHandler { this.targetFlashTween.stop(); this.targetFlashTween = null; } + for (const pokemon of this.targetsHighlighted) { pokemon.setAlpha(1); + this.highlightItems(pokemon.id, 1); } if (this.targetBattleInfoMoveTween.length >= 1) { @@ -165,6 +175,13 @@ export default class TargetSelectUiHandler extends UiHandler { } } + private highlightItems(targetId: number, val: number) : void { + const targetItems = this.enemyModifiers.getAll("name", targetId.toString()); + for (const item of targetItems as Phaser.GameObjects.Container[]) { + item.setAlpha(val); + } + } + clear() { super.clear(); this.eraseCursor();