mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 21:32:18 +02:00
Compare commits
6 Commits
5d4a6aa0f7
...
ad3bcc8723
Author | SHA1 | Date | |
---|---|---|---|
|
ad3bcc8723 | ||
|
f5bf766ff7 | ||
|
c710f85fd3 | ||
|
39b6a72517 | ||
|
06f98f6737 | ||
|
68b956cbe6 |
1
src/constants.ts
Normal file
1
src/constants.ts
Normal file
@ -0,0 +1 @@
|
||||
export const PLAYER_PARTY_MAX_SIZE = 6;
|
@ -1984,7 +1984,38 @@ export class ExposedTag extends BattlerTag {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag that doubles the type effectiveness of Fire-type moves.
|
||||
* @extends BattlerTag
|
||||
*/
|
||||
export class TarShotTag extends BattlerTag {
|
||||
constructor() {
|
||||
super(BattlerTagType.TAR_SHOT, BattlerTagLapseType.CUSTOM, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Pokemon is terastallized, the tag cannot be added.
|
||||
* @param {Pokemon} pokemon the {@linkcode Pokemon} to which the tag is added
|
||||
* @returns whether the tag is applied
|
||||
*/
|
||||
override canAdd(pokemon: Pokemon): boolean {
|
||||
return !pokemon.isTerastallized();
|
||||
}
|
||||
|
||||
override onAdd(pokemon: Pokemon): void {
|
||||
pokemon.scene.queueMessage(i18next.t("battlerTags:tarShotOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID.
|
||||
*
|
||||
* @param {BattlerTagType} tagType the type of the {@linkcode BattlerTagType}.
|
||||
* @param turnCount the turn count.
|
||||
* @param {Moves} sourceMove the source {@linkcode Moves}.
|
||||
* @param sourceId the source ID.
|
||||
* @returns {BattlerTag} the corresponding {@linkcode BattlerTag} object.
|
||||
*/
|
||||
export function getBattlerTag(tagType: BattlerTagType, turnCount: number, sourceMove: Moves, sourceId: number): BattlerTag {
|
||||
switch (tagType) {
|
||||
case BattlerTagType.RECHARGING:
|
||||
@ -2125,6 +2156,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
|
||||
case BattlerTagType.GULP_MISSILE_ARROKUDA:
|
||||
case BattlerTagType.GULP_MISSILE_PIKACHU:
|
||||
return new GulpMissileTag(tagType, sourceMove);
|
||||
case BattlerTagType.TAR_SHOT:
|
||||
return new TarShotTag();
|
||||
case BattlerTagType.NONE:
|
||||
default:
|
||||
return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId);
|
||||
|
@ -3472,7 +3472,7 @@ export class SpitUpPowerAttr extends VariablePowerAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const stockpilingTag = user.getTag(StockpilingTag);
|
||||
|
||||
if (stockpilingTag !== null && stockpilingTag.stockpiledCount > 0) {
|
||||
if (stockpilingTag && stockpilingTag.stockpiledCount > 0) {
|
||||
const power = args[0] as Utils.IntegerHolder;
|
||||
power.value = this.multiplier * stockpilingTag.stockpiledCount;
|
||||
return true;
|
||||
@ -3490,7 +3490,7 @@ export class SwallowHealAttr extends HealAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const stockpilingTag = user.getTag(StockpilingTag);
|
||||
|
||||
if (stockpilingTag !== null && stockpilingTag?.stockpiledCount > 0) {
|
||||
if (stockpilingTag && stockpilingTag.stockpiledCount > 0) {
|
||||
const stockpiled = stockpilingTag.stockpiledCount;
|
||||
let healRatio: number;
|
||||
|
||||
@ -8652,7 +8652,7 @@ export function initMoves() {
|
||||
.condition((user, target, move) => user.getTag(TrappedTag)?.sourceMove !== Moves.NO_RETREAT), // fails if the user is currently trapped by No Retreat
|
||||
new StatusMove(Moves.TAR_SHOT, Type.ROCK, 100, 15, -1, 0, 8)
|
||||
.attr(StatStageChangeAttr, [ Stat.SPD ], -1)
|
||||
.partial(),
|
||||
.attr(AddBattlerTagAttr, BattlerTagType.TAR_SHOT, false),
|
||||
new StatusMove(Moves.MAGIC_POWDER, Type.PSYCHIC, 100, 20, -1, 0, 8)
|
||||
.attr(ChangeTypeAttr, Type.PSYCHIC)
|
||||
.powderMove(),
|
||||
|
@ -73,4 +73,5 @@ export enum BattlerTagType {
|
||||
SHELL_TRAP = "SHELL_TRAP",
|
||||
DRAGON_CHEER = "DRAGON_CHEER",
|
||||
NO_RETREAT = "NO_RETREAT",
|
||||
TAR_SHOT = "TAR_SHOT",
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import { initMoveAnim, loadMoveAnimAssets } from "../data/battle-anims";
|
||||
import { Status, StatusEffect, getRandomStatus } from "../data/status-effect";
|
||||
import { pokemonEvolutions, pokemonPrevolutions, SpeciesFormEvolution, SpeciesEvolutionCondition, FusionSpeciesFormEvolution } from "../data/pokemon-evolutions";
|
||||
import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "../data/tms";
|
||||
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag } from "../data/battler-tags";
|
||||
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag } from "../data/battler-tags";
|
||||
import { WeatherType } from "../data/weather";
|
||||
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "../data/arena-tag";
|
||||
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr } from "../data/ability";
|
||||
@ -58,6 +58,7 @@ import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import { PLAYER_PARTY_MAX_SIZE } from "#app/constants";
|
||||
|
||||
export enum FieldPosition {
|
||||
CENTER,
|
||||
@ -1049,6 +1050,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
const teraType = this.getTeraType();
|
||||
if (teraType !== Type.UNKNOWN) {
|
||||
types.push(teraType);
|
||||
if (forDefend) {
|
||||
return types;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1320,9 +1324,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
const trappedByAbility = new Utils.BooleanHolder(false);
|
||||
const opposingField = this.isPlayer() ? this.scene.getEnemyField() : this.scene.getPlayerField();
|
||||
|
||||
this.scene.getEnemyField()!.forEach(enemyPokemon =>
|
||||
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, enemyPokemon, trappedByAbility, this, trappedAbMessages, simulated)
|
||||
opposingField.forEach(opponent =>
|
||||
applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated)
|
||||
);
|
||||
|
||||
return (trappedByAbility.value || !!this.getTag(TrappedTag));
|
||||
@ -1348,7 +1353,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
/**
|
||||
* Calculates the effectiveness of a move against the Pokémon.
|
||||
*
|
||||
* This includes modifiers from move and ability attributes.
|
||||
* @param source {@linkcode Pokemon} The attacking Pokémon.
|
||||
* @param move {@linkcode Move} The move being used by the attacking Pokémon.
|
||||
* @param ignoreAbility Whether to ignore abilities that might affect type effectiveness or immunity (defaults to `false`).
|
||||
@ -1368,10 +1373,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
: 1);
|
||||
|
||||
applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier);
|
||||
if (this.getTypes().find(t => move.isTypeImmune(source, this, t))) {
|
||||
if (this.getTypes(true, true).find(t => move.isTypeImmune(source, this, t))) {
|
||||
typeMultiplier.value = 0;
|
||||
}
|
||||
|
||||
if (this.getTag(TarShotTag) && (this.getMoveType(move) === Type.FIRE)) {
|
||||
typeMultiplier.value *= 2;
|
||||
}
|
||||
|
||||
const cancelledHolder = cancelled ?? new Utils.BooleanHolder(false);
|
||||
if (!ignoreAbility) {
|
||||
applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier);
|
||||
@ -1403,7 +1412,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the type effectiveness multiplier for an attack type
|
||||
* Calculates the move's type effectiveness multiplier based on the target's type/s.
|
||||
* @param moveType {@linkcode Type} the type of the move being used
|
||||
* @param source {@linkcode Pokemon} the Pokemon using the move
|
||||
* @param ignoreStrongWinds whether or not this ignores strong winds (anticipation, forewarn, stealth rocks)
|
||||
@ -4462,17 +4471,29 @@ export class EnemyPokemon extends Pokemon {
|
||||
return BattlerIndex.ENEMY + this.getFieldIndex();
|
||||
}
|
||||
|
||||
addToParty(pokeballType: PokeballType) {
|
||||
/**
|
||||
* Add a new pokemon to the player's party (at `slotIndex` if set).
|
||||
* @param pokeballType the type of pokeball the pokemon was caught with
|
||||
* @param slotIndex an optional index to place the pokemon in the party
|
||||
* @returns the pokemon that was added or null if the pokemon could not be added
|
||||
*/
|
||||
addToParty(pokeballType: PokeballType, slotIndex: number = -1) {
|
||||
const party = this.scene.getParty();
|
||||
let ret: PlayerPokemon | null = null;
|
||||
|
||||
if (party.length < 6) {
|
||||
if (party.length < PLAYER_PARTY_MAX_SIZE) {
|
||||
this.pokeball = pokeballType;
|
||||
this.metLevel = this.level;
|
||||
this.metBiome = this.scene.arena.biomeType;
|
||||
this.metSpecies = this.species.speciesId;
|
||||
const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this);
|
||||
party.push(newPokemon);
|
||||
|
||||
if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) {
|
||||
party.splice(slotIndex, 0, newPokemon);
|
||||
} else {
|
||||
party.push(newPokemon);
|
||||
}
|
||||
|
||||
ret = newPokemon;
|
||||
this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true);
|
||||
}
|
||||
|
@ -69,5 +69,6 @@
|
||||
"cursedLapse": "{{pokemonNameWithAffix}} is afflicted by the Curse!",
|
||||
"stockpilingOnAdd": "{{pokemonNameWithAffix}} stockpiled {{stockpiledCount}}!",
|
||||
"disabledOnAdd": "{{pokemonNameWithAffix}}'s {{moveName}}\nwas disabled!",
|
||||
"disabledLapse": "{{pokemonNameWithAffix}}'s {{moveName}}\nis no longer disabled."
|
||||
"disabledLapse": "{{pokemonNameWithAffix}}'s {{moveName}}\nis no longer disabled.",
|
||||
"tarShotOnAdd": "{{pokemonNameWithAffix}} became weaker to fire!"
|
||||
}
|
||||
|
@ -221,8 +221,8 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
this.scene.clearEnemyHeldItemModifiers();
|
||||
this.scene.field.remove(pokemon, true);
|
||||
};
|
||||
const addToParty = () => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType);
|
||||
const addToParty = (slotIndex?: number) => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
|
||||
const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier, false);
|
||||
if (this.scene.getParty().filter(p => p.isShiny()).length === 6) {
|
||||
this.scene.validateAchv(achvs.SHINY_PARTY);
|
||||
@ -253,7 +253,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => {
|
||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||
if (slotIndex < 6) {
|
||||
addToParty();
|
||||
addToParty(slotIndex);
|
||||
} else {
|
||||
promptRelease();
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Species } from "#app/enums/species";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import GameManager from "../utils/gameManager";
|
||||
import { PokeballType } from "#app/enums/pokeball";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
|
||||
describe("Spec - Pokemon", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -28,4 +30,37 @@ describe("Spec - Pokemon", () => {
|
||||
|
||||
expect(pkm.trySetStatus(undefined)).toBe(true);
|
||||
});
|
||||
|
||||
describe("Add To Party", () => {
|
||||
let scene: BattleScene;
|
||||
|
||||
beforeEach(async () => {
|
||||
game.override.enemySpecies(Species.ZUBAT);
|
||||
await game.classicMode.runToSummon([Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA]); // 5 Abra, only 1 slot left
|
||||
scene = game.scene;
|
||||
});
|
||||
|
||||
it("should append a new pokemon by default", async () => {
|
||||
const zubat = scene.getEnemyPokemon()!;
|
||||
zubat.addToParty(PokeballType.LUXURY_BALL);
|
||||
|
||||
const party = scene.getParty();
|
||||
expect(party).toHaveLength(6);
|
||||
party.forEach((pkm, index) =>{
|
||||
expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA);
|
||||
});
|
||||
});
|
||||
|
||||
it("should put a new pokemon into the passed slotIndex", async () => {
|
||||
const slotIndex = 1;
|
||||
const zubat = scene.getEnemyPokemon()!;
|
||||
zubat.addToParty(PokeballType.LUXURY_BALL, slotIndex);
|
||||
|
||||
const party = scene.getParty();
|
||||
expect(party).toHaveLength(6);
|
||||
party.forEach((pkm, index) =>{
|
||||
expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,23 +1,32 @@
|
||||
import { allMoves } from "#app/data/move";
|
||||
import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { TrainerSlot } from "#app/data/trainer-config";
|
||||
import { Type } from "#app/data/type";
|
||||
import { Abilities } from "#app/enums/abilities";
|
||||
import { Moves } from "#app/enums/moves";
|
||||
import { Species } from "#app/enums/species";
|
||||
import * as Messages from "#app/messages";
|
||||
import { TerastallizeModifier } from "#app/modifier/modifier";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
|
||||
function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Species,
|
||||
expected: number, targetAbility: Abilities = Abilities.BALL_FETCH): void {
|
||||
expected: number, targetAbility: Abilities = Abilities.BALL_FETCH, teraType?: Type): void {
|
||||
// Suppress getPokemonNameWithAffix because it calls on a null battle spec
|
||||
vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue("");
|
||||
game.override.enemyAbility(targetAbility);
|
||||
|
||||
if (teraType !== undefined) {
|
||||
game.override.enemyHeldItems([{ name:"TERA_SHARD", type: teraType }]);
|
||||
}
|
||||
|
||||
const user = game.scene.addPlayerPokemon(getPokemonSpecies(Species.SNORLAX), 5);
|
||||
const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE);
|
||||
|
||||
expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected);
|
||||
user.destroy();
|
||||
target.destroy();
|
||||
}
|
||||
|
||||
describe("Moves - Type Effectiveness", () => {
|
||||
@ -29,6 +38,8 @@ describe("Moves - Type Effectiveness", () => {
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
game = new GameManager(phaserGame);
|
||||
TerastallizeModifier.prototype.apply = (args) => true;
|
||||
|
||||
game.override.ability(Abilities.BALL_FETCH);
|
||||
});
|
||||
|
||||
@ -67,4 +78,30 @@ describe("Moves - Type Effectiveness", () => {
|
||||
it("Electric-type attacks are negated by Volt Absorb",
|
||||
() => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 0, Abilities.VOLT_ABSORB)
|
||||
);
|
||||
|
||||
it("Electric-type attacks are super-effective against Tera-Water Pokemon",
|
||||
() => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.EXCADRILL, 2, Abilities.BALL_FETCH, Type.WATER)
|
||||
);
|
||||
|
||||
it("Powder moves have no effect on Grass-type Pokemon",
|
||||
() => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.AMOONGUSS, 0)
|
||||
);
|
||||
|
||||
it("Powder moves have no effect on Tera-Grass Pokemon",
|
||||
() => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.SNORLAX, 0, Abilities.BALL_FETCH, Type.GRASS)
|
||||
);
|
||||
|
||||
it("Prankster-boosted status moves have no effect on Dark-type Pokemon",
|
||||
() => {
|
||||
game.override.ability(Abilities.PRANKSTER);
|
||||
testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.MIGHTYENA, 0);
|
||||
}
|
||||
);
|
||||
|
||||
it("Prankster-boosted status moves have no effect on Tera-Dark Pokemon",
|
||||
() => {
|
||||
game.override.ability(Abilities.PRANKSTER);
|
||||
testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.SNORLAX, 0, Abilities.BALL_FETCH, Type.DARK);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
133
src/test/moves/tar_shot.test.ts
Normal file
133
src/test/moves/tar_shot.test.ts
Normal file
@ -0,0 +1,133 @@
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { Type } from "#app/data/type";
|
||||
import { Moves } from "#app/enums/moves";
|
||||
import { Species } from "#app/enums/species";
|
||||
import { Stat } from "#app/enums/stat";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import { SPLASH_ONLY } from "#test/utils/testUtils";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("Moves - Tar Shot", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
const TIMEOUT = 20 * 1000;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleType("single")
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset(SPLASH_ONLY)
|
||||
.enemySpecies(Species.TANGELA)
|
||||
.enemyLevel(1000)
|
||||
.moveset([Moves.TAR_SHOT, Moves.FIRE_PUNCH])
|
||||
.disableCrits();
|
||||
});
|
||||
|
||||
it("lowers the target's Speed stat by one stage and doubles the effectiveness of Fire-type moves used on the target", async () => {
|
||||
await game.classicMode.startBattle([Species.PIKACHU]);
|
||||
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
|
||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
||||
|
||||
game.move.select(Moves.TAR_SHOT);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(enemy.getStatStage(Stat.SPD)).toBe(-1);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
game.move.select(Moves.FIRE_PUNCH);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4);
|
||||
}, TIMEOUT);
|
||||
|
||||
it("will not double the effectiveness of Fire-type moves used on a target that is already under the effect of Tar Shot (but may still lower its Speed)", async () => {
|
||||
await game.classicMode.startBattle([Species.PIKACHU]);
|
||||
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
|
||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
||||
|
||||
game.move.select(Moves.TAR_SHOT);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(enemy.getStatStage(Stat.SPD)).toBe(-1);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
game.move.select(Moves.TAR_SHOT);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(enemy.getStatStage(Stat.SPD)).toBe(-2);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
game.move.select(Moves.FIRE_PUNCH);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4);
|
||||
}, TIMEOUT);
|
||||
|
||||
it("does not double the effectiveness of Fire-type moves against a Pokémon that is Terastallized", async () => {
|
||||
game.override.enemyHeldItems([{ name: "TERA_SHARD", type: Type.GRASS }]).enemySpecies(Species.SPRIGATITO);
|
||||
await game.classicMode.startBattle([Species.PIKACHU]);
|
||||
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
|
||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
||||
|
||||
game.move.select(Moves.TAR_SHOT);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(enemy.getStatStage(Stat.SPD)).toBe(-1);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
game.move.select(Moves.FIRE_PUNCH);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
||||
}, TIMEOUT);
|
||||
|
||||
it("doubles the effectiveness of Fire-type moves against a Pokémon that is already under the effects of Tar Shot before it Terastallized", async () => {
|
||||
game.override.enemySpecies(Species.SPRIGATITO);
|
||||
await game.classicMode.startBattle([Species.PIKACHU]);
|
||||
|
||||
const enemy = game.scene.getEnemyPokemon()!;
|
||||
|
||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
||||
|
||||
game.move.select(Moves.TAR_SHOT);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(enemy.getStatStage(Stat.SPD)).toBe(-1);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
game.override.enemyHeldItems([{ name: "TERA_SHARD", type: Type.GRASS }]);
|
||||
|
||||
game.move.select(Moves.FIRE_PUNCH);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
|
||||
await game.phaseInterceptor.to("MoveEndPhase");
|
||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4);
|
||||
}, TIMEOUT);
|
||||
});
|
11
src/utils.ts
11
src/utils.ts
@ -609,3 +609,14 @@ export function toDmgValue(value: number, minValue: number = 1) {
|
||||
export function getLocalizedSpriteKey(baseKey: string) {
|
||||
return `${baseKey}${verifyLang(i18next.resolvedLanguage) ? `_${i18next.resolvedLanguage}` : ""}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a number is **inclusive** between two numbers
|
||||
* @param num the number to check
|
||||
* @param min the minimum value (included)
|
||||
* @param max the maximum value (included)
|
||||
* @returns true if number is **inclusive** between min and max
|
||||
*/
|
||||
export function isBetween(num: number, min: number, max: number): boolean {
|
||||
return num >= min && num <= max;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user