From b46377fab4d655c41eb0fa3890f749ed6f545a64 Mon Sep 17 00:00:00 2001 From: shayebeadlingkl Date: Fri, 10 May 2024 15:54:32 -0400 Subject: [PATCH] implements modifier, works correctly. does not spawn item or have correct icon --- src/data/move.ts | 9 +++++++-- src/modifier/modifier-type.ts | 3 +++ src/modifier/modifier.ts | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 978f5109148..dab737f7208 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -15,7 +15,7 @@ import { ArenaTagType } from "./enums/arena-tag-type"; import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, ReverseDrainAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr } from "./ability"; import { Abilities } from "./enums/abilities"; import { allAbilities } from './ability'; -import { PokemonHeldItemModifier } from "../modifier/modifier"; +import { ExtendScreenModifier, PokemonHeldItemModifier } from "../modifier/modifier"; import { BattlerIndex } from "../battle"; import { Stat } from "./pokemon-stat"; import { TerrainType } from "./terrain"; @@ -3035,8 +3035,13 @@ export class AddArenaTagAttr extends MoveEffectAttr { if (!super.apply(user, target, move, args)) return false; + const turnCountHolder = new Utils.IntegerHolder(this.turnCount); + + if ([ArenaTagType.REFLECT, ArenaTagType.LIGHT_SCREEN, ArenaTagType.AURORA_VEIL].includes(this.tagType)) + user.scene.applyModifiers(ExtendScreenModifier, user.isPlayer(), user, turnCountHolder); + if (move.chance < 0 || move.chance === 100 || user.randSeedInt(100) < move.chance) { - user.scene.arena.addTag(this.tagType, this.turnCount, move.id, user.id, (this.selfSideTarget ? user : target).isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY); + user.scene.arena.addTag(this.tagType, turnCountHolder.value, move.id, user.id, (this.selfSideTarget ? user : target).isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY); return true; } diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 2457a705bce..6a673caabed 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -918,6 +918,9 @@ export const modifierTypes = { HEALING_CHARM: () => new ModifierType('Healing Charm', 'Increases the effectiveness of HP restoring moves and items by 10% (excludes Revives)', (type, _args) => new Modifiers.HealingBoosterModifier(type, 1.1), 'healing_charm'), CANDY_JAR: () => new ModifierType('Candy Jar', 'Increases the number of levels added by Rare Candy items by 1', (type, _args) => new Modifiers.LevelIncrementBoosterModifier(type)), + + LIGHT_CLAY: () => new ModifierType('Light Clay', 'Aurora Veil, Light Screen, or Reflect lasts 8 turns instead of 5.', + (type, _args) => new Modifiers.ExtendScreenModifier(type), 'coin_case'), BERRY_POUCH: () => new ModifierType('Berry Pouch', 'Adds a 25% chance that a used berry will not be consumed', (type, _args) => new Modifiers.PreserveBerryModifier(type)), diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index ba009cb7a8d..c73a33e9e7f 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -918,6 +918,35 @@ export class PreserveBerryModifier extends PersistentModifier { } } +export class ExtendScreenModifier extends PersistentModifier { + constructor(type: ModifierType, stackCount?: integer) { + super(type, stackCount); + } + + match(modifier: Modifier) { + return modifier instanceof ExtendScreenModifier; + } + + clone() { + return new ExtendScreenModifier(this.type, this.stackCount); + } + + shouldApply(args: any[]): boolean { + return super.shouldApply(args) && args[0] instanceof Pokemon && args[1] instanceof Utils.IntegerHolder; + } + + apply(args: any[]): boolean { + if ((args[1] as Utils.IntegerHolder).value) + (args[1] as Utils.IntegerHolder).value = (args[1] as Utils.IntegerHolder).value + 3; + + return true; + } + + getMaxStackCount(scene: BattleScene): integer { + return 1; + } +} + export class PokemonInstantReviveModifier extends PokemonHeldItemModifier { constructor(type: ModifierType, pokemonId: integer, stackCount?: integer) { super(type, pokemonId, stackCount);