Update to structure of implementation

This commit is contained in:
geeil-han 2024-11-16 23:51:12 +01:00
parent 90aa989a40
commit 8e619385ef
2 changed files with 25 additions and 11 deletions

View File

@ -4312,16 +4312,31 @@ export class CueNextRoundAttr extends MoveEffectAttr {
} }
} }
/**
* Attribute that changes stat stages before the damage is calculated
*/
export class StatChangesBeforeDmgCalcAttr extends MoveAttr {
/**
* Applies Stat Changes before damage is calculated
*
* @param user {@linkcode Pokemon} that called {@linkcode move}
* @param target {@linkcode Pokemon} that is the target of {@linkcode move}
* @param move {@linkcode Move} called by {@linkcode user}
* @param args N/A
*
* @returns true if stat stages where correctly applied
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
return false;
}
}
/** /**
* Steals the postitive Stat stages of the target before damage calculation so stat changes * Steals the postitive Stat stages of the target before damage calculation so stat changes
* apply to damage calculation (e.g. {@linkcode Moves.SPECTRAL_THIEF}) * apply to damage calculation (e.g. {@linkcode Moves.SPECTRAL_THIEF})
* {@link https://bulbapedia.bulbagarden.net/wiki/Spectral_Thief_(move) | Spectral Thief} * {@link https://bulbapedia.bulbagarden.net/wiki/Spectral_Thief_(move) | Spectral Thief}
*/ */
export class SpectralThiefAttr extends MoveAttr { export class SpectralThiefAttr extends StatChangesBeforeDmgCalcAttr {
constructor() {
super();
}
/** /**
* steals max amount of positive stats of the target while not exceeding the limit of max 6 stat stages * steals max amount of positive stats of the target while not exceeding the limit of max 6 stat stages
* *
@ -4329,13 +4344,10 @@ export class SpectralThiefAttr extends MoveAttr {
* @param target {@linkcode Pokemon} that is the target of {@linkcode move} * @param target {@linkcode Pokemon} that is the target of {@linkcode move}
* @param move {@linkcode Move} called by {@linkcode user} * @param move {@linkcode Move} called by {@linkcode user}
* @param args N/A * @param args N/A
*
* @returns true if stat stages where correctly stolen * @returns true if stat stages where correctly stolen
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args)) {
return false;
}
// Copy all positive stat stages to user and reduce copied stat stages on target // Copy all positive stat stages to user and reduce copied stat stages on target
for (const s of BATTLE_STATS) { for (const s of BATTLE_STATS) {
const statStageValueTarget = target.getStatStage(s); const statStageValueTarget = target.getStatStage(s);
@ -5058,6 +5070,7 @@ export class VariableMoveTypeChartAttr extends MoveAttr {
* @returns true if application of the attribute succeeds * @returns true if application of the attribute succeeds
*/ */
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
console.log("Did not call SpectralThiefAttr correctly");
return false; return false;
} }
} }
@ -5067,6 +5080,7 @@ export class VariableMoveTypeChartAttr extends MoveAttr {
*/ */
export class FreezeDryAttr extends VariableMoveTypeChartAttr { export class FreezeDryAttr extends VariableMoveTypeChartAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
console.log("Did call SpectralThiefAttr correctly");
const multiplier = args[0] as Utils.NumberHolder; const multiplier = args[0] as Utils.NumberHolder;
const defType = args[1] as Type; const defType = args[1] as Type;

View File

@ -3,7 +3,7 @@ import BattleScene, { AnySound } from "#app/battle-scene";
import { Variant, VariantSet, variantColorCache } from "#app/data/variant"; import { Variant, VariantSet, variantColorCache } from "#app/data/variant";
import { variantData } from "#app/data/variant"; import { variantData } from "#app/data/variant";
import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from "#app/ui/battle-info"; import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from "#app/ui/battle-info";
import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, VariableMoveTypeAttr, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr, IgnoreOpponentStatStagesAttr, SacrificialAttr, VariableMoveCategoryAttr, CounterDamageAttr, StatStageChangeAttr, RechargeAttr, IgnoreWeatherTypeDebuffAttr, BypassBurnDamageReductionAttr, SacrificialAttrOnHit, OneHitKOAccuracyAttr, RespectAttackTypeImmunityAttr, MoveTarget, CombinedPledgeStabBoostAttr, VariableMoveTypeChartAttr, SpectralThiefAttr } from "#app/data/move"; import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, VariableMoveTypeAttr, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr, IgnoreOpponentStatStagesAttr, SacrificialAttr, VariableMoveCategoryAttr, CounterDamageAttr, StatStageChangeAttr, RechargeAttr, IgnoreWeatherTypeDebuffAttr, BypassBurnDamageReductionAttr, SacrificialAttrOnHit, OneHitKOAccuracyAttr, RespectAttackTypeImmunityAttr, MoveTarget, CombinedPledgeStabBoostAttr, VariableMoveTypeChartAttr, StatChangesBeforeDmgCalcAttr } from "#app/data/move";
import { default as PokemonSpecies, PokemonSpeciesForm, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { default as PokemonSpecies, PokemonSpeciesForm, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER, getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters"; import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER, getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
import { starterPassiveAbilities } from "#app/data/balance/passives"; import { starterPassiveAbilities } from "#app/data/balance/passives";
@ -2835,7 +2835,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* Steals positive stat stages from {@linkcode this} and gives it to {@linkcode source} * Steals positive stat stages from {@linkcode this} and gives it to {@linkcode source}
* before damage calculation * before damage calculation
*/ */
applyMoveAttrs(SpectralThiefAttr, source, this, move); applyMoveAttrs(StatChangesBeforeDmgCalcAttr, source, this, move);
const { cancelled, result, damage: dmg } = this.getAttackDamage(source, move, false, false, isCritical, false); const { cancelled, result, damage: dmg } = this.getAttackDamage(source, move, false, false, isCritical, false);