Triple Arrows effect chance for stat change is now properly 50%

This commit is contained in:
NightKev 2024-10-01 21:02:52 -07:00
parent 7473c31c77
commit 28590541c8
2 changed files with 63 additions and 13 deletions

View File

@ -970,13 +970,16 @@ export class MoveEffectAttr extends MoveAttr {
public lastHitOnly: boolean; public lastHitOnly: boolean;
/** Should this effect only apply on the first target hit? */ /** Should this effect only apply on the first target hit? */
public firstTargetOnly: boolean; public firstTargetOnly: boolean;
/** Overrides the secondary effect chance for this attr if set. */
public effectChanceOverride?: number;
constructor(selfTarget?: boolean, trigger?: MoveEffectTrigger, firstHitOnly: boolean = false, lastHitOnly: boolean = false, firstTargetOnly: boolean = false) { constructor(selfTarget?: boolean, trigger?: MoveEffectTrigger, firstHitOnly: boolean = false, lastHitOnly: boolean = false, firstTargetOnly: boolean = false, effectChanceOverride?: number) {
super(selfTarget); super(selfTarget);
this.trigger = trigger !== undefined ? trigger : MoveEffectTrigger.POST_APPLY; this.trigger = trigger ?? MoveEffectTrigger.POST_APPLY;
this.firstHitOnly = firstHitOnly; this.firstHitOnly = firstHitOnly;
this.lastHitOnly = lastHitOnly; this.lastHitOnly = lastHitOnly;
this.firstTargetOnly = firstTargetOnly; this.firstTargetOnly = firstTargetOnly;
this.effectChanceOverride = effectChanceOverride;
} }
/** /**
@ -1001,15 +1004,15 @@ export class MoveEffectAttr extends MoveAttr {
/** /**
* Gets the used move's additional effect chance. * Gets the used move's additional effect chance.
* If user's ability has MoveEffectChanceMultiplierAbAttr or IgnoreMoveEffectsAbAttr modifies the base chance. * Chance is modified by {@linkcode MoveEffectChanceMultiplierAbAttr} and {@linkcode IgnoreMoveEffectsAbAttr}.
* @param user {@linkcode Pokemon} using this move * @param user {@linkcode Pokemon} using this move
* @param target {@linkcode Pokemon} target of this move * @param target {@linkcode Pokemon | Target} of this move
* @param move {@linkcode Move} being used * @param move {@linkcode Move} being used
* @param selfEffect {@linkcode Boolean} if move targets user. * @param selfEffect `true` if move targets user.
* @returns Move chance value. * @returns Move effect chance value.
*/ */
getMoveChance(user: Pokemon, target: Pokemon, move: Move, selfEffect?: Boolean, showAbility?: Boolean): integer { getMoveChance(user: Pokemon, target: Pokemon, move: Move, selfEffect?: boolean, showAbility?: boolean): number {
const moveChance = new Utils.NumberHolder(move.chance); const moveChance = new Utils.NumberHolder(this.effectChanceOverride ?? move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, moveChance, move, target, selfEffect, showAbility); applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, moveChance, move, target, selfEffect, showAbility);
if (!selfEffect) { if (!selfEffect) {
applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, target, user, null, null, false, moveChance); applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, target, user, null, null, false, moveChance);
@ -2674,8 +2677,8 @@ export class StatStageChangeAttr extends MoveEffectAttr {
private condition: MoveConditionFunc | null; private condition: MoveConditionFunc | null;
private showMessage: boolean; private showMessage: boolean;
constructor(stats: BattleStat[], stages: integer, selfTarget?: boolean, condition?: MoveConditionFunc | null, showMessage: boolean = true, firstHitOnly: boolean = false, moveEffectTrigger: MoveEffectTrigger = MoveEffectTrigger.HIT, firstTargetOnly: boolean = false) { constructor(stats: BattleStat[], stages: integer, selfTarget?: boolean, condition?: MoveConditionFunc | null, showMessage: boolean = true, firstHitOnly: boolean = false, moveEffectTrigger: MoveEffectTrigger = MoveEffectTrigger.HIT, firstTargetOnly: boolean = false, effectChanceOverride?: number) {
super(selfTarget, moveEffectTrigger, firstHitOnly, false, firstTargetOnly); super(selfTarget, moveEffectTrigger, firstHitOnly, false, firstTargetOnly, effectChanceOverride);
this.stats = stats; this.stats = stats;
this.stages = stages; this.stages = stages;
this.condition = condition!; // TODO: is this bang correct? this.condition = condition!; // TODO: is this bang correct?
@ -9290,9 +9293,8 @@ export function initMoves() {
new AttackMove(Moves.TRIPLE_ARROWS, Type.FIGHTING, MoveCategory.PHYSICAL, 90, 100, 10, 30, 0, 8) new AttackMove(Moves.TRIPLE_ARROWS, Type.FIGHTING, MoveCategory.PHYSICAL, 90, 100, 10, 30, 0, 8)
.makesContact(false) .makesContact(false)
.attr(HighCritAttr) .attr(HighCritAttr)
.attr(StatStageChangeAttr, [ Stat.DEF ], -1) .attr(StatStageChangeAttr, [ Stat.DEF ], -1, undefined, undefined, undefined, undefined, undefined, undefined, 50)
.attr(FlinchAttr) .attr(FlinchAttr),
.partial(),
new AttackMove(Moves.INFERNAL_PARADE, Type.GHOST, MoveCategory.SPECIAL, 60, 100, 15, 30, 0, 8) new AttackMove(Moves.INFERNAL_PARADE, Type.GHOST, MoveCategory.SPECIAL, 60, 100, 15, 30, 0, 8)
.attr(StatusEffectAttr, StatusEffect.BURN) .attr(StatusEffectAttr, StatusEffect.BURN)
.attr(MovePowerMultiplierAttr, (user, target, move) => target.status ? 2 : 1), .attr(MovePowerMultiplierAttr, (user, target, move) => target.status ? 2 : 1),

View File

@ -0,0 +1,48 @@
import { allMoves, FlinchAttr, StatStageChangeAttr } from "#app/data/move";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Triple Arrows", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.ability(Abilities.BALL_FETCH)
.moveset([Moves.TRIPLE_ARROWS])
.battleType("single")
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH);
});
it("has a 30% flinch chance and 50% defense drop chance", async () => {
const tripleArrows = allMoves[Moves.TRIPLE_ARROWS];
const flinchAttr = tripleArrows.getAttrs(FlinchAttr)[0];
const defDropAttr = tripleArrows.getAttrs(StatStageChangeAttr)[0];
vi.spyOn(flinchAttr, "getMoveChance");
vi.spyOn(defDropAttr, "getMoveChance");
await game.classicMode.startBattle([Species.FEEBAS]);
game.move.select(Moves.TRIPLE_ARROWS);
await game.phaseInterceptor.to("BerryPhase");
expect(flinchAttr.getMoveChance).toHaveReturnedWith(30);
expect(defDropAttr.getMoveChance).toHaveReturnedWith(50);
});
});