diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index a664ac1e2bf..00de610b300 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -1420,6 +1420,18 @@ export class IgnoreAccuracyTag extends BattlerTag { } } +export class AlwaysGetHitTag extends BattlerTag { + constructor(sourceMove: Moves) { + super(BattlerTagType.ALWAYS_GET_HIT, BattlerTagLapseType.PRE_MOVE, 1, sourceMove); + } +} + +export class ReceiveDoubleDamageTag extends BattlerTag { + constructor(sourceMove: Moves) { + super(BattlerTagType.RECEIVE_DOUBLE_DAMAGE, BattlerTagLapseType.PRE_MOVE, 1, sourceMove); + } +} + export class SaltCuredTag extends BattlerTag { private sourceIndex: integer; @@ -1668,6 +1680,10 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourc return new BattlerTag(tagType, BattlerTagLapseType.AFTER_MOVE, turnCount, sourceMove); case BattlerTagType.IGNORE_ACCURACY: return new IgnoreAccuracyTag(sourceMove); + case BattlerTagType.ALWAYS_GET_HIT: + return new AlwaysGetHitTag(sourceMove); + case BattlerTagType.RECEIVE_DOUBLE_DAMAGE: + return new ReceiveDoubleDamageTag(sourceMove); case BattlerTagType.BYPASS_SLEEP: return new BattlerTag(BattlerTagType.BYPASS_SLEEP, BattlerTagLapseType.TURN_END, turnCount, sourceMove); case BattlerTagType.IGNORE_FLYING: diff --git a/src/data/move.ts b/src/data/move.ts index caed4b4a496..96dfcf97f7b 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4258,9 +4258,9 @@ export class IgnoreAccuracyAttr extends AddBattlerTagAttr { } } -export class AlwaysCritsAttr extends AddBattlerTagAttr { +export class AlwaysGetHitAttr extends AddBattlerTagAttr { constructor() { - super(BattlerTagType.ALWAYS_CRIT, true, false, 2); + super(BattlerTagType.ALWAYS_GET_HIT, true, false, 0, 0, true); } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { @@ -4268,7 +4268,19 @@ export class AlwaysCritsAttr extends AddBattlerTagAttr { return false; } - user.scene.queueMessage(getPokemonMessage(user, ` took aim\nat ${target.name}!`)); + return true; + } +} + +export class ReceiveDoubleDamageAttr extends AddBattlerTagAttr { + constructor() { + super(BattlerTagType.RECEIVE_DOUBLE_DAMAGE, true, false, 0, 0, true); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (!super.apply(user, target, move, args)) { + return false; + } return true; } @@ -8398,7 +8410,8 @@ export function initMoves() { new AttackMove(Moves.ICE_SPINNER, Type.ICE, MoveCategory.PHYSICAL, 80, 100, 15, -1, 0, 9) .attr(ClearTerrainAttr), new AttackMove(Moves.GLAIVE_RUSH, Type.DRAGON, MoveCategory.PHYSICAL, 120, 100, 5, -1, 0, 9) - .partial(), + .attr(AlwaysGetHitAttr) + .attr(ReceiveDoubleDamageAttr), new StatusMove(Moves.REVIVAL_BLESSING, Type.NORMAL, -1, 1, -1, 0, 9) .triageMove() .attr(RevivalBlessingAttr) diff --git a/src/enums/battler-tag-type.ts b/src/enums/battler-tag-type.ts index bb7f7c05b00..786f67f5d33 100644 --- a/src/enums/battler-tag-type.ts +++ b/src/enums/battler-tag-type.ts @@ -60,5 +60,7 @@ export enum BattlerTagType { MINIMIZED = "MINIMIZED", DESTINY_BOND = "DESTINY_BOND", CENTER_OF_ATTENTION = "CENTER_OF_ATTENTION", - ICE_FACE = "ICE_FACE" + ICE_FACE = "ICE_FACE", + RECEIVE_DOUBLE_DAMAGE = "RECEIVE_DOUBLE_DAMAGE", + ALWAYS_GET_HIT = "ALWAYS_GET_HIT" } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 894eac1654c..44e9cdf18d7 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1837,6 +1837,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const arenaAttackTypeMultiplier = new Utils.NumberHolder(this.scene.arena.getAttackTypeMultiplier(move.type, source.isGrounded())); applyMoveAttrs(IgnoreWeatherTypeDebuffAttr, source, this, move, arenaAttackTypeMultiplier); + const glaiveRushModifier = new Utils.IntegerHolder(1); + if (this.getTag(BattlerTagType.RECEIVE_DOUBLE_DAMAGE)) { + glaiveRushModifier.value = 2; + } let isCritical: boolean; const critOnly = new Utils.BooleanHolder(false); const critAlways = source.getTag(BattlerTagType.ALWAYS_CRIT); @@ -1921,6 +1925,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * twoStrikeMultiplier.value * targetMultiplier * criticalMultiplier.value + * glaiveRushModifier.value * randomMultiplier); if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) { diff --git a/src/phases.ts b/src/phases.ts index 70e840d769e..b39d975d54b 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3073,6 +3073,10 @@ export class MoveEffectPhase extends PokemonPhase { return true; } + if (target.getTag(BattlerTagType.ALWAYS_GET_HIT)) { + return true; + } + const hiddenTag = target.getTag(SemiInvulnerableTag); if (hiddenTag && !this.move.getMove().getAttrs(HitsTagAttr).some(hta => hta.tagType === hiddenTag.tagType)) { return false; diff --git a/src/test/moves/glaive_rush.test.ts b/src/test/moves/glaive_rush.test.ts new file mode 100644 index 00000000000..4d9f6d332d0 --- /dev/null +++ b/src/test/moves/glaive_rush.test.ts @@ -0,0 +1,132 @@ +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 { DamagePhase, TurnEndPhase } from "#app/phases"; +import { getMovePosition } from "#app/test/utils/gameManagerUtils"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import { Abilities } from "#app/enums/abilities.js"; +import { allMoves } from "#app/data/move.js"; + + +describe("Moves - Glaive Rush", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true); + vi.spyOn(overrides, "NEVER_CRIT_OVERRIDE", "get").mockReturnValue(true); + vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.MAGIKARP); + vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.BALL_FETCH); + vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.GLAIVE_RUSH)); + vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.KLINK); + vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.UNNERVE); + vi.spyOn(overrides, "PASSIVE_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.FUR_COAT); + vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SHADOW_SNEAK, Moves.AVALANCHE, Moves.SPLASH, Moves.GLAIVE_RUSH]); + }); + + it("takes double damage from attacks", async() => { + await game.startBattle(); + const enemy = game.scene.getEnemyPokemon(); + enemy.hp = 1000; + + vi.spyOn(game.scene, "randBattleSeedInt").mockReturnValue(0); + game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + await game.phaseInterceptor.to(DamagePhase); + const damageDealt = 1000 - enemy.hp; + await game.phaseInterceptor.to(TurnEndPhase); + game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + await game.phaseInterceptor.to(DamagePhase); + expect(enemy.hp).toBeLessThanOrEqual(1001 - (damageDealt * 3)); + + }, 20000); + + it("always gets hit by attacks", async() => { + await game.startBattle(); + const enemy = game.scene.getEnemyPokemon(); + enemy.hp = 1000; + + allMoves[Moves.AVALANCHE].accuracy = 0; + game.doAttack(getMovePosition(game.scene, 0, Moves.AVALANCHE)); + await game.phaseInterceptor.to(TurnEndPhase); + expect(enemy.hp).toBeLessThan(1000); + + }, 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(); + const player = game.scene.getPlayerPokemon(); + const enemy = game.scene.getEnemyPokemon(); + enemy.hp = 1000; + player.hp = 1000; + allMoves[Moves.SHADOW_SNEAK].accuracy = 0; + + game.doAttack(getMovePosition(game.scene, 0, Moves.GLAIVE_RUSH)); + await game.phaseInterceptor.to(TurnEndPhase); + expect(player.hp).toBe(1000); + + game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + await game.phaseInterceptor.to(TurnEndPhase); + const damagedHp = player.hp; + expect(player.hp).toBeLessThan(1000); + + game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); + await game.phaseInterceptor.to(TurnEndPhase); + expect(player.hp).toBe(damagedHp); + + }, 20000); + + it("secondary effects are removed upon switching", async() => { + vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(Array(4).fill(Moves.SHADOW_SNEAK)); + vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(0); + await game.startBattle([Species.KLINK, Species.FEEBAS]); + const player = game.scene.getPlayerPokemon(); + const enemy = game.scene.getEnemyPokemon(); + enemy.hp = 1000; + allMoves[Moves.SHADOW_SNEAK].accuracy = 0; + + game.doAttack(getMovePosition(game.scene, 0, Moves.GLAIVE_RUSH)); + await game.phaseInterceptor.to(TurnEndPhase); + expect(player.hp).toBe(player.getMaxHp()); + + game.doSwitchPokemon(1); + await game.phaseInterceptor.to(TurnEndPhase); + game.doSwitchPokemon(1); + await game.phaseInterceptor.to(TurnEndPhase); + expect(player.hp).toBe(player.getMaxHp()); + + }, 20000); +});