mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Add comments and fixed damage condition to applyPreDefend
This commit is contained in:
parent
82c8b09373
commit
5f20240a6e
@ -8,7 +8,7 @@ import { Weather, WeatherType } from "./weather";
|
|||||||
import { BattlerTag, GroundedTag, GulpMissileTag, SemiInvulnerableTag } from "./battler-tags";
|
import { BattlerTag, GroundedTag, GulpMissileTag, SemiInvulnerableTag } from "./battler-tags";
|
||||||
import { StatusEffect, getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "./status-effect";
|
import { StatusEffect, getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "./status-effect";
|
||||||
import { Gender } from "./gender";
|
import { Gender } from "./gender";
|
||||||
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, ChargeAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr } from "./move";
|
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, ChargeAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move";
|
||||||
import { ArenaTagSide, ArenaTrapTag } from "./arena-tag";
|
import { ArenaTagSide, ArenaTrapTag } from "./arena-tag";
|
||||||
import { Stat, getStatName } from "./pokemon-stat";
|
import { Stat, getStatName } from "./pokemon-stat";
|
||||||
import { BerryModifier, PokemonHeldItemModifier } from "../modifier/modifier";
|
import { BerryModifier, PokemonHeldItemModifier } from "../modifier/modifier";
|
||||||
@ -481,12 +481,27 @@ export class NonSuperEffectiveImmunityAbAttr extends TypeImmunityAbAttr {
|
|||||||
* @extends PreDefendAbAttr
|
* @extends PreDefendAbAttr
|
||||||
*/
|
*/
|
||||||
export class FullHpResistTypeAbAttr extends PreDefendAbAttr {
|
export class FullHpResistTypeAbAttr extends PreDefendAbAttr {
|
||||||
|
/**
|
||||||
|
* Reduces a type multiplier to 0.5 if the source is at full HP.
|
||||||
|
* @param pokemon {@linkcode Pokemon} the Pokemon with this ability
|
||||||
|
* @param passive n/a
|
||||||
|
* @param simulated n/a (this doesn't change game state)
|
||||||
|
* @param attacker n/a
|
||||||
|
* @param move {@linkcode Move} the move being used on the source
|
||||||
|
* @param cancelled n/a
|
||||||
|
* @param args `[0]` a container for the move's current type effectiveness multiplier
|
||||||
|
* @returns `true` if the move's effectiveness is reduced; `false` otherwise
|
||||||
|
*/
|
||||||
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise<boolean> {
|
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise<boolean> {
|
||||||
const typeMultiplier = args[0];
|
const typeMultiplier = args[0];
|
||||||
if (!(typeMultiplier && typeMultiplier instanceof Utils.NumberHolder)) {
|
if (!(typeMultiplier && typeMultiplier instanceof Utils.NumberHolder)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (move && move.hasAttr(FixedDamageAttr)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (pokemon.isFullHp() && typeMultiplier.value > 0.5) {
|
if (pokemon.isFullHp() && typeMultiplier.value > 0.5) {
|
||||||
typeMultiplier.value = 0.5;
|
typeMultiplier.value = 0.5;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Abilities } from "#app/enums/abilities";
|
import { Abilities } from "#app/enums/abilities";
|
||||||
import { Moves } from "#app/enums/moves";
|
import { Moves } from "#app/enums/moves";
|
||||||
import { Species } from "#app/enums/species";
|
import { Species } from "#app/enums/species";
|
||||||
|
import { HitResult } from "#app/field/pokemon.js";
|
||||||
import GameManager from "#test/utils/gameManager";
|
import GameManager from "#test/utils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
@ -89,4 +90,22 @@ describe("Abilities - Tera Shell", () => {
|
|||||||
expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.25);
|
expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.25);
|
||||||
}, TIMEOUT
|
}, TIMEOUT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should not affect the effectiveness of fixed-damage moves",
|
||||||
|
async () => {
|
||||||
|
game.override.enemyMoveset(Array(4).fill(Moves.DRAGON_RAGE));
|
||||||
|
|
||||||
|
await game.startBattle([Species.SNORLAX]);
|
||||||
|
|
||||||
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||||
|
vi.spyOn(playerPokemon, "apply");
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
expect(playerPokemon.apply).toHaveLastReturnedWith(HitResult.EFFECTIVE);
|
||||||
|
expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp() - 40);
|
||||||
|
}, TIMEOUT
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user