mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
[Move] Finish implementation of Glaive Rush (#2720)
* Finish implementation of Glaive Rush * Fix test RNG * Add code/test for Multi-Lens interaction * Fix off-by-one error in test caused by rounding issues * Update for code changes * Fix BattlerTag name
This commit is contained in:
parent
10413722c6
commit
b6266c6da1
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
132
src/test/moves/glaive_rush.test.ts
Normal file
132
src/test/moves/glaive_rush.test.ts
Normal file
@ -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);
|
||||
});
|
Loading…
Reference in New Issue
Block a user