Add battler stat multiplier ability attribute

pull/1/head
Flashfyre 2023-05-02 00:11:31 -04:00
parent f6c7a2906d
commit 60f191e60d
1 changed files with 43 additions and 0 deletions

View File

@ -222,6 +222,27 @@ export class RecoilMovePowerBoostAbAttr extends VariableMovePowerAbAttr {
} }
} }
export class BattleStatMultiplierAbAttr extends AbAttr {
private battleStat: BattleStat;
private multiplier: number;
constructor(battleStat: BattleStat, multiplier: number) {
super();
this.battleStat = battleStat;
this.multiplier = multiplier;
}
applyBattleStat(pokemon: Pokemon, battleStat: BattleStat, statValue: Utils.NumberHolder, args: any[]) {
if (battleStat === this.battleStat) {
statValue.value *= this.multiplier;
return true;
}
return false;
}
}
export class PreStatChangeAbAttr extends AbAttr { export class PreStatChangeAbAttr extends AbAttr {
applyPreStatChange(pokemon: Pokemon, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean { applyPreStatChange(pokemon: Pokemon, stat: BattleStat, cancelled: Utils.BooleanHolder, args: any[]): boolean {
return false; return false;
@ -360,6 +381,28 @@ export function applyPreDefendAbAttrs(attrType: { new(...args: any[]): PreDefend
pokemon.scene.clearPhaseQueueSplice(); pokemon.scene.clearPhaseQueueSplice();
} }
export function applyBattleStatMultiplierAbAttrs(attrType: { new(...args: any[]): BattleStatMultiplierAbAttr },
pokemon: Pokemon, battleStat: BattleStat, statValue: Utils.NumberHolder, ...args: any[]) {
if (!pokemon.canApplyAbility())
return;
const ability = pokemon.getAbility();
const attrs = ability.getAttrs(attrType) as BattleStatMultiplierAbAttr[];
for (let attr of attrs) {
if (!canApplyAttr(pokemon, attr))
continue;
pokemon.scene.setPhaseQueueSplice();
if (attr.applyBattleStat(pokemon, battleStat, statValue, args)) {
queueShowAbility(pokemon);
const message = attr.getTriggerMessage(pokemon);
if (message)
pokemon.scene.queueMessage(message);
}
}
pokemon.scene.clearPhaseQueueSplice();
}
export function applyPreAttackAbAttrs(attrType: { new(...args: any[]): PreAttackAbAttr }, export function applyPreAttackAbAttrs(attrType: { new(...args: any[]): PreAttackAbAttr },
pokemon: Pokemon, defender: Pokemon, move: PokemonMove, ...args: any[]): void { pokemon: Pokemon, defender: Pokemon, move: PokemonMove, ...args: any[]): void {
if (!pokemon.canApplyAbility()) if (!pokemon.canApplyAbility())