Skip to content

Commit

Permalink
Add code/test for Multi-Lens interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
DayKev committed Jun 30, 2024
1 parent 88f3361 commit 353ae01
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4144,7 +4144,7 @@ export class IgnoreAccuracyAttr extends AddBattlerTagAttr {

export class AlwaysGetHitAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.ALWAYS_GET_HIT, true, false);
super(BattlerTagType.ALWAYS_GET_HIT, true, false, 0, 0, true);
}

apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
Expand All @@ -4158,7 +4158,7 @@ export class AlwaysGetHitAttr extends AddBattlerTagAttr {

export class ReceiveDoubleDamageAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.RECEIVE_DOUBLE_DAMAGE, true, false);
super(BattlerTagType.RECEIVE_DOUBLE_DAMAGE, true, false, 0, 0, true);
}

apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
Expand Down
24 changes: 22 additions & 2 deletions src/test/moves/glaive_rush.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Abilities } from "#app/enums/abilities.js";
import { allMoves } from "#app/data/move.js";


describe("Moves - Tackle", () => {
describe("Moves - Glaive Rush", () => {
let phaserGame: Phaser.Game;
let game: GameManager;

Expand Down Expand Up @@ -49,7 +49,7 @@ describe("Moves - Tackle", () => {
await game.phaseInterceptor.to(TurnEndPhase);
game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK));
await game.phaseInterceptor.to(DamagePhase);
expect(enemy.hp).toEqual(1000 - (damageDealt * 3));
expect(enemy.hp).toBeLessThanOrEqual(1000 - (damageDealt * 3));

}, 20000);

Expand All @@ -65,6 +65,26 @@ describe("Moves - Tackle", () => {

}, 20000);

it("interacts properly with multi-lens", async() => {
vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "MULTI_LENS", count: 2}]);
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.AVALANCHE));
await game.startBattle();
const player = game.scene.getPlayerPokemon();
const enemy = game.scene.getEnemyPokemon();
enemy.hp = 1000;
player.hp = 1000;

allMoves[Moves.AVALANCHE].accuracy = 0;
game.doAttack(getMovePosition(game.scene, 0, Moves.GLAIVE_RUSH));
await game.phaseInterceptor.to(TurnEndPhase);
expect(player.hp).toBeLessThan(1000);
player.hp = 1000;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase);
expect(player.hp).toBe(1000);

}, 20000);

it("secondary effects only last until next move", async() => {
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.SHADOW_SNEAK));
await game.startBattle();
Expand Down

0 comments on commit 353ae01

Please sign in to comment.