From da18bf6ea97339b8043a0483fcb67f48be47c880 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sun, 1 Jun 2025 20:21:33 +0200 Subject: [PATCH] HeldItem .apply() methods do not really need the stack as input, just the pokemon --- src/items/held-items/attack-type-booster.ts | 7 ++++--- src/items/held-items/hit-heal.ts | 7 ++++--- src/items/held-items/turn-heal.ts | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/items/held-items/attack-type-booster.ts b/src/items/held-items/attack-type-booster.ts index 9324bec3229..cb8966fbb99 100644 --- a/src/items/held-items/attack-type-booster.ts +++ b/src/items/held-items/attack-type-booster.ts @@ -55,7 +55,8 @@ export class AttackTypeBoosterHeldItem extends HeldItem { return `${HeldItemNames[this.type]?.toLowerCase()}`; } - apply(stackCount: number, moveType: PokemonType, movePower: NumberHolder): void { + apply(pokemon: Pokemon, moveType: PokemonType, movePower: NumberHolder): void { + const stackCount = pokemon.heldItemManager.getStack(this.type); if (moveType === this.moveType && movePower.value >= 1) { movePower.value = Math.floor(movePower.value * (1 + stackCount * this.powerBoost)); } @@ -64,9 +65,9 @@ export class AttackTypeBoosterHeldItem extends HeldItem { export function applyAttackTypeBoosterHeldItem(pokemon: Pokemon, moveType: PokemonType, movePower: NumberHolder) { if (pokemon) { - for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) { + for (const item of Object.keys(pokemon.heldItemManager.getHeldItems())) { if (allHeldItems[item] instanceof AttackTypeBoosterHeldItem) { - allHeldItems[item].apply(props.stack, moveType, movePower); + allHeldItems[item].apply(pokemon, moveType, movePower); } } } diff --git a/src/items/held-items/hit-heal.ts b/src/items/held-items/hit-heal.ts index 8e710f3359c..8ea06d6cc6f 100644 --- a/src/items/held-items/hit-heal.ts +++ b/src/items/held-items/hit-heal.ts @@ -25,7 +25,8 @@ export class HitHealHeldItem extends HeldItem { * @param pokemon The {@linkcode Pokemon} that holds the item * @returns `true` if the {@linkcode Pokemon} was healed */ - apply(stackCount: number, pokemon: Pokemon): boolean { + apply(pokemon: Pokemon): boolean { + const stackCount = pokemon.heldItemManager.getStack(this.type); if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) { // TODO: this shouldn't be undefined AFAIK globalScene.unshiftPhase( @@ -46,9 +47,9 @@ export class HitHealHeldItem extends HeldItem { export function applyHitHealHeldItem(pokemon: Pokemon) { if (pokemon) { - for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) { + for (const item of Object.keys(pokemon.heldItemManager.getHeldItems())) { if (allHeldItems[item] instanceof HitHealHeldItem) { - allHeldItems[item].apply(props.stack, pokemon); + allHeldItems[item].apply(pokemon); } } } diff --git a/src/items/held-items/turn-heal.ts b/src/items/held-items/turn-heal.ts index a3e1120abe2..348d03c243c 100644 --- a/src/items/held-items/turn-heal.ts +++ b/src/items/held-items/turn-heal.ts @@ -20,7 +20,8 @@ export class TurnHealHeldItem extends HeldItem { return "leftovers"; } - apply(stackCount: number, pokemon: Pokemon): boolean { + apply(pokemon: Pokemon): boolean { + const stackCount = pokemon.heldItemManager.getStack(this.type); if (pokemon.isFullHp()) { return false; } @@ -41,9 +42,9 @@ export class TurnHealHeldItem extends HeldItem { export function applyTurnHealHeldItem(pokemon: Pokemon) { if (pokemon) { - for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) { + for (const item of Object.keys(pokemon.heldItemManager.getHeldItems())) { if (allHeldItems[item] instanceof TurnHealHeldItem) { - allHeldItems[item].apply(props.stack, pokemon); + allHeldItems[item].apply(pokemon); } } }