From 5e2dfa975a5f7729ae4fab0340ee4ea67e883fd8 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:09:28 -0800 Subject: [PATCH] Rename `PokemonTurnData`'s `damageDealt` and `currDamageDealt` (#4784) --- src/data/ability.ts | 2 +- src/data/move.ts | 6 +++--- src/field/pokemon.ts | 9 ++++----- src/modifier/modifier.ts | 4 ++-- src/test/moves/focus_punch.test.ts | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 6c503bb4100..87f9e89e534 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -4969,7 +4969,7 @@ class ForceSwitchOutHelper { function calculateShellBellRecovery(pokemon: Pokemon): number { const shellBellModifier = pokemon.getHeldItems().find(m => m instanceof HitHealModifier); if (shellBellModifier) { - return Utils.toDmgValue(pokemon.turnData.damageDealt / 8) * shellBellModifier.stackCount; + return Utils.toDmgValue(pokemon.turnData.totalDamageDealt / 8) * shellBellModifier.stackCount; } return 0; } diff --git a/src/data/move.ts b/src/data/move.ts index db49f86021f..cd206755238 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1474,8 +1474,8 @@ export class RecoilAttr extends MoveEffectAttr { return false; } - const damageValue = (!this.useHp ? user.turnData.damageDealt : user.getMaxHp()) * this.damageRatio; - const minValue = user.turnData.damageDealt ? 1 : 0; + const damageValue = (!this.useHp ? user.turnData.totalDamageDealt : user.getMaxHp()) * this.damageRatio; + const minValue = user.turnData.totalDamageDealt ? 1 : 0; const recoilDamage = Utils.toDmgValue(damageValue, minValue); if (!recoilDamage) { return false; @@ -2006,7 +2006,7 @@ export class HitHealAttr extends MoveEffectAttr { message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) }); } else { // Default healing formula used by draining moves like Absorb, Draining Kiss, Bitter Blade, etc. - healAmount = Utils.toDmgValue(user.turnData.currDamageDealt * this.healRatio); + healAmount = Utils.toDmgValue(user.turnData.singleHitDamageDealt * this.healRatio); message = i18next.t("battle:regainHealth", { pokemonName: getPokemonNameWithAffix(user) }); } if (reverseDrain) { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index c77aeed617b..6c328fa25cc 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2827,8 +2827,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.scene.gameData.gameStats.highestDamage = damage; } } - source.turnData.damageDealt += damage; - source.turnData.currDamageDealt = damage; + source.turnData.totalDamageDealt += damage; + source.turnData.singleHitDamageDealt = damage; this.turnData.damageTaken += damage; this.battleData.hitCount++; @@ -5130,7 +5130,6 @@ export class PokemonSummonData { public tags: BattlerTag[] = []; public abilitySuppressed: boolean = false; public abilitiesApplied: Abilities[] = []; - public speciesForm: PokemonSpeciesForm | null; public fusionSpeciesForm: PokemonSpeciesForm; public ability: Abilities = Abilities.NONE; @@ -5170,8 +5169,8 @@ export class PokemonTurnData { * - `0` = Move is finished */ public hitsLeft: number = -1; - public damageDealt: number = 0; - public currDamageDealt: number = 0; + public totalDamageDealt: number = 0; + public singleHitDamageDealt: number = 0; public damageTaken: number = 0; public attacksReceived: AttackMoveResult[] = []; public order: number; diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 36f94b99b20..d34804ba040 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1767,10 +1767,10 @@ export class HitHealModifier extends PokemonHeldItemModifier { * @returns `true` if the {@linkcode Pokemon} was healed */ override apply(pokemon: Pokemon): boolean { - if (pokemon.turnData.damageDealt && !pokemon.isFullHp()) { + if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) { const scene = pokemon.scene; scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), - toDmgValue(pokemon.turnData.damageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); + toDmgValue(pokemon.turnData.totalDamageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); } return true; diff --git a/src/test/moves/focus_punch.test.ts b/src/test/moves/focus_punch.test.ts index 386eb2537ee..352e3b60aa4 100644 --- a/src/test/moves/focus_punch.test.ts +++ b/src/test/moves/focus_punch.test.ts @@ -59,7 +59,7 @@ describe("Moves - Focus Punch", () => { expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); expect(leadPokemon.getMoveHistory().length).toBe(1); - expect(leadPokemon.turnData.damageDealt).toBe(enemyStartingHp - enemyPokemon.hp); + expect(leadPokemon.turnData.totalDamageDealt).toBe(enemyStartingHp - enemyPokemon.hp); } ); @@ -86,7 +86,7 @@ describe("Moves - Focus Punch", () => { expect(enemyPokemon.hp).toBe(enemyStartingHp); expect(leadPokemon.getMoveHistory().length).toBe(1); - expect(leadPokemon.turnData.damageDealt).toBe(0); + expect(leadPokemon.turnData.totalDamageDealt).toBe(0); } );