mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-15 20:09:30 +02:00
Added overrideGameWithChallenges
This commit is contained in:
parent
216018b409
commit
13a4b99072
@ -61,15 +61,24 @@ export class GameMode implements GameModeConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables challenges if they are disabled and sets the specified challenge's value
|
* Enables challenges if they are disabled and sets the specified challenge's value
|
||||||
* @param challenge The challenge to set
|
* @param challenge - The challenge to set
|
||||||
* @param value The value to give the challenge. Impact depends on the specific challenge
|
* @param value - The value to give the challenge. Impact depends on the specific challenge
|
||||||
|
* @param severity - If provided, will override the given severity amount. Unused if `challenge` does not use severity
|
||||||
|
* @todo Add severity support to daily mode challenge setting
|
||||||
*/
|
*/
|
||||||
setChallengeValue(challenge: Challenges, value: number) {
|
setChallengeValue(challenge: Challenges, value: number, severity?: number) {
|
||||||
if (!this.isChallenge) {
|
if (!this.isChallenge) {
|
||||||
this.isChallenge = true;
|
this.isChallenge = true;
|
||||||
this.challenges = allChallenges.map(c => copyChallenge(c));
|
this.challenges = allChallenges.map(c => copyChallenge(c));
|
||||||
}
|
}
|
||||||
this.challenges.filter((chal: Challenge) => chal.id === challenge).map((chal: Challenge) => (chal.value = value));
|
this.challenges
|
||||||
|
.filter((chal: Challenge) => chal.id === challenge)
|
||||||
|
.forEach(chal => {
|
||||||
|
chal.value = value;
|
||||||
|
if (chal.hasSeverity()) {
|
||||||
|
chal.severity = severity ?? chal.severity;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { BattlerIndex } from "#enums/battler-index";
|
import { BattlerIndex } from "#enums/battler-index";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { GameManager } from "#test/test-utils/game-manager";
|
import { GameManager } from "#test/test-utils/game-manager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
@ -113,4 +114,18 @@ describe("Abilities - Tera Shell", () => {
|
|||||||
}
|
}
|
||||||
expect(spy).toHaveReturnedTimes(2);
|
expect(spy).toHaveReturnedTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should overwrite Freeze-Dry", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.TERAPAGOS]);
|
||||||
|
|
||||||
|
const terapagos = game.field.getPlayerPokemon();
|
||||||
|
terapagos.summonData.types = [PokemonType.WATER];
|
||||||
|
const spy = vi.spyOn(terapagos, "getMoveEffectiveness");
|
||||||
|
|
||||||
|
game.move.use(MoveId.SPLASH);
|
||||||
|
await game.move.forceEnemyMove(MoveId.FREEZE_DRY);
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(spy).toHaveLastReturnedWith(0.5);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -106,21 +106,6 @@ describe("Inverse Battle", () => {
|
|||||||
expect(currentHp).toBeGreaterThan((maxHp * 31) / 32 - 1);
|
expect(currentHp).toBeGreaterThan((maxHp * 31) / 32 - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Freeze Dry is 2x effective against Water Type like other Ice type Move - Freeze Dry against Squirtle", async () => {
|
|
||||||
game.override.moveset([MoveId.FREEZE_DRY]).enemySpecies(SpeciesId.SQUIRTLE);
|
|
||||||
|
|
||||||
await game.challengeMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Water Absorb should heal against water moves - Water Absorb against Water gun", async () => {
|
it("Water Absorb should heal against water moves - Water Absorb against Water gun", async () => {
|
||||||
game.override.moveset([MoveId.WATER_GUN]).enemyAbility(AbilityId.WATER_ABSORB);
|
game.override.moveset([MoveId.WATER_GUN]).enemyAbility(AbilityId.WATER_ABSORB);
|
||||||
|
|
||||||
@ -164,6 +149,7 @@ describe("Inverse Battle", () => {
|
|||||||
expect(enemy.status?.effect).not.toBe(StatusEffect.PARALYSIS);
|
expect(enemy.status?.effect).not.toBe(StatusEffect.PARALYSIS);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: These should belong to their respective moves' test files, not the inverse battle mechanic itself
|
||||||
it("Ground type is not immune to Thunder Wave - Thunder Wave against Sandshrew", async () => {
|
it("Ground type is not immune to Thunder Wave - Thunder Wave against Sandshrew", async () => {
|
||||||
game.override.moveset([MoveId.THUNDER_WAVE]).enemySpecies(SpeciesId.SANDSHREW);
|
game.override.moveset([MoveId.THUNDER_WAVE]).enemySpecies(SpeciesId.SANDSHREW);
|
||||||
|
|
||||||
@ -202,21 +188,6 @@ describe("Inverse Battle", () => {
|
|||||||
expect(player.getTypes()[0]).toBe(PokemonType.DRAGON);
|
expect(player.getTypes()[0]).toBe(PokemonType.DRAGON);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Flying Press should be 0.25x effective against Grass + Dark Type - Flying Press against Meowscarada", async () => {
|
|
||||||
game.override.moveset([MoveId.FLYING_PRESS]).enemySpecies(SpeciesId.MEOWSCARADA);
|
|
||||||
|
|
||||||
await game.challengeMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FLYING_PRESS);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(0.25);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Scrappy ability has no effect - Tackle against Ghost Type still 2x effective with Scrappy", async () => {
|
it("Scrappy ability has no effect - Tackle against Ghost Type still 2x effective with Scrappy", async () => {
|
||||||
game.override.moveset([MoveId.TACKLE]).ability(AbilityId.SCRAPPY).enemySpecies(SpeciesId.GASTLY);
|
game.override.moveset([MoveId.TACKLE]).ability(AbilityId.SCRAPPY).enemySpecies(SpeciesId.GASTLY);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { Challenges } from "#enums/challenges";
|
|||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import type { PlayerPokemon } from "#field/pokemon";
|
import type { EnemyPokemon, PlayerPokemon } from "#field/pokemon";
|
||||||
import { GameManager } from "#test/test-utils/game-manager";
|
import { GameManager } from "#test/test-utils/game-manager";
|
||||||
import { getEnumValues } from "#utils/enums";
|
import { getEnumValues } from "#utils/enums";
|
||||||
import { toTitleCase } from "#utils/strings";
|
import { toTitleCase } from "#utils/strings";
|
||||||
@ -16,6 +16,7 @@ describe.sequential("Move - Flying Press", () => {
|
|||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
let hawlucha: PlayerPokemon;
|
let hawlucha: PlayerPokemon;
|
||||||
|
let enemy: EnemyPokemon;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
@ -26,32 +27,29 @@ describe.sequential("Move - Flying Press", () => {
|
|||||||
game.override
|
game.override
|
||||||
.ability(AbilityId.BALL_FETCH)
|
.ability(AbilityId.BALL_FETCH)
|
||||||
.battleStyle("single")
|
.battleStyle("single")
|
||||||
.criticalHits(false)
|
|
||||||
.enemySpecies(SpeciesId.MAGIKARP)
|
.enemySpecies(SpeciesId.MAGIKARP)
|
||||||
.enemyAbility(AbilityId.BALL_FETCH)
|
.enemyAbility(AbilityId.BALL_FETCH)
|
||||||
.enemyMoveset(MoveId.SPLASH)
|
.enemyMoveset(MoveId.SPLASH);
|
||||||
.startingLevel(100)
|
|
||||||
.enemyLevel(100);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.HAWLUCHA]);
|
await game.classicMode.startBattle([SpeciesId.HAWLUCHA]);
|
||||||
|
|
||||||
hawlucha = game.field.getPlayerPokemon();
|
hawlucha = game.field.getPlayerPokemon();
|
||||||
|
enemy = game.field.getEnemyPokemon();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
game.phaseInterceptor.restoreOg();
|
game.phaseInterceptor.restoreOg();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset temporary summon data overrides to reset effects
|
// Reset temp data after each test
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
hawlucha.resetSummonData();
|
hawlucha.resetSummonData();
|
||||||
expect(hawlucha).not.toHaveBattlerTag(BattlerTagType.ELECTRIFIED);
|
enemy.resetSummonData();
|
||||||
expect(hawlucha.hasAbility(AbilityId.NORMALIZE)).toBe(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const pokemonTypes = getEnumValues(PokemonType);
|
const pokemonTypes = getEnumValues(PokemonType);
|
||||||
|
|
||||||
function checkEffForAllTypes(primaryType: PokemonType) {
|
function checkEffForAllTypes(primaryType: PokemonType) {
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
for (const type of pokemonTypes) {
|
for (const type of pokemonTypes) {
|
||||||
enemy.summonData.types = [type];
|
enemy.summonData.types = [type];
|
||||||
const primaryEff = enemy.getAttackTypeEffectiveness(primaryType, { source: hawlucha });
|
const primaryEff = enemy.getAttackTypeEffectiveness(primaryType, { source: hawlucha });
|
||||||
@ -71,7 +69,7 @@ describe.sequential("Move - Flying Press", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Normal", () => {
|
describe("Normal -", () => {
|
||||||
it("should deal damage as a Fighting/Flying type move by default", async () => {
|
it("should deal damage as a Fighting/Flying type move by default", async () => {
|
||||||
checkEffForAllTypes(PokemonType.FIGHTING);
|
checkEffForAllTypes(PokemonType.FIGHTING);
|
||||||
});
|
});
|
||||||
@ -85,12 +83,25 @@ describe.sequential("Move - Flying Press", () => {
|
|||||||
hawlucha.setTempAbility(allAbilities[AbilityId.NORMALIZE]);
|
hawlucha.setTempAbility(allAbilities[AbilityId.NORMALIZE]);
|
||||||
checkEffForAllTypes(PokemonType.NORMAL);
|
checkEffForAllTypes(PokemonType.NORMAL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should deal 8x damage against a Normal/Ice type with Grass added", () => {
|
||||||
|
enemy.summonData.types = [PokemonType.NORMAL, PokemonType.ICE];
|
||||||
|
enemy.summonData.addedType = PokemonType.GRASS;
|
||||||
|
|
||||||
|
const moveType = hawlucha.getMoveType(allMoves[MoveId.FLYING_PRESS]);
|
||||||
|
const flyingPressEff = enemy.getAttackTypeEffectiveness(moveType, {
|
||||||
|
source: hawlucha,
|
||||||
|
move: allMoves[MoveId.FLYING_PRESS],
|
||||||
|
});
|
||||||
|
expect(flyingPressEff).toBe(8);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Inverse", () => {
|
describe("Inverse Battle -", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
|
game.challengeMode.overrideGameWithChallenges(Challenges.INVERSE_BATTLE, 1, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should deal damage as a Fighting/Flying type move by default", async () => {
|
it("should deal damage as a Fighting/Flying type move by default", async () => {
|
||||||
checkEffForAllTypes(PokemonType.FIGHTING);
|
checkEffForAllTypes(PokemonType.FIGHTING);
|
||||||
});
|
});
|
||||||
@ -107,10 +118,7 @@ describe.sequential("Move - Flying Press", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should deal 2x to Wonder Guard Shedinja under Electrify", () => {
|
it("should deal 2x to Wonder Guard Shedinja under Electrify", () => {
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
game.field.mockAbility(enemy, AbilityId.WONDER_GUARD);
|
game.field.mockAbility(enemy, AbilityId.WONDER_GUARD);
|
||||||
enemy.resetSummonData();
|
|
||||||
|
|
||||||
hawlucha.addTag(BattlerTagType.ELECTRIFIED);
|
hawlucha.addTag(BattlerTagType.ELECTRIFIED);
|
||||||
|
|
||||||
const flyingPressEff = enemy.getAttackTypeEffectiveness(hawlucha.getMoveType(allMoves[MoveId.FLYING_PRESS]), {
|
const flyingPressEff = enemy.getAttackTypeEffectiveness(hawlucha.getMoveType(allMoves[MoveId.FLYING_PRESS]), {
|
||||||
|
@ -1,330 +1,140 @@
|
|||||||
|
import { allMoves } from "#data/data-lists";
|
||||||
|
import type { TypeDamageMultiplier } from "#data/type";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { BattlerIndex } from "#enums/battler-index";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
import { Challenges } from "#enums/challenges";
|
import { Challenges } from "#enums/challenges";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
|
import type { EnemyPokemon, PlayerPokemon } from "#field/pokemon";
|
||||||
import { GameManager } from "#test/test-utils/game-manager";
|
import { GameManager } from "#test/test-utils/game-manager";
|
||||||
|
import { stringifyEnumArray } from "#test/test-utils/string-utils";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
describe("Moves - Freeze-Dry", () => {
|
type typesArray = [PokemonType] | [PokemonType, PokemonType] | [PokemonType, PokemonType, PokemonType];
|
||||||
|
|
||||||
|
describe.sequential("Move - Freeze-Dry", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
beforeAll(() => {
|
let feebas: PlayerPokemon;
|
||||||
|
let enemy: EnemyPokemon;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
type: Phaser.HEADLESS,
|
type: Phaser.HEADLESS,
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
game.phaseInterceptor.restoreOg();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override
|
game.override
|
||||||
.battleStyle("single")
|
.battleStyle("single")
|
||||||
.enemySpecies(SpeciesId.MAGIKARP)
|
.enemySpecies(SpeciesId.MAGIKARP)
|
||||||
.enemyAbility(AbilityId.BALL_FETCH)
|
.enemyAbility(AbilityId.BALL_FETCH)
|
||||||
.enemyMoveset(MoveId.SPLASH)
|
.enemyMoveset(MoveId.SPLASH)
|
||||||
.starterSpecies(SpeciesId.FEEBAS)
|
.ability(AbilityId.BALL_FETCH);
|
||||||
.ability(AbilityId.BALL_FETCH)
|
|
||||||
.moveset([MoveId.FREEZE_DRY, MoveId.FORESTS_CURSE, MoveId.SOAK]);
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
feebas = game.field.getPlayerPokemon();
|
||||||
|
enemy = game.field.getEnemyPokemon();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should deal 2x damage to pure water types", async () => {
|
// Reset temp data after each test
|
||||||
await game.classicMode.startBattle();
|
afterEach(() => {
|
||||||
|
feebas.resetSummonData();
|
||||||
const enemy = game.field.getEnemyPokemon();
|
enemy.resetSummonData();
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
enemy.isTerastallized = false;
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should deal 4x damage to water/flying types", async () => {
|
afterAll(() => {
|
||||||
game.override.enemySpecies(SpeciesId.WINGULL);
|
game.phaseInterceptor.restoreOg();
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 1x damage to water/fire types", async () => {
|
|
||||||
game.override.enemySpecies(SpeciesId.VOLCANION);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Freeze drys forced super effectiveness should overwrite wonder guard
|
* Check that Freeze-Dry is the given effectiveness against the given type.
|
||||||
|
* @param types - The base {@linkcode PokemonType}s to set; will populate `addedType` if above 3
|
||||||
|
* @param multi - The expected {@linkcode TypeDamageMultiplier}
|
||||||
*/
|
*/
|
||||||
it("should deal 2x dmg against soaked wonder guard target", async () => {
|
function expectEffectiveness(types: typesArray, multi: TypeDamageMultiplier): void {
|
||||||
game.override
|
enemy.summonData.types = types.slice(0, 2);
|
||||||
.enemySpecies(SpeciesId.SHEDINJA)
|
if (types[2] !== undefined) {
|
||||||
.enemyMoveset(MoveId.SPLASH)
|
enemy.summonData.addedType = types[2];
|
||||||
.starterSpecies(SpeciesId.MAGIKARP)
|
}
|
||||||
.moveset([MoveId.SOAK, MoveId.FREEZE_DRY]);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
const moveType = feebas.getMoveType(allMoves[MoveId.FREEZE_DRY]);
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
const eff = enemy.getAttackTypeEffectiveness(moveType, { source: feebas, move: allMoves[MoveId.FREEZE_DRY] });
|
||||||
|
expect(
|
||||||
|
eff,
|
||||||
|
`Freeze-dry effectiveness against ${stringifyEnumArray(PokemonType, types)} was ${eff} instead of ${multi}!`,
|
||||||
|
).toBe(multi);
|
||||||
|
}
|
||||||
|
|
||||||
game.move.select(MoveId.SOAK);
|
describe("Normal -", () => {
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
it.each<{ name: string; types: typesArray; eff: TypeDamageMultiplier }>([
|
||||||
await game.toNextTurn();
|
{ name: "Pure Water", types: [PokemonType.WATER], eff: 2 },
|
||||||
|
{ name: "Water/Ground", types: [PokemonType.WATER, PokemonType.GROUND], eff: 4 },
|
||||||
|
{ name: "Water/Flying/Grass", types: [PokemonType.WATER, PokemonType.FLYING, PokemonType.GRASS], eff: 8 },
|
||||||
|
{ name: "Water/Fire", types: [PokemonType.WATER, PokemonType.FIRE], eff: 1 },
|
||||||
|
])("should be $effx effective against a $name-type opponent", ({ types, eff }) => {
|
||||||
|
expectEffectiveness(types, eff);
|
||||||
|
});
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
it("should deal 2x dmg against soaked wonder guard target", async () => {
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
game.field.mockAbility(enemy, AbilityId.WONDER_GUARD);
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
expectEffectiveness([PokemonType.WATER], 2);
|
||||||
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
|
});
|
||||||
|
|
||||||
|
it("should consider the target's Tera Type", async () => {
|
||||||
|
// Steel type terastallized into Water; 2x
|
||||||
|
enemy.teraType = PokemonType.WATER;
|
||||||
|
enemy.isTerastallized = true;
|
||||||
|
|
||||||
|
expectEffectiveness([PokemonType.STEEL], 2);
|
||||||
|
|
||||||
|
// Water type terastallized into steel; 0.5x
|
||||||
|
enemy.teraType = PokemonType.STEEL;
|
||||||
|
expectEffectiveness([PokemonType.WATER], 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each<{ name: string; types: typesArray; eff: TypeDamageMultiplier }>([
|
||||||
|
{ name: "Pure Water", types: [PokemonType.WATER], eff: 2 },
|
||||||
|
{ name: "Water/Ghost", types: [PokemonType.WATER, PokemonType.GHOST], eff: 0 },
|
||||||
|
])("should be $effx effective against a $name-type opponent with Normalize", ({ types, eff }) => {
|
||||||
|
game.field.mockAbility(feebas, AbilityId.NORMALIZE);
|
||||||
|
expectEffectiveness(types, eff);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not stack with Electrify", async () => {
|
||||||
|
feebas.addTag(BattlerTagType.ELECTRIFIED);
|
||||||
|
expect(feebas.getMoveType(allMoves[MoveId.FREEZE_DRY])).toBe(PokemonType.ELECTRIC);
|
||||||
|
|
||||||
|
expectEffectiveness([PokemonType.WATER], 2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should deal 8x damage to water/ground/grass type under Forest's Curse", async () => {
|
describe("Inverse Battle -", () => {
|
||||||
game.override.enemySpecies(SpeciesId.QUAGSIRE);
|
beforeAll(() => {
|
||||||
await game.classicMode.startBattle();
|
game.challengeMode.overrideGameWithChallenges(Challenges.INVERSE_BATTLE, 1, 1);
|
||||||
|
});
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
it("should deal 2x damage to Water type", async () => {
|
||||||
|
expectEffectiveness([PokemonType.WATER], 2);
|
||||||
game.move.select(MoveId.FORESTS_CURSE);
|
});
|
||||||
await game.toNextTurn();
|
|
||||||
|
it("should deal 2x damage to Water type under Normalize", async () => {
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
game.field.mockAbility(feebas, AbilityId.NORMALIZE);
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
expectEffectiveness([PokemonType.WATER], 2);
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
});
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(8);
|
it("should still deal 2x damage to Water type under Electrify", async () => {
|
||||||
});
|
feebas.addTag(BattlerTagType.ELECTRIFIED);
|
||||||
|
expectEffectiveness([PokemonType.WATER], 2);
|
||||||
it("should deal 2x damage to steel type terastallized into water", async () => {
|
});
|
||||||
game.override.enemySpecies(SpeciesId.SKARMORY);
|
|
||||||
await game.classicMode.startBattle();
|
it("should deal 1x damage to Water/Flying type under Electrify", async () => {
|
||||||
|
feebas.addTag(BattlerTagType.ELECTRIFIED);
|
||||||
const enemy = game.field.getEnemyPokemon();
|
expectEffectiveness([PokemonType.WATER, PokemonType.FLYING], 1);
|
||||||
enemy.teraType = PokemonType.WATER;
|
});
|
||||||
enemy.isTerastallized = true;
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 0.5x damage to water type terastallized into fire", async () => {
|
|
||||||
game.override.enemySpecies(SpeciesId.PELIPPER);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
enemy.teraType = PokemonType.FIRE;
|
|
||||||
enemy.isTerastallized = true;
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.5);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 0.5x damage to water type Terapagos with Tera Shell", async () => {
|
|
||||||
game.override.enemySpecies(SpeciesId.TERAPAGOS).enemyAbility(AbilityId.TERA_SHELL);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.SOAK);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.5);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 2x damage to water type under Normalize", async () => {
|
|
||||||
game.override.ability(AbilityId.NORMALIZE);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 0.25x damage to rock/steel type under Normalize", async () => {
|
|
||||||
game.override.ability(AbilityId.NORMALIZE).enemySpecies(SpeciesId.SHIELDON);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.25);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 0x damage to water/ghost type under Normalize", async () => {
|
|
||||||
game.override.ability(AbilityId.NORMALIZE).enemySpecies(SpeciesId.JELLICENT);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 2x damage to water type under Electrify", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.ELECTRIFY]);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 4x damage to water/flying type under Electrify", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.ELECTRIFY]).enemySpecies(SpeciesId.GYARADOS);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 0x damage to water/ground type under Electrify", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.ELECTRIFY]).enemySpecies(SpeciesId.BARBOACH);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 0.25x damage to Grass/Dragon type under Electrify", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.ELECTRIFY]).enemySpecies(SpeciesId.FLAPPLE);
|
|
||||||
await game.classicMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.25);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 2x damage to Water type during inverse battle", async () => {
|
|
||||||
game.override.moveset([MoveId.FREEZE_DRY]).enemySpecies(SpeciesId.MAGIKARP);
|
|
||||||
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
|
|
||||||
|
|
||||||
await game.challengeMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 2x damage to Water type during inverse battle under Normalize", async () => {
|
|
||||||
game.override.moveset([MoveId.FREEZE_DRY]).ability(AbilityId.NORMALIZE).enemySpecies(SpeciesId.MAGIKARP);
|
|
||||||
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
|
|
||||||
|
|
||||||
await game.challengeMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 2x damage to Water type during inverse battle under Electrify", async () => {
|
|
||||||
game.override.moveset([MoveId.FREEZE_DRY]).enemySpecies(SpeciesId.MAGIKARP).enemyMoveset([MoveId.ELECTRIFY]);
|
|
||||||
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
|
|
||||||
|
|
||||||
await game.challengeMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should deal 1x damage to water/flying type during inverse battle under Electrify", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.ELECTRIFY]).enemySpecies(SpeciesId.GYARADOS);
|
|
||||||
|
|
||||||
game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1);
|
|
||||||
|
|
||||||
await game.challengeMode.startBattle();
|
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
|
||||||
vi.spyOn(enemy, "getMoveEffectiveness");
|
|
||||||
|
|
||||||
game.move.select(MoveId.FREEZE_DRY);
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
|
|
||||||
expect(enemy.getMoveEffectiveness).toHaveReturnedWith(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -32,16 +32,25 @@ describe("Moves - Synchronoise", () => {
|
|||||||
.enemyMoveset(MoveId.SPLASH);
|
.enemyMoveset(MoveId.SPLASH);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should consider the user's tera type if it is terastallized", async () => {
|
// TODO: Write test
|
||||||
|
it.todo("should affect all opponents that share a type with the user");
|
||||||
|
|
||||||
|
it("should consider the user's Tera Type if it is Terastallized", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.BIDOOF]);
|
await game.classicMode.startBattle([SpeciesId.BIDOOF]);
|
||||||
|
|
||||||
const playerPokemon = game.field.getPlayerPokemon();
|
const playerPokemon = game.field.getPlayerPokemon();
|
||||||
const enemyPokemon = game.field.getEnemyPokemon();
|
const enemyPokemon = game.field.getEnemyPokemon();
|
||||||
|
|
||||||
// force the player to be terastallized
|
|
||||||
playerPokemon.teraType = PokemonType.WATER;
|
playerPokemon.teraType = PokemonType.WATER;
|
||||||
playerPokemon.isTerastallized = true;
|
game.move.selectWithTera(MoveId.SYNCHRONOISE);
|
||||||
game.move.select(MoveId.SYNCHRONOISE);
|
await game.toEndOfTurn();
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
|
||||||
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
|
expect(enemyPokemon).not.toHaveFullHp();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: Write test
|
||||||
|
it.todo("should fail if no opponents share a type with the user");
|
||||||
|
|
||||||
|
// TODO: Write test
|
||||||
|
it.todo("should fail if the user is typeless");
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,8 @@ import { generateStarter } from "#test/test-utils/game-manager-utils";
|
|||||||
import { GameManagerHelper } from "#test/test-utils/helpers/game-manager-helper";
|
import { GameManagerHelper } from "#test/test-utils/helpers/game-manager-helper";
|
||||||
import { copyChallenge } from "data/challenge";
|
import { copyChallenge } from "data/challenge";
|
||||||
|
|
||||||
|
type challengeStub = { id: Challenges; value: number; severity: number };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to handle Challenge mode specifics
|
* Helper to handle Challenge mode specifics
|
||||||
*/
|
*/
|
||||||
@ -33,8 +35,9 @@ export class ChallengeModeHelper extends GameManagerHelper {
|
|||||||
* Runs the Challenge game to the summon phase.
|
* Runs the Challenge game to the summon phase.
|
||||||
* @param gameMode - Optional game mode to set.
|
* @param gameMode - Optional game mode to set.
|
||||||
* @returns A promise that resolves when the summon phase is reached.
|
* @returns A promise that resolves when the summon phase is reached.
|
||||||
|
* @todo this duplicates nearly all its code with the classic mode variant...
|
||||||
*/
|
*/
|
||||||
async runToSummon(species?: SpeciesId[]) {
|
private async runToSummon(species?: SpeciesId[]) {
|
||||||
await this.game.runToTitle();
|
await this.game.runToTitle();
|
||||||
|
|
||||||
if (this.game.override.disableShinies) {
|
if (this.game.override.disableShinies) {
|
||||||
@ -88,4 +91,26 @@ export class ChallengeModeHelper extends GameManagerHelper {
|
|||||||
await this.game.phaseInterceptor.to(CommandPhase);
|
await this.game.phaseInterceptor.to(CommandPhase);
|
||||||
console.log("==================[New Turn]==================");
|
console.log("==================[New Turn]==================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override an already-started game with the given challenges.
|
||||||
|
* @param id - The challenge id
|
||||||
|
* @param value - The challenge value
|
||||||
|
* @param severity - The challenge severity
|
||||||
|
* @todo Make severity optional for challenges that do not require it
|
||||||
|
*/
|
||||||
|
public overrideGameWithChallenges(id: Challenges, value: number, severity: number): void;
|
||||||
|
/**
|
||||||
|
* Override an already-started game with the given challenges.
|
||||||
|
* @param challenges - One or more challenges to set.
|
||||||
|
*/
|
||||||
|
public overrideGameWithChallenges(challenges: challengeStub[]): void;
|
||||||
|
public overrideGameWithChallenges(challenges: challengeStub[] | Challenges, value?: number, severity?: number): void {
|
||||||
|
if (typeof challenges !== "object") {
|
||||||
|
challenges = [{ id: challenges, value: value!, severity: severity! }];
|
||||||
|
}
|
||||||
|
for (const challenge of challenges) {
|
||||||
|
this.game.scene.gameMode.setChallengeValue(challenge.id, challenge.value, challenge.severity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export class DailyModeHelper extends GameManagerHelper {
|
|||||||
* @returns A promise that resolves when the summon phase is reached.
|
* @returns A promise that resolves when the summon phase is reached.
|
||||||
* @remarks Please do not use for starting normal battles - use {@linkcode startBattle} instead
|
* @remarks Please do not use for starting normal battles - use {@linkcode startBattle} instead
|
||||||
*/
|
*/
|
||||||
async runToSummon(): Promise<void> {
|
private async runToSummon(): Promise<void> {
|
||||||
await this.game.runToTitle();
|
await this.game.runToTitle();
|
||||||
|
|
||||||
if (this.game.override.disableShinies) {
|
if (this.game.override.disableShinies) {
|
||||||
|
Loading…
Reference in New Issue
Block a user