diff --git a/src/items/held-item.ts b/src/items/held-item.ts index 10efe2aae8e..9ca3fbd616d 100644 --- a/src/items/held-item.ts +++ b/src/items/held-item.ts @@ -41,7 +41,7 @@ export type HeldItemEffect = (typeof HeldItemEffect)[keyof typeof HeldItemEffect export class HeldItem { // public pokemonId: number; public type: HeldItemId; - public maxStackCount: number; + public readonly maxStackCount: number; public isTransferable = true; public isStealable = true; public isSuppressable = true; diff --git a/src/items/held-items/accuracy-booster.ts b/src/items/held-items/accuracy-booster.ts index 1373d4d7151..09abb723300 100644 --- a/src/items/held-items/accuracy-booster.ts +++ b/src/items/held-items/accuracy-booster.ts @@ -6,10 +6,13 @@ import type { NumberHolder } from "#utils/common"; export interface AccuracyBoostParams { /** The pokemon with the item */ pokemon: Pokemon; - /** The amount of exp to gain */ + /** Holds the move's accuracy, which may be modified after item application */ moveAccuracy: NumberHolder; } +/** + * @sealed + */ export class AccuracyBoosterHeldItem extends HeldItem { public effects: HeldItemEffect[] = [HeldItemEffect.ACCURACY_BOOSTER]; @@ -22,8 +25,8 @@ export class AccuracyBoosterHeldItem extends HeldItem { /** * Checks if {@linkcode PokemonMoveAccuracyBoosterModifier} should be applied - * @param pokemon The {@linkcode Pokemon} to apply the move accuracy boost to - * @param moveAccuracy {@linkcode NumberHolder} holding the move accuracy boost + * @param pokemon - The {@linkcode Pokemon} to apply the move accuracy boost to + * @param moveAccuracy - {@linkcode NumberHolder} holding the move accuracy boost * @returns `true` if {@linkcode PokemonMoveAccuracyBoosterModifier} should be applied */ // override shouldApply(pokemon?: Pokemon, moveAccuracy?: NumberHolder): boolean { @@ -32,15 +35,10 @@ export class AccuracyBoosterHeldItem extends HeldItem { /** * Applies {@linkcode PokemonMoveAccuracyBoosterModifier} - * @param _pokemon The {@linkcode Pokemon} to apply the move accuracy boost to - * @param moveAccuracy {@linkcode NumberHolder} holding the move accuracy boost - * @returns always `true` */ - apply(params: AccuracyBoostParams): boolean { - const pokemon = params.pokemon; - const moveAccuracy = params.moveAccuracy; + apply({ pokemon, moveAccuracy }: AccuracyBoostParams): true { const stackCount = pokemon.heldItemManager.getStack(this.type); - moveAccuracy.value = moveAccuracy.value + this.accuracyAmount * stackCount; + moveAccuracy.value += this.accuracyAmount * stackCount; return true; } diff --git a/src/items/held-items/attack-type-booster.ts b/src/items/held-items/attack-type-booster.ts index ddfd5373be5..7e5f1f10141 100644 --- a/src/items/held-items/attack-type-booster.ts +++ b/src/items/held-items/attack-type-booster.ts @@ -66,10 +66,7 @@ export class AttackTypeBoosterHeldItem extends HeldItem { return `${HeldItemNames[this.type]?.toLowerCase()}`; } - apply(params: AttackTypeBoostParams): void { - const pokemon = params.pokemon; - const moveType = params.moveType; - const movePower = params.movePower; + apply({ pokemon, moveType, movePower }: AttackTypeBoostParams): 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)); diff --git a/src/items/held-items/base-stat-booster.ts b/src/items/held-items/base-stat-booster.ts index b47d8bf850f..7525974ca92 100644 --- a/src/items/held-items/base-stat-booster.ts +++ b/src/items/held-items/base-stat-booster.ts @@ -7,6 +7,7 @@ import i18next from "i18next"; export interface BaseStatBoosterParams { /** The pokemon with the item */ pokemon: Pokemon; + /** The base stats of the {@linkcode pokemon} */ baseStats: number[]; } @@ -57,8 +58,8 @@ export class BaseStatBoosterHeldItem extends HeldItem { /** * Checks if {@linkcode BaseStatModifier} should be applied to the specified {@linkcode Pokemon}. - * @param _pokemon the {@linkcode Pokemon} to be modified - * @param baseStats the base stats of the {@linkcode Pokemon} + * @param _pokemon - The {@linkcode Pokemon} to be modified + * @param baseStats - The base stats of the {@linkcode Pokemon} * @returns `true` if the {@linkcode Pokemon} should be modified */ // override shouldApply(_pokemon?: Pokemon, baseStats?: number[]): boolean { @@ -67,14 +68,9 @@ export class BaseStatBoosterHeldItem extends HeldItem { /** * Applies the {@linkcode BaseStatModifier} to the specified {@linkcode Pokemon}. - * @param _pokemon the {@linkcode Pokemon} to be modified - * @param baseStats the base stats of the {@linkcode Pokemon} - * @returns always `true` */ - apply(params: BaseStatBoosterParams): boolean { - const pokemon = params.pokemon; + apply({ pokemon, baseStats }: BaseStatBoosterParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); - const baseStats = params.baseStats; baseStats[this.stat] = Math.floor(baseStats[this.stat] * (1 + stackCount * 0.1)); return true; } diff --git a/src/items/held-items/base-stat-flat.ts b/src/items/held-items/base-stat-flat.ts index b622a88fe14..ae10f6d7d1d 100644 --- a/src/items/held-items/base-stat-flat.ts +++ b/src/items/held-items/base-stat-flat.ts @@ -33,13 +33,8 @@ export class BaseStatFlatHeldItem extends HeldItem { /** * Applies the {@linkcode PokemonBaseStatFlatModifier} - * @param _pokemon The {@linkcode Pokemon} that holds the item - * @param baseStats The base stats of the {@linkcode Pokemon} - * @returns always `true` */ - apply(params: BaseStatFlatParams): boolean { - const pokemon = params.pokemon; - const baseStats = params.baseStats; + apply({ pokemon, baseStats }: BaseStatFlatParams): true { const stats = this.getStats(pokemon); const statModifier = 20; // Modifies the passed in baseStats[] array by a flat value, only if the stat is specified in this.stats @@ -57,15 +52,12 @@ export class BaseStatFlatHeldItem extends HeldItem { * Get the lowest of HP/Spd, lowest of Atk/SpAtk, and lowest of Def/SpDef * @returns Array of 3 {@linkcode Stat}s to boost */ - getStats(pokemon: Pokemon): Stat[] { - const stats: Stat[] = []; + getStats(pokemon: Pokemon): [HpOrSpeed: Stat, AtkOrSpAtk: Stat, DefOrSpDef: Stat] { const baseStats = pokemon.getSpeciesForm().baseStats.slice(0); - // HP or Speed - stats.push(baseStats[Stat.HP] < baseStats[Stat.SPD] ? Stat.HP : Stat.SPD); - // Attack or SpAtk - stats.push(baseStats[Stat.ATK] < baseStats[Stat.SPATK] ? Stat.ATK : Stat.SPATK); - // Def or SpDef - stats.push(baseStats[Stat.DEF] < baseStats[Stat.SPDEF] ? Stat.DEF : Stat.SPDEF); - return stats; + return [ + baseStats[Stat.HP] < baseStats[Stat.SPD] ? Stat.HP : Stat.SPD, + baseStats[Stat.ATK] < baseStats[Stat.SPATK] ? Stat.ATK : Stat.SPATK, + baseStats[Stat.DEF] < baseStats[Stat.SPDEF] ? Stat.DEF : Stat.SPDEF, + ]; } } diff --git a/src/items/held-items/base-stat-total.ts b/src/items/held-items/base-stat-total.ts index 43ba1c697d6..1c1eb154cb3 100644 --- a/src/items/held-items/base-stat-total.ts +++ b/src/items/held-items/base-stat-total.ts @@ -6,7 +6,7 @@ import i18next from "i18next"; export interface BaseStatTotalParams { /** The pokemon with the item */ pokemon: Pokemon; - /** The amount of exp to gain */ + /** Array of the pokemon's base stat; modified in place after item application */ baseStats: number[]; } @@ -56,8 +56,7 @@ export class BaseStatTotalHeldItem extends HeldItem { * @param baseStats the base stats of the {@linkcode Pokemon} * @returns always `true` */ - apply(params: BaseStatTotalParams): boolean { - const baseStats = params.baseStats; + apply({ baseStats }: BaseStatTotalParams): true { // Modifies the passed in baseStats[] array baseStats.forEach((v, i) => { // HP is affected by half as much as other stats diff --git a/src/items/held-items/baton.ts b/src/items/held-items/baton.ts index 02356a995c5..e518f8f0c5d 100644 --- a/src/items/held-items/baton.ts +++ b/src/items/held-items/baton.ts @@ -16,7 +16,7 @@ export class BatonHeldItem extends HeldItem { * Applies {@linkcode SwitchEffectTransferModifier} * @returns always `true` */ - apply(): boolean { + apply(): true { return true; } } diff --git a/src/items/held-items/berry.ts b/src/items/held-items/berry.ts index eeae8261273..3b0b3bcf2f1 100644 --- a/src/items/held-items/berry.ts +++ b/src/items/held-items/berry.ts @@ -66,12 +66,9 @@ export class BerryHeldItem extends ConsumableHeldItem { /** * Applies {@linkcode BerryHeldItem} - * @param pokemon The {@linkcode Pokemon} that holds the berry * @returns always `true` */ - apply(params: BerryParams): boolean { - const pokemon = params.pokemon; - + apply({ pokemon }: BerryParams): boolean { if (!this.shouldApply(pokemon)) { return false; } diff --git a/src/items/held-items/bypass-speed-chance.ts b/src/items/held-items/bypass-speed-chance.ts index df14b07dce0..ba3800d2635 100644 --- a/src/items/held-items/bypass-speed-chance.ts +++ b/src/items/held-items/bypass-speed-chance.ts @@ -9,14 +9,12 @@ import i18next from "i18next"; export interface BypassSpeedChanceParams { /** The pokemon with the item */ pokemon: Pokemon; + /** Holder for whether the speed should be bypassed */ doBypassSpeed: BooleanHolder; } /** - * Modifier used for held items, namely Toxic Orb and Flame Orb, that apply a - * set {@linkcode StatusEffect} at the end of a turn. - * @extends PokemonHeldItemModifier - * @see {@linkcode apply} + * Modifier used for items that allow a Pokémon to bypass the speed chance (Quick Claw). */ export class BypassSpeedChanceHeldItem extends HeldItem { public effects: HeldItemEffect[] = [HeldItemEffect.BYPASS_SPEED_CHANCE]; @@ -33,13 +31,9 @@ export class BypassSpeedChanceHeldItem extends HeldItem { /** * Applies {@linkcode BypassSpeedChanceModifier} - * @param pokemon the {@linkcode Pokemon} that holds the item - * @param doBypassSpeed {@linkcode BooleanHolder} that is `true` if speed should be bypassed * @returns `true` if {@linkcode BypassSpeedChanceModifier} has been applied */ - apply(params: BypassSpeedChanceParams): boolean { - const pokemon = params.pokemon; - const doBypassSpeed = params.doBypassSpeed; + apply({ pokemon, doBypassSpeed }: BypassSpeedChanceParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); if (!doBypassSpeed.value && pokemon.randBattleSeedInt(10) < stackCount) { doBypassSpeed.value = true; diff --git a/src/items/held-items/crit-booster.ts b/src/items/held-items/crit-booster.ts index a388684dd09..d1ba07c90c9 100644 --- a/src/items/held-items/crit-booster.ts +++ b/src/items/held-items/crit-booster.ts @@ -7,6 +7,7 @@ import type { NumberHolder } from "#utils/common"; export interface CritBoostParams { /** The pokemon with the item */ pokemon: Pokemon; + /** The critical hit stage */ critStage: NumberHolder; } @@ -34,8 +35,8 @@ export class CritBoostHeldItem extends HeldItem { * @param critStage {@linkcode NumberHolder} that holds the resulting critical-hit level * @returns always `true` */ - apply(params: CritBoostParams): boolean { - params.critStage.value += this.stageIncrement; + apply({ critStage }: CritBoostParams): boolean { + critStage.value += this.stageIncrement; return true; } } diff --git a/src/items/held-items/damage-money-reward.ts b/src/items/held-items/damage-money-reward.ts index 46ce90796bc..b158640cb7f 100644 --- a/src/items/held-items/damage-money-reward.ts +++ b/src/items/held-items/damage-money-reward.ts @@ -7,7 +7,7 @@ import { NumberHolder } from "#utils/common"; export interface DamageMoneyRewardParams { /** The pokemon with the item */ pokemon: Pokemon; - /** The amount of exp to gain */ + /** The damage, used to calculate the money reward */ damage: number; } @@ -16,13 +16,9 @@ export class DamageMoneyRewardHeldItem extends HeldItem { /** * Applies {@linkcode DamageMoneyRewardModifier} - * @param pokemon The {@linkcode Pokemon} attacking - * @param multiplier {@linkcode NumberHolder} holding the multiplier value * @returns always `true` */ - apply(params: DamageMoneyRewardParams): boolean { - const pokemon = params.pokemon; - const damage = params.damage; + apply({ pokemon, damage }: DamageMoneyRewardParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); const moneyAmount = new NumberHolder(Math.floor(damage * (0.5 * stackCount))); globalScene.applyPlayerItems(TrainerItemEffect.MONEY_MULTIPLIER, { numberHolder: moneyAmount }); diff --git a/src/items/held-items/exp-booster.ts b/src/items/held-items/exp-booster.ts index 5644546132b..d257fc8d774 100644 --- a/src/items/held-items/exp-booster.ts +++ b/src/items/held-items/exp-booster.ts @@ -7,7 +7,7 @@ import i18next from "i18next"; export interface ExpBoostParams { /** The pokemon with the item */ pokemon: Pokemon; - /** The amount of exp to gain */ + /** Holds the amount of experience gained, which may be modified after item application */ expAmount: NumberHolder; } @@ -41,13 +41,9 @@ export class ExpBoosterHeldItem extends HeldItem { /** * Applies {@linkcode PokemonExpBoosterModifier} - * @param _pokemon The {@linkcode Pokemon} to apply the exp boost to - * @param boost {@linkcode NumberHolder} holding the exp boost value * @returns always `true` */ - apply(params: ExpBoostParams): boolean { - const pokemon = params.pokemon; - const expAmount = params.expAmount; + apply({ pokemon, expAmount }: ExpBoostParams): true { const stackCount = pokemon.heldItemManager.getStack(this.type); expAmount.value = Math.floor(expAmount.value * (1 + stackCount * this.boostMultiplier)); diff --git a/src/items/held-items/field-effect.ts b/src/items/held-items/field-effect.ts index c248143578d..a076a2fc7dd 100644 --- a/src/items/held-items/field-effect.ts +++ b/src/items/held-items/field-effect.ts @@ -3,8 +3,9 @@ import { HeldItem, HeldItemEffect } from "#items/held-item"; import type { NumberHolder } from "#utils/common"; export interface FieldEffectParams { - pokemon: Pokemon; /** The pokemon with the item */ + pokemon: Pokemon; + /** Holder for the field effect duration*/ fieldDuration: NumberHolder; } @@ -20,14 +21,11 @@ export class FieldEffectHeldItem extends HeldItem { /** * Provides two more turns per stack to any weather or terrain effect caused * by the holder. - * @param pokemon {@linkcode Pokemon} that holds the held item - * @param fieldDuration {@linkcode NumberHolder} that stores the current field effect duration - * @returns `true` if the field effect extension was applied successfully + * @returns always `true` */ - apply(params: FieldEffectParams): boolean { - const pokemon = params.pokemon; + apply({ pokemon, fieldDuration }: FieldEffectParams): true { const stackCount = pokemon.heldItemManager.getStack(this.type); - params.fieldDuration.value += 2 * stackCount; + fieldDuration.value += 2 * stackCount; return true; } } diff --git a/src/items/held-items/flinch-chance.ts b/src/items/held-items/flinch-chance.ts index 290743fac00..82d716368aa 100644 --- a/src/items/held-items/flinch-chance.ts +++ b/src/items/held-items/flinch-chance.ts @@ -6,6 +6,7 @@ import type { BooleanHolder } from "#utils/common"; export interface FlinchChanceParams { /** The pokemon with the item */ pokemon: Pokemon; + /** Holds whether the attack will cause a flinch */ flinched: BooleanHolder; } @@ -37,13 +38,9 @@ export class FlinchChanceHeldItem extends HeldItem { /** * Applies {@linkcode FlinchChanceModifier} to randomly flinch targets hit. - * @param pokemon - The {@linkcode Pokemon} that holds the item - * @param flinched - A {@linkcode BooleanHolder} holding whether the pokemon has flinched * @returns `true` if {@linkcode FlinchChanceModifier} was applied successfully */ - apply(params: FlinchChanceParams): boolean { - const pokemon = params.pokemon; - const flinched = params.flinched; + apply({ pokemon, flinched }: FlinchChanceParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); // The check for pokemon.summonData is to ensure that a crash doesn't occur when a Pokemon with King's Rock procs a flinch // TODO: Since summonData is always defined now, we can probably remove this diff --git a/src/items/held-items/friendship-booster.ts b/src/items/held-items/friendship-booster.ts index 904f98c0929..960838f8925 100644 --- a/src/items/held-items/friendship-booster.ts +++ b/src/items/held-items/friendship-booster.ts @@ -6,7 +6,7 @@ import i18next from "i18next"; export interface FriendshipBoostParams { /** The pokemon with the item */ pokemon: Pokemon; - /** The amount of exp to gain */ + /** Holder for the friendship amount to be changed by the item */ friendship: NumberHolder; } @@ -19,13 +19,9 @@ export class FriendshipBoosterHeldItem extends HeldItem { /** * Applies {@linkcode PokemonFriendshipBoosterModifier} - * @param _pokemon The {@linkcode Pokemon} to apply the friendship boost to - * @param friendship {@linkcode NumberHolder} holding the friendship boost value * @returns always `true` */ - apply(params: FriendshipBoostParams): boolean { - const pokemon = params.pokemon; - const friendship = params.friendship; + apply({ pokemon, friendship }: FriendshipBoostParams): true { const stackCount = pokemon.heldItemManager.getStack(this.type); friendship.value = Math.floor(friendship.value * (1 + 0.5 * stackCount)); diff --git a/src/items/held-items/hit-heal.ts b/src/items/held-items/hit-heal.ts index 522c3e018d7..5d4a05582ec 100644 --- a/src/items/held-items/hit-heal.ts +++ b/src/items/held-items/hit-heal.ts @@ -28,11 +28,9 @@ export class HitHealHeldItem extends HeldItem { /** * Applies {@linkcode HitHealModifier} - * @param pokemon The {@linkcode Pokemon} that holds the item * @returns `true` if the {@linkcode Pokemon} was healed */ - apply(params: HitHealParams): boolean { - const pokemon = params.pokemon; + apply({ pokemon }: HitHealParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); if (pokemon.turnData.totalDamageDealt > 0 && !pokemon.isFullHp()) { // TODO: this shouldn't be undefined AFAIK diff --git a/src/items/held-items/incrementing-stat.ts b/src/items/held-items/incrementing-stat.ts index 9b11a51944b..a462b70326e 100644 --- a/src/items/held-items/incrementing-stat.ts +++ b/src/items/held-items/incrementing-stat.ts @@ -7,7 +7,9 @@ import i18next from "i18next"; export interface IncrementingStatParams { /** The pokemon with the item */ pokemon: Pokemon; + /** The stat whose value is being impacted */ stat: Stat; + /** Holds the stat's value, which may be modified after item application */ // TODO: https://github.com/pagefaultgames/pokerogue/pull/5656#discussion_r2135612276 statHolder: NumberHolder; } @@ -40,19 +42,14 @@ export class IncrementingStatHeldItem extends HeldItem { /** * Applies the {@linkcode PokemonIncrementingStatModifier} - * @param _pokemon The {@linkcode Pokemon} that holds the item - * @param stat The affected {@linkcode Stat} - * @param statHolder The {@linkcode NumberHolder} that holds the stat * @returns always `true` */ - apply(params: IncrementingStatParams): boolean { - const pokemon = params.pokemon; + apply({ pokemon, statHolder, stat }: IncrementingStatParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); - const statHolder = params.statHolder; // Modifies the passed in stat number holder by +2 per stack for HP, +1 per stack for other stats // If the Macho Brace is at max stacks (50), adds additional 10% to total HP and 5% to other stats - const isHp = params.stat === Stat.HP; + const isHp = stat === Stat.HP; if (isHp) { statHolder.value += 2 * stackCount; diff --git a/src/items/held-items/instant-revive.ts b/src/items/held-items/instant-revive.ts index 7dd6b359577..10137efe61d 100644 --- a/src/items/held-items/instant-revive.ts +++ b/src/items/held-items/instant-revive.ts @@ -35,11 +35,9 @@ export class InstantReviveHeldItem extends ConsumableHeldItem { /** * Goes through the holder's stat stages and, if any are negative, resets that * stat stage back to 0. - * @param pokemon {@linkcode Pokemon} that holds the item * @returns `true` if any stat stages were reset, false otherwise */ - apply(params: InstantReviveParams): boolean { - const pokemon = params.pokemon; + apply({ pokemon }: InstantReviveParams): boolean { // Restore the Pokemon to half HP globalScene.phaseManager.unshiftPhase( new PokemonHealPhase( diff --git a/src/items/held-items/item-steal.ts b/src/items/held-items/item-steal.ts index 64734ddc84e..acba8d6930f 100644 --- a/src/items/held-items/item-steal.ts +++ b/src/items/held-items/item-steal.ts @@ -4,7 +4,7 @@ import { allHeldItems } from "#data/data-lists"; import type { HeldItemId } from "#enums/held-item-id"; import { Pokemon } from "#field/pokemon"; import { HeldItem, HeldItemEffect } from "#items/held-item"; -import { randSeedFloat } from "#utils/common"; +import { coerceArray, randSeedFloat } from "#utils/common"; import i18next from "i18next"; export interface ItemStealParams { @@ -148,20 +148,20 @@ export class ContactItemStealChanceHeldItem extends ItemTransferHeldItem { * @param targetPokemon The {@linkcode Pokemon} the holder is targeting with an attack * @returns The target {@linkcode Pokemon} as array for further use in `apply` implementations */ - getTargets(params: ItemStealParams): Pokemon[] { - return params.target ? [params.target] : []; + getTargets({ target }: ItemStealParams): Pokemon[] { + return target ? coerceArray(target) : []; } - getTransferredItemCount(params: ItemStealParams): number { - const stackCount = params.pokemon.heldItemManager.getStack(this.type); + getTransferredItemCount({ pokemon }: ItemStealParams): number { + const stackCount = pokemon.heldItemManager.getStack(this.type); return randSeedFloat() <= this.chance * stackCount ? 1 : 0; } - getTransferMessage(params: ItemStealParams, itemId: HeldItemId): string { + getTransferMessage({ pokemon, target }: ItemStealParams, itemId: HeldItemId): string { return i18next.t("modifier:contactHeldItemTransferApply", { - pokemonNameWithAffix: getPokemonNameWithAffix(params.target), + pokemonNameWithAffix: getPokemonNameWithAffix(target), itemName: allHeldItems[itemId].name, - pokemonName: params.pokemon.getNameToRender(), + pokemonName: pokemon.getNameToRender(), typeName: this.name, }); } diff --git a/src/items/held-items/multi-hit.ts b/src/items/held-items/multi-hit.ts index d288039bceb..66cb7cdfa2b 100644 --- a/src/items/held-items/multi-hit.ts +++ b/src/items/held-items/multi-hit.ts @@ -6,9 +6,13 @@ import { isNullOrUndefined, type NumberHolder } from "#utils/common"; import i18next from "i18next"; export interface MultiHitParams { + /** The pokemon with the item */ pokemon: Pokemon; + /** The move being used */ moveId: MoveId; + /** Holder for the move's hit count for the turn */ count?: NumberHolder; + /** Holder for the damage multiplier applied to a strike of the move */ damageMultiplier?: NumberHolder; } @@ -27,16 +31,11 @@ export class MultiHitHeldItem extends HeldItem { /** * For each stack, converts 25 percent of attack damage into an additional strike. - * @param pokemon The {@linkcode Pokemon} using the move - * @param moveId The {@linkcode MoveId | identifier} for the move being used - * @param count {@linkcode NumberHolder} holding the move's hit count for this turn - * @param damageMultiplier {@linkcode NumberHolder} holding a damage multiplier applied to a strike of this move - * @returns always `true` + * @returns Whether the item applies its effects to move */ - apply(params: MultiHitParams): boolean { - const pokemon = params.pokemon; - const move = allMoves[params.moveId]; - /** + apply({ pokemon, count, moveId, damageMultiplier }: MultiHitParams): boolean { + const move = allMoves[moveId]; + /* * The move must meet Parental Bond's restrictions for this item * to apply. This means * - Only attacks are boosted @@ -49,11 +48,11 @@ export class MultiHitHeldItem extends HeldItem { return false; } - if (!isNullOrUndefined(params.count)) { - return this.applyHitCountBoost(pokemon, params.count); + if (!isNullOrUndefined(count)) { + return this.applyHitCountBoost(pokemon, count); } - if (!isNullOrUndefined(params.damageMultiplier)) { - return this.applyDamageModifier(pokemon, params.damageMultiplier); + if (!isNullOrUndefined(damageMultiplier)) { + return this.applyDamageModifier(pokemon, damageMultiplier); } return false; diff --git a/src/items/held-items/nature-weight-booster.ts b/src/items/held-items/nature-weight-booster.ts index 2bf6e8133f4..ec6e91eb437 100644 --- a/src/items/held-items/nature-weight-booster.ts +++ b/src/items/held-items/nature-weight-booster.ts @@ -5,7 +5,7 @@ import type { NumberHolder } from "#utils/common"; export interface NatureWeightBoostParams { /** The pokemon with the item */ pokemon: Pokemon; - /** The amount of exp to gain */ + /** Holder for the multiplier */ multiplier: NumberHolder; } @@ -14,13 +14,9 @@ export class NatureWeightBoosterHeldItem extends HeldItem { /** * Applies {@linkcode PokemonNatureWeightModifier} - * @param _pokemon The {@linkcode Pokemon} to apply the nature weight to - * @param multiplier {@linkcode NumberHolder} holding the nature weight * @returns `true` if multiplier was applied */ - apply(params: NatureWeightBoostParams): boolean { - const pokemon = params.pokemon; - const multiplier = params.multiplier; + apply({ pokemon, multiplier }: NatureWeightBoostParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); if (multiplier.value !== 1) { multiplier.value += 0.1 * stackCount * (multiplier.value > 1 ? 1 : -1); diff --git a/src/items/held-items/reset-negative-stat-stage.ts b/src/items/held-items/reset-negative-stat-stage.ts index 152f0431a96..0714270cc51 100644 --- a/src/items/held-items/reset-negative-stat-stage.ts +++ b/src/items/held-items/reset-negative-stat-stage.ts @@ -35,12 +35,9 @@ export class ResetNegativeStatStageHeldItem extends ConsumableHeldItem { /** * Goes through the holder's stat stages and, if any are negative, resets that * stat stage back to 0. - * @param pokemon {@linkcode Pokemon} that holds the item * @returns `true` if any stat stages were reset, false otherwise */ - apply(params: ResetNegativeStatStageParams): boolean { - const pokemon = params.pokemon; - const isPlayer = params.isPlayer; + apply({ pokemon, isPlayer }: ResetNegativeStatStageParams): boolean { let statRestored = false; for (const s of BATTLE_STATS) { diff --git a/src/items/held-items/stat-booster.ts b/src/items/held-items/stat-booster.ts index 435ca331825..aa7eaea93ec 100644 --- a/src/items/held-items/stat-booster.ts +++ b/src/items/held-items/stat-booster.ts @@ -47,14 +47,11 @@ export class StatBoostHeldItem extends HeldItem { /** * Boosts the incoming stat by a {@linkcode multiplier} if the stat is listed * in {@linkcode stats}. - * @param _pokemon the {@linkcode Pokemon} that holds the item - * @param _stat the {@linkcode Stat} to be boosted - * @param statValue {@linkcode NumberHolder} that holds the resulting value of the stat * @returns `true` if the stat boost applies successfully, false otherwise * @see shouldApply */ - apply(params: StatBoostParams): boolean { - params.statValue.value *= this.multiplier; + apply({ statValue }: StatBoostParams): boolean { + statValue.value *= this.multiplier; return true; } @@ -88,9 +85,6 @@ export class EvolutionStatBoostHeldItem extends StatBoostHeldItem { * only half of the boost if either of the fused members are fully * evolved. However, if they are both unevolved, the full boost * will apply. - * @param pokemon {@linkcode Pokemon} that holds the item - * @param _stat {@linkcode Stat} The {@linkcode Stat} to be boosted - * @param statValue{@linkcode NumberHolder} that holds the resulting value of the stat * @returns `true` if the stat boost applies successfully, false otherwise * @see shouldApply */ diff --git a/src/items/held-items/survive-chance.ts b/src/items/held-items/survive-chance.ts index ef9256f030f..4120e452d1a 100644 --- a/src/items/held-items/survive-chance.ts +++ b/src/items/held-items/survive-chance.ts @@ -32,13 +32,9 @@ export class SurviveChanceHeldItem extends HeldItem { /** * Applies {@linkcode SurviveDamageModifier} - * @param pokemon the {@linkcode Pokemon} that holds the item - * @param surviveDamage {@linkcode BooleanHolder} that holds the survive damage * @returns `true` if the survive damage has been applied */ - apply(params: SurviveChanceParams): boolean { - const pokemon = params.pokemon; - const surviveDamage = params.surviveDamage; + apply({ pokemon, surviveDamage }: SurviveChanceParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); if (!surviveDamage.value && pokemon.randBattleSeedInt(10) < stackCount) { surviveDamage.value = true; diff --git a/src/items/held-items/turn-end-heal.ts b/src/items/held-items/turn-end-heal.ts index 3acc5861a8e..598b9bc61fa 100644 --- a/src/items/held-items/turn-end-heal.ts +++ b/src/items/held-items/turn-end-heal.ts @@ -14,8 +14,7 @@ export interface TurnEndHealParams { export class TurnEndHealHeldItem extends HeldItem { public effects: HeldItemEffect[] = [HeldItemEffect.TURN_END_HEAL]; - apply(params: TurnEndHealParams): boolean { - const pokemon = params.pokemon; + apply({ pokemon }: TurnEndHealParams): boolean { const stackCount = pokemon.heldItemManager.getStack(this.type); if (pokemon.isFullHp()) { return false; diff --git a/src/items/held-items/turn-end-status.ts b/src/items/held-items/turn-end-status.ts index d746b59419d..d6cbe240fd1 100644 --- a/src/items/held-items/turn-end-status.ts +++ b/src/items/held-items/turn-end-status.ts @@ -27,11 +27,10 @@ export class TurnEndStatusHeldItem extends HeldItem { /** * Tries to inflicts the holder with the associated {@linkcode StatusEffect}. - * @param pokemon {@linkcode Pokemon} that holds the held item * @returns `true` if the status effect was applied successfully */ - apply(params: TurnEndStatusParams): boolean { - return params.pokemon.trySetStatus(this.effect, true, undefined, undefined, this.name); + apply({ pokemon }: TurnEndStatusParams): boolean { + return pokemon.trySetStatus(this.effect, true, undefined, undefined, this.name); } getStatusEffect(): StatusEffect { diff --git a/src/items/trainer-item.ts b/src/items/trainer-item.ts index 2553a01b795..2c2200b38be 100644 --- a/src/items/trainer-item.ts +++ b/src/items/trainer-item.ts @@ -67,15 +67,15 @@ export class TrainerItem { this.maxStackCount = maxStackCount; } - get name(): string { + public get name(): string { return i18next.t(`modifierType:ModifierType.${TrainerItemNames[this.type]}.name`); } - get description(): string { + public get description(): string { return i18next.t(`modifierType:ModifierType.${TrainerItemNames[this.type]}.description`); } - get iconName(): string { + public get iconName(): string { return `${TrainerItemNames[this.type]?.toLowerCase()}`; } @@ -84,10 +84,9 @@ export class TrainerItem { } createIcon(stackCount: number): Phaser.GameObjects.Container { - const container = globalScene.add.container(0, 0); + const container = globalScene.add.container(); - const item = globalScene.add.sprite(0, 12, "items").setFrame(this.iconName).setOrigin(0, 0.5); - container.add(item); + container.add(globalScene.add.sprite(0, 12, "items").setFrame(this.iconName).setOrigin(0, 0.5)); const stackText = this.getIconStackText(stackCount); if (stackText) { @@ -102,12 +101,13 @@ export class TrainerItem { return null; } - const text = globalScene.add.bitmapText(10, 15, "item-count", stackCount.toString(), 11); - text.letterSpacing = -0.5; + const text = globalScene.add + .bitmapText(10, 15, "item-count", stackCount.toString(), 11) + .setLetterSpacing(-0.5) + .setOrigin(0); if (stackCount >= this.getMaxStackCount()) { text.setTint(0xf89890); } - text.setOrigin(0); return text; }