mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-09 00:49:27 +02:00
Add parameter destructuring (#6092)
This commit is contained in:
parent
97e5ab882a
commit
315d4cf408
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -16,7 +16,7 @@ export class BatonHeldItem extends HeldItem {
|
||||
* Applies {@linkcode SwitchEffectTransferModifier}
|
||||
* @returns always `true`
|
||||
*/
|
||||
apply(): boolean {
|
||||
apply(): true {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 });
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user