Shell bell

This commit is contained in:
Wlowscha 2025-06-01 04:03:04 +02:00
parent 096c3e018e
commit cf19a01c37
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
4 changed files with 84 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { HeldItems } from "#enums/held-items";
import type { PokemonType } from "#enums/pokemon-type";
import { AttackTypeBoosterHeldItem, attackTypeToHeldItem } from "./held-items/attack-type-booster";
import { HitHealHeldItem } from "./held-items/hit-heal";
import { TurnHealHeldItem } from "./held-items/turn-heal";
export const allHeldItems = {};
@ -12,5 +13,6 @@ export function initHeldItems() {
allHeldItems[heldItemType] = new AttackTypeBoosterHeldItem(heldItemType, 99, pokemonType, 0.2);
}
allHeldItems[HeldItems.LEFTOVERS] = new TurnHealHeldItem(HeldItems.LEFTOVERS, 4);
allHeldItems[HeldItems.SHELL_BELL] = new HitHealHeldItem(HeldItems.LEFTOVERS, 4);
console.log(allHeldItems);
}

View File

@ -0,0 +1,55 @@
import type Pokemon from "#app/field/pokemon";
import { globalScene } from "#app/global-scene";
import i18next from "i18next";
import { HeldItem } from "#app/items/held-item";
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
import { toDmgValue } from "#app/utils/common";
import { getPokemonNameWithAffix } from "#app/messages";
import { allHeldItems } from "../all-held-items";
export class HitHealHeldItem extends HeldItem {
get name(): string {
return i18next.t("modifierType:ModifierType.SHELL_BELL.name");
}
get description(): string {
return i18next.t("modifierType:ModifierType.SHELL_BELL.description");
}
get icon(): string {
return "shell_bell";
}
/**
* Applies {@linkcode HitHealModifier}
* @param pokemon The {@linkcode Pokemon} that holds the item
* @returns `true` if the {@linkcode Pokemon} was healed
*/
apply(stackCount: number, pokemon: Pokemon): boolean {
if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) {
// TODO: this shouldn't be undefined AFAIK
globalScene.unshiftPhase(
new PokemonHealPhase(
pokemon.getBattlerIndex(),
toDmgValue(pokemon.turnData.totalDamageDealt / 8) * stackCount,
i18next.t("modifier:hitHealApply", {
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
typeName: this.name,
}),
true,
),
);
}
return true;
}
}
export function applyHitHealHeldItem(pokemon: Pokemon) {
if (pokemon) {
for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) {
if (allHeldItems[item] instanceof HitHealHeldItem) {
allHeldItems[item].apply(props.stack, pokemon);
}
}
}
}

View File

@ -2363,6 +2363,9 @@ export const modifierTypes = {
LEFTOVERS_REWARD: () =>
new PokemonHeldItemReward(HeldItems.LEFTOVERS, (type, args) => new TurnHealModifier(type, (args[0] as Pokemon).id)),
SHELL_BELL_REWARD: () =>
new PokemonHeldItemReward(HeldItems.SHELL_BELL, (type, args) => new HitHealModifier(type, (args[0] as Pokemon).id)),
LEFTOVERS: () =>
new PokemonHeldItemModifierType(
"modifierType:ModifierType.LEFTOVERS",
@ -3051,7 +3054,7 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.ROGUE_BALL, () => (hasMaximumBalls(PokeballType.ROGUE_BALL) ? 0 : 16), 16),
new WeightedModifierType(modifierTypes.RELIC_GOLD, skipInLastClassicWaveOrDefault(2)),
new WeightedModifierType(modifierTypes.LEFTOVERS_REWARD, 3),
new WeightedModifierType(modifierTypes.SHELL_BELL, 3),
new WeightedModifierType(modifierTypes.SHELL_BELL_REWARD, 3),
new WeightedModifierType(modifierTypes.BERRY_POUCH, 4),
new WeightedModifierType(modifierTypes.GRIP_CLAW, 5),
new WeightedModifierType(modifierTypes.SCOPE_LENS, 4),
@ -3675,6 +3678,27 @@ export function getEnemyModifierTypesForWave(
return ret;
}
export function getEnemyHeldItemsForWave(
waveIndex: number,
count: number,
party: EnemyPokemon[],
poolType: ModifierPoolType.WILD | ModifierPoolType.TRAINER,
upgradeChance = 0,
): PokemonHeldItemReward[] {
const ret = new Array(count)
.fill(0)
.map(
() =>
getNewModifierTypeOption(party, poolType, undefined, upgradeChance && !randSeedInt(upgradeChance) ? 1 : 0)
?.type as PokemonHeldItemReward,
);
if (!(waveIndex % 1000)) {
// TODO: Change this line with the actual held item when implemented
ret.push(getModifierType(modifierTypes.MINI_BLACK_HOLE) as PokemonHeldItemReward);
}
return ret;
}
export function getDailyRunStarterModifiers(party: PlayerPokemon[]): PokemonHeldItemModifier[] {
const ret: PokemonHeldItemModifier[] = [];
for (const p of party) {

View File

@ -78,6 +78,7 @@ import type Move from "#app/data/moves/move";
import { isFieldTargeted } from "#app/data/moves/move-utils";
import { FaintPhase } from "./faint-phase";
import { DamageAchv } from "#app/system/achv";
import { applyHitHealHeldItem } from "#app/items/held-items/hit-heal";
type HitCheckEntry = [HitCheckResult, TypeDamageMultiplier];
@ -416,7 +417,7 @@ export class MoveEffectPhase extends PokemonPhase {
// If there are multiple hits, or if there are hits of the multi-hit move left
globalScene.queueMessage(i18next.t("battle:attackHitsCount", { count: hitsTotal }));
}
globalScene.applyModifiers(HitHealModifier, this.player, user);
applyHitHealHeldItem(user);
this.getTargets().forEach(target => (target.turnData.moveEffectiveness = null));
}
}