diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 027f1782481..59b040ca9d8 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2320,19 +2320,22 @@ export class TypeBoostTag extends SerializableBattlerTag { export class CritBoostTag extends SerializableBattlerTag { public declare readonly tagType: CritStageBoostTagType; /** The number of stages boosted by this tag */ - #critStages: number; - /** The number of stages boosted by this tag */ - public get critStages(): number { - return this.#critStages; - } - constructor(tagType: CritStageBoostTagType, sourceMove: MoveId, stages = 1) { + public readonly critStages: number; + + constructor(tagType: CritStageBoostTagType, sourceMove: MoveId) { super(tagType, BattlerTagLapseType.TURN_END, 1, sourceMove, undefined, true); - this.#critStages = stages; } onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); + // Dragon cheer adds +2 crit stages if the pokemon is a Dragon type when the tag is added + if (this.tagType === BattlerTagType.DRAGON_CHEER && pokemon.getTypes(true).includes(PokemonType.DRAGON)) { + (this as Mutable).critStages = 2; + } else { + (this as Mutable).critStages = 1; + } + globalScene.phaseManager.queueMessage( i18next.t("battlerTags:critBoostOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), @@ -2353,6 +2356,13 @@ export class CritBoostTag extends SerializableBattlerTag { }), ); } + + public override loadTag(source: BaseBattlerTag & Pick): void { + super.loadTag(source); + // TODO: Remove the nullish coalescing once Zod Schemas come in + // For now, this is kept for backwards compatibility with older save files + (this as Mutable).critStages = source.critStages ?? 1; + } } export class SaltCuredTag extends SerializableBattlerTag { @@ -3734,9 +3744,8 @@ export function getBattlerTag( case BattlerTagType.FIRE_BOOST: return new TypeBoostTag(tagType, sourceMove, PokemonType.FIRE, 1.5, false); case BattlerTagType.CRIT_BOOST: - return new CritBoostTag(tagType, sourceMove); case BattlerTagType.DRAGON_CHEER: - return new CritBoostTag(tagType, sourceMove, 2); + return new CritBoostTag(tagType, sourceMove); case BattlerTagType.ALWAYS_CRIT: case BattlerTagType.IGNORE_ACCURACY: return new SerializableBattlerTag(tagType, BattlerTagLapseType.TURN_END, 2, sourceMove); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 7aecc0c8e75..7cb6f30c99e 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -25,7 +25,6 @@ import { AutotomizedTag, BattlerTag, CritBoostTag, - DragonCheerTag, EncoreTag, ExposedTag, GroundedTag, @@ -1390,8 +1389,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container { const critBoostTag = source.getTag(CritBoostTag); if (critBoostTag) { // Dragon cheer only gives +1 crit stage to non-dragon types - critStage.value += - critBoostTag instanceof DragonCheerTag && !critBoostTag.typesOnAdd.includes(PokemonType.DRAGON) ? 1 : 2; + critStage.value += critBoostTag.critStages; } console.log(`crit stage: +${critStage.value}`);