Merge branch 'beta' into pokemon.ts-cleanup

This commit is contained in:
Tempoanon 2024-11-03 21:48:27 -05:00 committed by GitHub
commit b839ed64d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 14 deletions

View File

@ -1956,6 +1956,10 @@ export class CopyFaintedAllyAbilityAbAttr extends PostKnockOutAbAttr {
} }
} }
/**
* Ability attribute for ignoring the opponent's stat changes
* @param stats the stats that should be ignored
*/
export class IgnoreOpponentStatStagesAbAttr extends AbAttr { export class IgnoreOpponentStatStagesAbAttr extends AbAttr {
private stats: readonly BattleStat[]; private stats: readonly BattleStat[];
@ -1965,6 +1969,15 @@ export class IgnoreOpponentStatStagesAbAttr extends AbAttr {
this.stats = stats ?? BATTLE_STATS; this.stats = stats ?? BATTLE_STATS;
} }
/**
* Modifies a BooleanHolder and returns the result to see if a stat is ignored or not
* @param _pokemon n/a
* @param _passive n/a
* @param simulated n/a
* @param _cancelled n/a
* @param args A BooleanHolder that represents whether or not to ignore a stat's stat changes
* @returns true if the stat is ignored, false otherwise
*/
apply(_pokemon: Pokemon, _passive: boolean, simulated: boolean, _cancelled: Utils.BooleanHolder, args: any[]) { apply(_pokemon: Pokemon, _passive: boolean, simulated: boolean, _cancelled: Utils.BooleanHolder, args: any[]) {
if (this.stats.includes(args[0])) { if (this.stats.includes(args[0])) {
(args[1] as Utils.BooleanHolder).value = true; (args[1] as Utils.BooleanHolder).value = true;
@ -4969,7 +4982,7 @@ class ForceSwitchOutHelper {
function calculateShellBellRecovery(pokemon: Pokemon): number { function calculateShellBellRecovery(pokemon: Pokemon): number {
const shellBellModifier = pokemon.getHeldItems().find(m => m instanceof HitHealModifier); const shellBellModifier = pokemon.getHeldItems().find(m => m instanceof HitHealModifier);
if (shellBellModifier) { if (shellBellModifier) {
return Utils.toDmgValue(pokemon.turnData.damageDealt / 8) * shellBellModifier.stackCount; return Utils.toDmgValue(pokemon.turnData.totalDamageDealt / 8) * shellBellModifier.stackCount;
} }
return 0; return 0;
} }
@ -5361,6 +5374,7 @@ export function initAbilities() {
new Ability(Abilities.ILLUMINATE, 3) new Ability(Abilities.ILLUMINATE, 3)
.attr(ProtectStatAbAttr, Stat.ACC) .attr(ProtectStatAbAttr, Stat.ACC)
.attr(DoubleBattleChanceAbAttr) .attr(DoubleBattleChanceAbAttr)
.attr(IgnoreOpponentStatStagesAbAttr, [ Stat.EVA ])
.ignorable(), .ignorable(),
new Ability(Abilities.TRACE, 3) new Ability(Abilities.TRACE, 3)
.attr(PostSummonCopyAbilityAbAttr) .attr(PostSummonCopyAbilityAbAttr)
@ -5580,7 +5594,7 @@ export function initAbilities() {
new Ability(Abilities.FOREWARN, 4) new Ability(Abilities.FOREWARN, 4)
.attr(ForewarnAbAttr), .attr(ForewarnAbAttr),
new Ability(Abilities.UNAWARE, 4) new Ability(Abilities.UNAWARE, 4)
.attr(IgnoreOpponentStatStagesAbAttr) .attr(IgnoreOpponentStatStagesAbAttr, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA ])
.ignorable(), .ignorable(),
new Ability(Abilities.TINTED_LENS, 4) new Ability(Abilities.TINTED_LENS, 4)
.attr(DamageBoostAbAttr, 2, (user, target, move) => (target?.getMoveEffectiveness(user!, move) ?? 1) <= 0.5), .attr(DamageBoostAbAttr, 2, (user, target, move) => (target?.getMoveEffectiveness(user!, move) ?? 1) <= 0.5),

View File

@ -1474,8 +1474,8 @@ export class RecoilAttr extends MoveEffectAttr {
return false; return false;
} }
const damageValue = (!this.useHp ? user.turnData.damageDealt : user.getMaxHp()) * this.damageRatio; const damageValue = (!this.useHp ? user.turnData.totalDamageDealt : user.getMaxHp()) * this.damageRatio;
const minValue = user.turnData.damageDealt ? 1 : 0; const minValue = user.turnData.totalDamageDealt ? 1 : 0;
const recoilDamage = Utils.toDmgValue(damageValue, minValue); const recoilDamage = Utils.toDmgValue(damageValue, minValue);
if (!recoilDamage) { if (!recoilDamage) {
return false; return false;
@ -2006,7 +2006,7 @@ export class HitHealAttr extends MoveEffectAttr {
message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) }); message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) });
} else { } else {
// Default healing formula used by draining moves like Absorb, Draining Kiss, Bitter Blade, etc. // 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) }); message = i18next.t("battle:regainHealth", { pokemonName: getPokemonNameWithAffix(user) });
} }
if (reverseDrain) { if (reverseDrain) {

View File

@ -2837,8 +2837,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.gameData.gameStats.highestDamage = damage; this.scene.gameData.gameStats.highestDamage = damage;
} }
} }
source.turnData.damageDealt += damage; source.turnData.totalDamageDealt += damage;
source.turnData.currDamageDealt = damage; source.turnData.singleHitDamageDealt = damage;
this.turnData.damageTaken += damage; this.turnData.damageTaken += damage;
this.battleData.hitCount++; this.battleData.hitCount++;
@ -5140,7 +5140,6 @@ export class PokemonSummonData {
public tags: BattlerTag[] = []; public tags: BattlerTag[] = [];
public abilitySuppressed: boolean = false; public abilitySuppressed: boolean = false;
public abilitiesApplied: Abilities[] = []; public abilitiesApplied: Abilities[] = [];
public speciesForm: PokemonSpeciesForm | null; public speciesForm: PokemonSpeciesForm | null;
public fusionSpeciesForm: PokemonSpeciesForm; public fusionSpeciesForm: PokemonSpeciesForm;
public ability: Abilities = Abilities.NONE; public ability: Abilities = Abilities.NONE;
@ -5180,8 +5179,8 @@ export class PokemonTurnData {
* - `0` = Move is finished * - `0` = Move is finished
*/ */
public hitsLeft: number = -1; public hitsLeft: number = -1;
public damageDealt: number = 0; public totalDamageDealt: number = 0;
public currDamageDealt: number = 0; public singleHitDamageDealt: number = 0;
public damageTaken: number = 0; public damageTaken: number = 0;
public attacksReceived: AttackMoveResult[] = []; public attacksReceived: AttackMoveResult[] = [];
public order: number; public order: number;

View File

@ -1767,10 +1767,10 @@ export class HitHealModifier extends PokemonHeldItemModifier {
* @returns `true` if the {@linkcode Pokemon} was healed * @returns `true` if the {@linkcode Pokemon} was healed
*/ */
override apply(pokemon: Pokemon): boolean { override apply(pokemon: Pokemon): boolean {
if (pokemon.turnData.damageDealt && !pokemon.isFullHp()) { if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) {
const scene = pokemon.scene; const scene = pokemon.scene;
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), 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; return true;

View File

@ -59,7 +59,7 @@ describe("Moves - Focus Punch", () => {
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
expect(leadPokemon.getMoveHistory().length).toBe(1); 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(enemyPokemon.hp).toBe(enemyStartingHp);
expect(leadPokemon.getMoveHistory().length).toBe(1); expect(leadPokemon.getMoveHistory().length).toBe(1);
expect(leadPokemon.turnData.damageDealt).toBe(0); expect(leadPokemon.turnData.totalDamageDealt).toBe(0);
} }
); );