[Move] Implement Flame Burst (after beta fix) (#3239)

* add integration tests

* account for magic guard

* update test name

* remove test code

* fix magic guard interaction

* set 1 as min damage

* fix tests

* only apply magic guard attr if ally is active

* nit: remove new line

* update docs

* add the move attr
This commit is contained in:
Adrian T. 2024-07-30 22:05:54 +08:00 committed by GitHub
parent cb7dbe601a
commit 208f5af62a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 152 additions and 1 deletions

View File

@ -1435,6 +1435,39 @@ export class PartyStatusCureAttr extends MoveEffectAttr {
}
}
/**
* Applies damage to the target's ally equal to 1/16 of that ally's max HP.
* @extends MoveEffectAttr
*/
export class FlameBurstAttr extends MoveEffectAttr {
/**
* @param user - n/a
* @param target - The target Pokémon.
* @param move - n/a
* @param args - n/a
* @returns A boolean indicating whether the effect was successfully applied.
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> {
const targetAlly = target.getAlly();
const cancelled = new Utils.BooleanHolder(false);
if (targetAlly) {
applyAbAttrs(BlockNonDirectDamageAbAttr, targetAlly, cancelled);
}
if (cancelled.value || !targetAlly) {
return false;
}
targetAlly.damageAndUpdate(Math.max(1, Math.floor(1/16 * targetAlly.getMaxHp())), HitResult.OTHER);
return true;
}
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
return target.getAlly() ? -5 : 0;
}
}
export class SacrificialFullRestoreAttr extends SacrificialAttr {
constructor() {
super();
@ -7292,7 +7325,7 @@ export function initMoves() {
new AttackMove(Moves.STORM_THROW, Type.FIGHTING, MoveCategory.PHYSICAL, 60, 100, 10, -1, 0, 5)
.attr(CritOnlyAttr),
new AttackMove(Moves.FLAME_BURST, Type.FIRE, MoveCategory.SPECIAL, 70, 100, 15, -1, 0, 5)
.partial(),
.attr(FlameBurstAttr),
new AttackMove(Moves.SLUDGE_WAVE, Type.POISON, MoveCategory.SPECIAL, 95, 100, 10, 10, 0, 5)
.attr(StatusEffectAttr, StatusEffect.POISON)
.target(MoveTarget.ALL_NEAR_OTHERS),

View File

@ -0,0 +1,118 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import Phaser from "phaser";
import GameManager from "#app/test/utils/gameManager";
import Overrides from "#app/overrides";
import { Species } from "#enums/species";
import {
SelectTargetPhase,
TurnEndPhase,
} from "#app/phases";
import { Moves } from "#enums/moves";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Abilities } from "#app/enums/abilities.js";
import { allAbilities } from "#app/data/ability.js";
import Pokemon from "#app/field/pokemon.js";
describe("Moves - Flame Burst", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
/**
* Calculates the effect damage of Flame Burst which is 1/16 of the target ally's max HP
* See Flame Burst {@link https://bulbapedia.bulbagarden.net/wiki/Flame_Burst_(move)}
* See Flame Burst's move attribute {@linkcode FlameBurstAttr}
* @param pokemon {@linkcode Pokemon} - The ally of the move's target
* @returns Effect damage of Flame Burst
*/
const getEffectDamage = (pokemon: Pokemon): number => {
return Math.max(1, Math.floor(pokemon.getMaxHp() * 1/16));
};
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double");
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.FLAME_BURST, Moves.SPLASH]);
vi.spyOn(Overrides, "NEVER_CRIT_OVERRIDE", "get").mockReturnValue(true);
vi.spyOn(Overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.UNNERVE);
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(4);
vi.spyOn(Overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SHUCKLE);
vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH);
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(new Array(4).fill(Moves.SPLASH));
});
it("inflicts damage to the target's ally equal to 1/16 of its max HP", async () => {
await game.startBattle([Species.PIKACHU, Species.PIKACHU]);
const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField();
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(leftEnemy.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase);
expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp());
expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp() - getEffectDamage(rightEnemy));
});
it("does not inflict damage to the target's ally if the target was not affected by Flame Burst", async () => {
vi.spyOn(Overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.FLASH_FIRE);
await game.startBattle([Species.PIKACHU, Species.PIKACHU]);
const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField();
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(leftEnemy.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase);
expect(leftEnemy.hp).toBe(leftEnemy.getMaxHp());
expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp());
});
it("does not interact with the target ally's abilities", async () => {
await game.startBattle([Species.PIKACHU, Species.PIKACHU]);
const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField();
vi.spyOn(rightEnemy, "getAbility").mockReturnValue(allAbilities[Abilities.FLASH_FIRE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(leftEnemy.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase);
expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp());
expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp() - getEffectDamage(rightEnemy));
});
it("effect damage is prevented by Magic Guard", async () => {
await game.startBattle([Species.PIKACHU, Species.PIKACHU]);
const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField();
vi.spyOn(rightEnemy, "getAbility").mockReturnValue(allAbilities[Abilities.MAGIC_GUARD]);
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAME_BURST));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(leftEnemy.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase);
expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp());
expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp());
});
it("is not affected by protection moves and Endure", async () => {
// TODO: update this test when it's possible to select move for each enemy
}, { skip: true });
});