mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-29 19:52:27 +02:00
added ignoreHeldItems to getEffectiveStat and added tera blast tests
This commit is contained in:
parent
5db3074e2c
commit
d5c9a02fab
@ -4544,7 +4544,7 @@ export class TeraMoveCategoryAttr extends VariableMoveCategoryAttr {
|
|||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
const category = (args[0] as Utils.NumberHolder);
|
const category = (args[0] as Utils.NumberHolder);
|
||||||
|
|
||||||
if (user.isTerastallized() && user.getEffectiveStat(Stat.ATK, target, move) > user.getEffectiveStat(Stat.SPATK, target, move)) {
|
if (user.isTerastallized() && user.getEffectiveStat(Stat.ATK, target, move, true, true, false, false, true) > user.getEffectiveStat(Stat.SPATK, target, move, true, true, false, false, true)) {
|
||||||
category.value = MoveCategory.PHYSICAL;
|
category.value = MoveCategory.PHYSICAL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -935,11 +935,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
* @param ignoreOppAbility during an attack, determines whether the opposing Pokemon's abilities should be ignored during the stat calculation.
|
* @param ignoreOppAbility during an attack, determines whether the opposing Pokemon's abilities should be ignored during the stat calculation.
|
||||||
* @param isCritical determines whether a critical hit has occurred or not (`false` by default)
|
* @param isCritical determines whether a critical hit has occurred or not (`false` by default)
|
||||||
* @param simulated if `true`, nullifies any effects that produce any changes to game state from triggering
|
* @param simulated if `true`, nullifies any effects that produce any changes to game state from triggering
|
||||||
|
* @param ignoreHeldItems determines whether this Pokemon's held items should be ignored during the stat calculation, default `false`
|
||||||
* @returns the final in-battle value of a stat
|
* @returns the final in-battle value of a stat
|
||||||
*/
|
*/
|
||||||
getEffectiveStat(stat: EffectiveStat, opponent?: Pokemon, move?: Move, ignoreAbility: boolean = false, ignoreOppAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true): integer {
|
getEffectiveStat(stat: EffectiveStat, opponent?: Pokemon, move?: Move, ignoreAbility: boolean = false, ignoreOppAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true, ignoreHeldItems: boolean = false): integer {
|
||||||
const statValue = new Utils.NumberHolder(this.getStat(stat, false));
|
const statValue = new Utils.NumberHolder(this.getStat(stat, false));
|
||||||
this.scene.applyModifiers(StatBoosterModifier, this.isPlayer(), this, stat, statValue);
|
if (!ignoreHeldItems) {
|
||||||
|
this.scene.applyModifiers(StatBoosterModifier, this.isPlayer(), this, stat, statValue);
|
||||||
|
}
|
||||||
|
|
||||||
// The Ruin abilities here are never ignored, but they reveal themselves on summon anyway
|
// The Ruin abilities here are never ignored, but they reveal themselves on summon anyway
|
||||||
const fieldApplied = new Utils.BooleanHolder(false);
|
const fieldApplied = new Utils.BooleanHolder(false);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { allMoves } from "#app/data/move";
|
import { allMoves, TeraMoveCategoryAttr } from "#app/data/move";
|
||||||
import { Type } from "#enums/type";
|
import { Type } from "#enums/type";
|
||||||
import { Abilities } from "#app/enums/abilities";
|
import { Abilities } from "#app/enums/abilities";
|
||||||
import { HitResult } from "#app/field/pokemon";
|
import { HitResult } from "#app/field/pokemon";
|
||||||
@ -14,6 +14,7 @@ describe("Moves - Tera Blast", () => {
|
|||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
const moveToCheck = allMoves[Moves.TERA_BLAST];
|
const moveToCheck = allMoves[Moves.TERA_BLAST];
|
||||||
|
const teraBlastAttr = moveToCheck.getAttrs(TeraMoveCategoryAttr)[0];
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
@ -86,19 +87,86 @@ describe("Moves - Tera Blast", () => {
|
|||||||
expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE);
|
expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Currently abilities are bugged and can't see when a move's category is changed
|
it("uses the higher ATK for damage calculation", async () => {
|
||||||
it.skip("uses the higher stat of the user's Atk and SpAtk for damage calculation", async () => {
|
|
||||||
game.override.enemyAbility(Abilities.TOXIC_DEBRIS);
|
|
||||||
await game.startBattle();
|
await game.startBattle();
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
playerPokemon.stats[Stat.ATK] = 100;
|
playerPokemon.stats[Stat.ATK] = 100;
|
||||||
playerPokemon.stats[Stat.SPATK] = 1;
|
playerPokemon.stats[Stat.SPATK] = 1;
|
||||||
|
|
||||||
|
vi.spyOn(teraBlastAttr, "apply");
|
||||||
|
|
||||||
game.move.select(Moves.TERA_BLAST);
|
game.move.select(Moves.TERA_BLAST);
|
||||||
await game.phaseInterceptor.to("TurnEndPhase");
|
await game.toNextTurn();
|
||||||
expect(game.scene.getEnemyPokemon()!.battleData.abilityRevealed).toBe(true);
|
expect(teraBlastAttr.apply).toHaveLastReturnedWith(true);
|
||||||
}, 20000);
|
});
|
||||||
|
|
||||||
|
it("uses the higher SPATK for damage calculation", async () => {
|
||||||
|
await game.startBattle();
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
playerPokemon.stats[Stat.ATK] = 1;
|
||||||
|
playerPokemon.stats[Stat.SPATK] = 100;
|
||||||
|
|
||||||
|
vi.spyOn(teraBlastAttr, "apply");
|
||||||
|
|
||||||
|
game.move.select(Moves.TERA_BLAST);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(teraBlastAttr.apply).toHaveLastReturnedWith(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should stay as a special move if ATK turns lower than SPATK mid-turn", async () => {
|
||||||
|
game.override.enemyMoveset([ Moves.CHARM ]);
|
||||||
|
await game.startBattle();
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
playerPokemon.stats[Stat.ATK] = 51;
|
||||||
|
playerPokemon.stats[Stat.SPATK] = 50;
|
||||||
|
|
||||||
|
vi.spyOn(teraBlastAttr, "apply");
|
||||||
|
|
||||||
|
game.move.select(Moves.TERA_BLAST);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(teraBlastAttr.apply).toHaveLastReturnedWith(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not change its move category from stat changes due to held items", async () => {
|
||||||
|
game.override
|
||||||
|
.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }])
|
||||||
|
.starterSpecies(Species.CUBONE);
|
||||||
|
await game.startBattle();
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
|
playerPokemon.stats[Stat.ATK] = 50;
|
||||||
|
playerPokemon.stats[Stat.SPATK] = 51;
|
||||||
|
|
||||||
|
vi.spyOn(teraBlastAttr, "apply");
|
||||||
|
|
||||||
|
game.move.select(Moves.TERA_BLAST);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(teraBlastAttr.apply).toHaveLastReturnedWith(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not change its move category from stat changes due to abilities", async () => {
|
||||||
|
game.override.enemyAbility(Abilities.HUGE_POWER);
|
||||||
|
await game.startBattle();
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
playerPokemon.stats[Stat.ATK] = 50;
|
||||||
|
playerPokemon.stats[Stat.SPATK] = 51;
|
||||||
|
|
||||||
|
vi.spyOn(teraBlastAttr, "apply");
|
||||||
|
|
||||||
|
game.move.select(Moves.TERA_BLAST);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(teraBlastAttr.apply).toHaveLastReturnedWith(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it("causes stat drops if user is Stellar tera type", async () => {
|
it("causes stat drops if user is Stellar tera type", async () => {
|
||||||
game.override.startingHeldItems([{ name: "TERA_SHARD", type: Type.STELLAR }]);
|
game.override.startingHeldItems([{ name: "TERA_SHARD", type: Type.STELLAR }]);
|
||||||
|
Loading…
Reference in New Issue
Block a user