add unit tests for Dancing Lessons and Part-Timer
This commit is contained in:
parent
f90d8b0575
commit
7c9d34a2bb
|
@ -1,4 +1,4 @@
|
|||
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { EnemyPartyConfig, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards, transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import Pokemon, { PlayerPokemon, PokemonMove } from "#app/field/pokemon";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { Species } from "#enums/species";
|
||||
|
@ -23,6 +23,7 @@ import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
|||
import { BattlerIndex } from "#app/battle";
|
||||
import { catchPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
|
||||
/** the i18n namespace for this encounter */
|
||||
const namespace = "mysteryEncounter:dancingLessons";
|
||||
|
@ -179,6 +180,7 @@ export const DancingLessonsEncounter: IMysteryEncounter =
|
|||
ignorePp: true
|
||||
});
|
||||
|
||||
setEncounterRewards(scene, { guaranteedModifierTypeFuncs: [modifierTypes.BATON], fillRemaining: true });
|
||||
await initBattleWithEnemyConfig(scene, encounter.enemyPartyConfigs[0]);
|
||||
})
|
||||
.build()
|
||||
|
@ -223,7 +225,7 @@ export const DancingLessonsEncounter: IMysteryEncounter =
|
|||
.withDialogue({
|
||||
buttonLabel: `${namespace}.option.3.label`,
|
||||
buttonTooltip: `${namespace}.option.3.tooltip`,
|
||||
disabledButtonTooltip: `${namespace}.option.3.tooltip`,
|
||||
disabledButtonTooltip: `${namespace}.option.3.disabled_tooltip`,
|
||||
secondOptionPrompt: `${namespace}.option.3.select_prompt`,
|
||||
selected: [
|
||||
{
|
||||
|
@ -242,9 +244,11 @@ export const DancingLessonsEncounter: IMysteryEncounter =
|
|||
const option: OptionSelectItem = {
|
||||
label: move.getName(),
|
||||
handler: () => {
|
||||
// Pokemon and second option selected
|
||||
// Pokemon and second option selected
|
||||
encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
|
||||
encounter.setDialogueToken("selectedMove", move.getName());
|
||||
encounter.misc.selectedMove = move;
|
||||
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
@ -267,9 +271,20 @@ export const DancingLessonsEncounter: IMysteryEncounter =
|
|||
})
|
||||
.withOptionPhase(async (scene: BattleScene) => {
|
||||
// Show the Oricorio a dance, and recruit it
|
||||
const oricorio = scene.currentBattle.mysteryEncounter.misc.oricorioData.toPokemon(scene);
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
const oricorio = encounter.misc.oricorioData.toPokemon(scene);
|
||||
oricorio.passive = true;
|
||||
|
||||
// Ensure the Oricorio's moveset gains the Dance move the player used
|
||||
const move = encounter.misc.selectedMove?.getMove().id;
|
||||
if (!oricorio.moveset.some(m => m.getMove().id === move)) {
|
||||
if (oricorio.moveset.length < 4) {
|
||||
oricorio.moveset.push(new PokemonMove(move));
|
||||
} else {
|
||||
oricorio.moveset[3] = new PokemonMove(move);
|
||||
}
|
||||
}
|
||||
|
||||
transitionMysteryEncounterIntroVisuals(scene, true, true, 500);
|
||||
await catchPokemon(scene, oricorio, null, PokeballType.POKEBALL, false);
|
||||
leaveEncounterWithoutBattle(scene, true);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards, transitionMysteryEncounterIntroVisuals, updatePlayerMoney } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterExp, setEncounterRewards, transitionMysteryEncounterIntroVisuals, updatePlayerMoney } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import IMysteryEncounter, { MysteryEncounterBuilder } from "../mystery-encounter";
|
||||
|
@ -87,10 +87,10 @@ export const PartTimerEncounter: IMysteryEncounter =
|
|||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
|
||||
|
||||
// Calculate the "baseline" stat value (100 base stat, 31 IVs, neutral nature, same level as pokemon) to compare
|
||||
// Calculate the "baseline" stat value (90 base stat, 16 IVs, neutral nature, same level as pokemon) to compare
|
||||
// Resulting money is 2.5 * (% difference from baseline), with minimum of 1 and maximum of 4.
|
||||
// Calculation from Pokemon.calculateStats
|
||||
const baselineValue = Math.floor(((2 * 100 + 31) * pokemon.level) * 0.01) + 5;
|
||||
const baselineValue = Math.floor(((2 * 90 + 16) * pokemon.level) * 0.01) + 5;
|
||||
const percentDiff = (pokemon.getStat(Stat.SPD) - baselineValue) / baselineValue;
|
||||
const moneyMultiplier = Math.min(Math.max(2.5 * (1+ percentDiff), 1), 4);
|
||||
|
||||
|
@ -104,6 +104,8 @@ export const PartTimerEncounter: IMysteryEncounter =
|
|||
move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed;
|
||||
});
|
||||
|
||||
setEncounterExp(scene, pokemon.id, 100);
|
||||
|
||||
// Hide intro visuals
|
||||
transitionMysteryEncounterIntroVisuals(scene, true, false);
|
||||
// Play sfx for "working"
|
||||
|
@ -161,15 +163,15 @@ export const PartTimerEncounter: IMysteryEncounter =
|
|||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender());
|
||||
|
||||
// Calculate the "baseline" stat value (100 base stat, 31 IVs, neutral nature, same level as pokemon) to compare
|
||||
// Calculate the "baseline" stat value (75 base stat, 16 IVs, neutral nature, same level as pokemon) to compare
|
||||
// Resulting money is 2.5 * (% difference from baseline), with minimum of 1 and maximum of 4.
|
||||
// Calculation from Pokemon.calculateStats
|
||||
const baselineHp = Math.floor(((2 * 80 + 31) * pokemon.level) * 0.01) + pokemon.level + 10;
|
||||
const baselineAtkDef = Math.floor(((2 * 80 + 31) * pokemon.level) * 0.01) + 5;
|
||||
const baselineHp = Math.floor(((2 * 75 + 16) * pokemon.level) * 0.01) + pokemon.level + 10;
|
||||
const baselineAtkDef = Math.floor(((2 * 75 + 16) * pokemon.level) * 0.01) + 5;
|
||||
const baselineValue = baselineHp + 1.5 * (baselineAtkDef * 2);
|
||||
const strongestValue = pokemon.getStat(Stat.HP) + 1.5 * (pokemon.getStat(Stat.ATK) + pokemon.getStat(Stat.DEF));
|
||||
const percentDiff = (strongestValue - baselineValue) / baselineValue;
|
||||
const moneyMultiplier = Math.min(Math.max(2.5 * (1+ percentDiff), 1), 4);
|
||||
const moneyMultiplier = Math.min(Math.max(2.5 * (1 + percentDiff), 1), 4);
|
||||
|
||||
encounter.misc = {
|
||||
moneyMultiplier
|
||||
|
@ -181,6 +183,8 @@ export const PartTimerEncounter: IMysteryEncounter =
|
|||
move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed;
|
||||
});
|
||||
|
||||
setEncounterExp(scene, pokemon.id, 100);
|
||||
|
||||
// Hide intro visuals
|
||||
transitionMysteryEncounterIntroVisuals(scene, true, false);
|
||||
// Play sfx for "working"
|
||||
|
@ -246,6 +250,8 @@ export const PartTimerEncounter: IMysteryEncounter =
|
|||
move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed;
|
||||
});
|
||||
|
||||
setEncounterExp(scene, selectedPokemon.id, 100);
|
||||
|
||||
// Hide intro visuals
|
||||
transitionMysteryEncounterIntroVisuals(scene, true, false);
|
||||
// Play sfx for "working"
|
||||
|
|
|
@ -127,9 +127,9 @@ class DefaultOverrides {
|
|||
// -------------------------
|
||||
|
||||
// 1 to 256, set to null to ignore
|
||||
readonly MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = 256;
|
||||
readonly MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = null;
|
||||
readonly MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier = null;
|
||||
readonly MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = MysteryEncounterType.DANCING_LESSONS;
|
||||
readonly MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = null;
|
||||
|
||||
// -------------------------
|
||||
// MODIFIER / ITEM OVERRIDES
|
||||
|
|
|
@ -861,7 +861,7 @@ export class EncounterPhase extends BattlePhase {
|
|||
if (!this.loaded) {
|
||||
if (battle.battleType === BattleType.TRAINER) {
|
||||
battle.enemyParty[e] = battle.trainer.genPartyMember(e);
|
||||
} else if (battle.battleType !== BattleType.MYSTERY_ENCOUNTER) {
|
||||
} else {
|
||||
const enemySpecies = this.scene.randomSpecies(battle.waveIndex, level, true);
|
||||
battle.enemyParty[e] = this.scene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, !!this.scene.getEncounterBossSegments(battle.waveIndex, level, enemySpecies));
|
||||
if (this.scene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler";
|
|||
* @param secondaryOptionSelect -
|
||||
* @param isBattle - if selecting option should lead to battle, set to true
|
||||
*/
|
||||
export async function runMysteryEncounterToEnd(game: GameManager, optionNo: number, secondaryOptionSelect: { pokemonNo: number, optionNo: number } = null, isBattle: boolean = false) {
|
||||
export async function runMysteryEncounterToEnd(game: GameManager, optionNo: number, secondaryOptionSelect: { pokemonNo: number, optionNo?: number } = null, isBattle: boolean = false) {
|
||||
vi.spyOn(EncounterPhaseUtils, "selectPokemonForOption");
|
||||
await runSelectMysteryEncounterOption(game, optionNo, secondaryOptionSelect);
|
||||
|
||||
|
@ -65,7 +65,7 @@ export async function runMysteryEncounterToEnd(game: GameManager, optionNo: numb
|
|||
}
|
||||
}
|
||||
|
||||
export async function runSelectMysteryEncounterOption(game: GameManager, optionNo: number, secondaryOptionSelect: { pokemonNo: number, optionNo: number } = null) {
|
||||
export async function runSelectMysteryEncounterOption(game: GameManager, optionNo: number, secondaryOptionSelect: { pokemonNo: number, optionNo?: number } = null) {
|
||||
// Handle any eventual queued messages (e.g. weather phase, etc.)
|
||||
game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => {
|
||||
const uiHandler = game.scene.ui.getHandler<MessageUiHandler>();
|
||||
|
@ -112,7 +112,7 @@ export async function runSelectMysteryEncounterOption(game: GameManager, optionN
|
|||
}
|
||||
}
|
||||
|
||||
async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number, optionNo: number) {
|
||||
async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number, optionNo?: number) {
|
||||
// Handle secondary option selections
|
||||
const partyUiHandler = game.scene.ui.handlers[Mode.PARTY] as PartyUiHandler;
|
||||
vi.spyOn(partyUiHandler, "show");
|
||||
|
|
|
@ -0,0 +1,246 @@
|
|||
import { Biome } from "#app/enums/biome";
|
||||
import { MysteryEncounterType } from "#app/enums/mystery-encounter-type";
|
||||
import { Species } from "#app/enums/species";
|
||||
import GameManager from "#app/test/utils/gameManager";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounterTestUtils";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encounters";
|
||||
import { CommandPhase, LearnMovePhase, MovePhase, SelectModifierPhase } from "#app/phases";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { DancingLessonsEncounter } from "#app/data/mystery-encounters/encounters/dancing-lessons-encounter";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
||||
import { PokemonMove } from "#app/field/pokemon";
|
||||
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
|
||||
|
||||
const namespace = "mysteryEncounter:dancingLessons";
|
||||
const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA];
|
||||
const defaultBiome = Biome.PLAINS;
|
||||
const defaultWave = 45;
|
||||
|
||||
describe("Dancing Lessons - Mystery Encounter", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
let scene: BattleScene;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({ type: Phaser.HEADLESS });
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
game = new GameManager(phaserGame);
|
||||
scene = game.scene;
|
||||
game.override.mysteryEncounterChance(100);
|
||||
game.override.startingWave(defaultWave);
|
||||
game.override.startingBiome(defaultBiome);
|
||||
game.override.disableTrainerWaves(true);
|
||||
|
||||
vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(
|
||||
new Map<Biome, MysteryEncounterType[]>([
|
||||
[Biome.PLAINS, [MysteryEncounterType.DANCING_LESSONS]],
|
||||
[Biome.SPACE, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]],
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it("should have the correct properties", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
|
||||
expect(DancingLessonsEncounter.encounterType).toBe(MysteryEncounterType.DANCING_LESSONS);
|
||||
expect(DancingLessonsEncounter.encounterTier).toBe(MysteryEncounterTier.GREAT);
|
||||
expect(DancingLessonsEncounter.dialogue).toBeDefined();
|
||||
expect(DancingLessonsEncounter.dialogue.intro).toStrictEqual([{ text: `${namespace}.intro` }]);
|
||||
expect(DancingLessonsEncounter.dialogue.encounterOptionsDialogue.title).toBe(`${namespace}.title`);
|
||||
expect(DancingLessonsEncounter.dialogue.encounterOptionsDialogue.description).toBe(`${namespace}.description`);
|
||||
expect(DancingLessonsEncounter.dialogue.encounterOptionsDialogue.query).toBe(`${namespace}.query`);
|
||||
expect(DancingLessonsEncounter.options.length).toBe(3);
|
||||
});
|
||||
|
||||
it("should not run below wave 10", async () => {
|
||||
game.override.startingWave(9);
|
||||
|
||||
await game.runToMysteryEncounter();
|
||||
|
||||
expect(scene.currentBattle?.mysteryEncounter?.encounterType).not.toBe(MysteryEncounterType.DANCING_LESSONS);
|
||||
});
|
||||
|
||||
it("should not run above wave 179", async () => {
|
||||
game.override.startingWave(181);
|
||||
|
||||
await game.runToMysteryEncounter();
|
||||
|
||||
expect(scene.currentBattle.mysteryEncounter).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should not spawn outside of proper biomes", async () => {
|
||||
game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT);
|
||||
game.override.startingBiome(Biome.SPACE);
|
||||
await game.runToMysteryEncounter();
|
||||
|
||||
expect(game.scene.currentBattle.mysteryEncounter?.encounterType).not.toBe(MysteryEncounterType.DANCING_LESSONS);
|
||||
});
|
||||
|
||||
describe("Option 1 - Fight the Oricorio", () => {
|
||||
it("should have the correct properties", () => {
|
||||
const option1 = DancingLessonsEncounter.options[0];
|
||||
expect(option1.optionMode).toBe(MysteryEncounterOptionMode.DEFAULT);
|
||||
expect(option1.dialogue).toBeDefined();
|
||||
expect(option1.dialogue).toStrictEqual({
|
||||
buttonLabel: `${namespace}.option.1.label`,
|
||||
buttonTooltip: `${namespace}.option.1.tooltip`,
|
||||
selected: [
|
||||
{
|
||||
text: `${namespace}.option.1.selected`,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should start battle against Oricorio", async () => {
|
||||
const phaseSpy = vi.spyOn(scene, "pushPhase");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 1, null, true);
|
||||
|
||||
const enemyField = scene.getEnemyField();
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
||||
expect(enemyField.length).toBe(1);
|
||||
expect(enemyField[0].species.speciesId).toBe(Species.ORICORIO);
|
||||
expect(enemyField[0].summonData.battleStats).toEqual([1, 1, 1, 1, 1, 0, 0]);
|
||||
const moveset = enemyField[0].moveset.map(m => m.moveId);
|
||||
expect(moveset.some(m => m === Moves.REVELATION_DANCE)).toBeTruthy();
|
||||
|
||||
const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]);
|
||||
expect(movePhases.length).toBe(1);
|
||||
expect(movePhases.filter(p => (p as MovePhase).move.moveId === Moves.REVELATION_DANCE).length).toBe(1); // Revelation Dance used before battle
|
||||
});
|
||||
|
||||
it("should have a Baton in the rewards after battle", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 1, null, true);
|
||||
await skipBattleRunMysteryEncounterRewardsPhase(game);
|
||||
await game.phaseInterceptor.to(SelectModifierPhase, false);
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(SelectModifierPhase.name);
|
||||
await game.phaseInterceptor.run(SelectModifierPhase);
|
||||
|
||||
expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT);
|
||||
const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler;
|
||||
expect(modifierSelectHandler.options.length).toEqual(3); // Should fill remaining
|
||||
expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toContain("BATON");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Option 2 - Learn its Dance", () => {
|
||||
it("should have the correct properties", () => {
|
||||
const option = DancingLessonsEncounter.options[1];
|
||||
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DEFAULT);
|
||||
expect(option.dialogue).toBeDefined();
|
||||
expect(option.dialogue).toStrictEqual({
|
||||
buttonLabel: `${namespace}.option.2.label`,
|
||||
buttonTooltip: `${namespace}.option.2.tooltip`,
|
||||
selected: [
|
||||
{
|
||||
text: `${namespace}.option.2.selected`,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("Should select a pokemon to learn Revelation Dance", async () => {
|
||||
const phaseSpy = vi.spyOn(scene, "unshiftPhase");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
|
||||
|
||||
const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof LearnMovePhase).map(p => p[0]);
|
||||
expect(movePhases.length).toBe(1);
|
||||
expect(movePhases.filter(p => (p as LearnMovePhase)["moveId"] === Moves.REVELATION_DANCE).length).toBe(1); // Revelation Dance taught to pokemon
|
||||
});
|
||||
|
||||
it("should leave encounter without battle", async () => {
|
||||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
|
||||
|
||||
expect(leaveEncounterWithoutBattleSpy).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Option 3 - Teach it a Dance", () => {
|
||||
it("should have the correct properties", () => {
|
||||
const option = DancingLessonsEncounter.options[2];
|
||||
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL);
|
||||
expect(option.dialogue).toBeDefined();
|
||||
expect(option.dialogue).toStrictEqual({
|
||||
buttonLabel: `${namespace}.option.3.label`,
|
||||
buttonTooltip: `${namespace}.option.3.tooltip`,
|
||||
disabledButtonTooltip: `${namespace}.option.3.disabled_tooltip`,
|
||||
secondOptionPrompt: `${namespace}.option.3.select_prompt`,
|
||||
selected: [
|
||||
{
|
||||
text: `${namespace}.option.3.selected`,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should add Oricorio to the party", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
const partyCountBefore = scene.getParty().length;
|
||||
scene.getParty()[0].moveset = [new PokemonMove(Moves.DRAGON_DANCE)];
|
||||
await runMysteryEncounterToEnd(game, 3, {pokemonNo: 1, optionNo: 1});
|
||||
const partyCountAfter = scene.getParty().length;
|
||||
|
||||
expect(partyCountBefore + 1).toBe(partyCountAfter);
|
||||
const oricorio = scene.getParty()[scene.getParty().length - 1];
|
||||
expect(oricorio.species.speciesId).toBe(Species.ORICORIO);
|
||||
const moveset = oricorio.moveset.map(m => m.moveId);
|
||||
expect(moveset?.some(m => m === Moves.REVELATION_DANCE)).toBeTruthy();
|
||||
expect(moveset?.some(m => m === Moves.DRAGON_DANCE)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should NOT be selectable if the player doesn't have a Dance type move", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
const partyCountBefore = scene.getParty().length;
|
||||
scene.getParty().forEach(p => p.moveset = []);
|
||||
await game.phaseInterceptor.to(MysteryEncounterPhase, false);
|
||||
|
||||
const encounterPhase = scene.getCurrentPhase();
|
||||
expect(encounterPhase.constructor.name).toBe(MysteryEncounterPhase.name);
|
||||
const mysteryEncounterPhase = encounterPhase as MysteryEncounterPhase;
|
||||
vi.spyOn(mysteryEncounterPhase, "continueEncounter");
|
||||
vi.spyOn(mysteryEncounterPhase, "handleOptionSelect");
|
||||
vi.spyOn(scene.ui, "playError");
|
||||
|
||||
await runSelectMysteryEncounterOption(game, 3);
|
||||
const partyCountAfter = scene.getParty().length;
|
||||
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(MysteryEncounterPhase.name);
|
||||
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
|
||||
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
|
||||
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
|
||||
expect(partyCountBefore).toBe(partyCountAfter);
|
||||
});
|
||||
|
||||
it("should leave encounter without battle", async () => {
|
||||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
|
||||
scene.getParty()[0].moveset = [new PokemonMove(Moves.DRAGON_DANCE)];
|
||||
await runMysteryEncounterToEnd(game, 3, {pokemonNo: 1, optionNo: 1});
|
||||
|
||||
expect(leaveEncounterWithoutBattleSpy).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -5,22 +5,23 @@ import { Species } from "#app/enums/species";
|
|||
import GameManager from "#app/test/utils/gameManager";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounterTestUtils";
|
||||
import { SelectModifierPhase } from "#app/phases";
|
||||
import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounterTestUtils";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
||||
import { CIVILIZATION_ENCOUNTER_BIOMES } from "#app/data/mystery-encounters/mystery-encounters";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import { PartTimerEncounter } from "#app/data/mystery-encounters/encounters/part-timer-encounter";
|
||||
import { PokemonMove } from "#app/field/pokemon";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
|
||||
|
||||
const namespace = "mysteryEncounter:departmentStoreSale";
|
||||
const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA];
|
||||
const namespace = "mysteryEncounter:partTimer";
|
||||
// Pyukumuku for lowest speed, Regieleki for highest speed, Feebas for lowest "bulk", Melmetal for highest "bulk"
|
||||
const defaultParty = [Species.PYUKUMUKU, Species.REGIELEKI, Species.FEEBAS, Species.MELMETAL];
|
||||
const defaultBiome = Biome.PLAINS;
|
||||
const defaultWave = 37;
|
||||
|
||||
describe("Department Store Sale - Mystery Encounter", () => {
|
||||
describe("Part-Timer - Mystery Encounter", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
let scene: BattleScene;
|
||||
|
@ -111,17 +112,42 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should have shop with only TMs", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 1);
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(SelectModifierPhase.name);
|
||||
await game.phaseInterceptor.run(SelectModifierPhase);
|
||||
it("should give the player 1x money multiplier money with max slowest Pokemon", async () => {
|
||||
vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
|
||||
|
||||
expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT);
|
||||
const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler;
|
||||
expect(modifierSelectHandler.options.length).toEqual(4);
|
||||
for (const option of modifierSelectHandler.options) {
|
||||
expect(option.modifierTypeOption.type.id).toContain("TM_");
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
// Override party levels to 50 so stats can be fully reflective
|
||||
scene.getParty().forEach(p => {
|
||||
p.level = 50;
|
||||
p.calculateStats();
|
||||
});
|
||||
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 });
|
||||
|
||||
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene, scene.getWaveMoneyAmount(1), true, false);
|
||||
// Expect PP of mon's moves to have been reduced to 2
|
||||
const moves = scene.getParty()[0].moveset;
|
||||
for (const move of moves) {
|
||||
expect(move.getMovePp() - move.ppUsed).toBe(2);
|
||||
}
|
||||
});
|
||||
|
||||
it("should give the player 4x money multiplier money with max fastest Pokemon", async () => {
|
||||
vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
// Override party levels to 50 so stats can be fully reflective
|
||||
scene.getParty().forEach(p => {
|
||||
p.level = 50;
|
||||
p.ivs = [20,20,20,20,20,20];
|
||||
p.calculateStats();
|
||||
});
|
||||
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 2 });
|
||||
|
||||
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene, scene.getWaveMoneyAmount(4), true, false);
|
||||
// Expect PP of mon's moves to have been reduced to 2
|
||||
const moves = scene.getParty()[1].moveset;
|
||||
for (const move of moves) {
|
||||
expect(move.getMovePp() - move.ppUsed).toBe(2);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -129,13 +155,13 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 1);
|
||||
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 });
|
||||
|
||||
expect(leaveEncounterWithoutBattleSpy).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Option 2 - Vitamin Shop", () => {
|
||||
describe("Option 2 - Help in the Warehouse", () => {
|
||||
it("should have the correct properties", () => {
|
||||
const option = PartTimerEncounter.options[1];
|
||||
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DEFAULT);
|
||||
|
@ -151,18 +177,42 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should have shop with only Vitamins", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 2);
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(SelectModifierPhase.name);
|
||||
await game.phaseInterceptor.run(SelectModifierPhase);
|
||||
it("should give the player 1x money multiplier money with least bulky Pokemon", async () => {
|
||||
vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
|
||||
|
||||
expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT);
|
||||
const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler;
|
||||
expect(modifierSelectHandler.options.length).toEqual(3);
|
||||
for (const option of modifierSelectHandler.options) {
|
||||
expect(option.modifierTypeOption.type.id.includes("PP_UP") ||
|
||||
option.modifierTypeOption.type.id.includes("BASE_STAT_BOOSTER")).toBeTruthy();
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
// Override party levels to 50 so stats can be fully reflective
|
||||
scene.getParty().forEach(p => {
|
||||
p.level = 50;
|
||||
p.calculateStats();
|
||||
});
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 3 });
|
||||
|
||||
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene, scene.getWaveMoneyAmount(1), true, false);
|
||||
// Expect PP of mon's moves to have been reduced to 2
|
||||
const moves = scene.getParty()[2].moveset;
|
||||
for (const move of moves) {
|
||||
expect(move.getMovePp() - move.ppUsed).toBe(2);
|
||||
}
|
||||
});
|
||||
|
||||
it("should give the player 4x money multiplier money with bulkiest Pokemon", async () => {
|
||||
vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
// Override party levels to 50 so stats can be fully reflective
|
||||
scene.getParty().forEach(p => {
|
||||
p.level = 50;
|
||||
p.ivs = [20,20,20,20,20,20];
|
||||
p.calculateStats();
|
||||
});
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 4 });
|
||||
|
||||
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene, scene.getWaveMoneyAmount(4), true, false);
|
||||
// Expect PP of mon's moves to have been reduced to 2
|
||||
const moves = scene.getParty()[3].moveset;
|
||||
for (const move of moves) {
|
||||
expect(move.getMovePp() - move.ppUsed).toBe(2);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -170,7 +220,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 2);
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
|
||||
|
||||
expect(leaveEncounterWithoutBattleSpy).toBeCalled();
|
||||
});
|
||||
|
@ -179,11 +229,12 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
describe("Option 3 - Assist with Sales", () => {
|
||||
it("should have the correct properties", () => {
|
||||
const option = PartTimerEncounter.options[2];
|
||||
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DEFAULT);
|
||||
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL);
|
||||
expect(option.dialogue).toBeDefined();
|
||||
expect(option.dialogue).toStrictEqual({
|
||||
buttonLabel: `${namespace}.option.3.label`,
|
||||
buttonTooltip: `${namespace}.option.3.tooltip`,
|
||||
disabledButtonTooltip: `${namespace}.option.3.disabled_tooltip`,
|
||||
selected: [
|
||||
{
|
||||
text: `${namespace}.option.3.selected`
|
||||
|
@ -192,18 +243,43 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should have shop with only X Items", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 3);
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(SelectModifierPhase.name);
|
||||
await game.phaseInterceptor.run(SelectModifierPhase);
|
||||
it("Should NOT be selectable when requirements are not met", async () => {
|
||||
vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
|
||||
|
||||
expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT);
|
||||
const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler;
|
||||
expect(modifierSelectHandler.options.length).toEqual(5);
|
||||
for (const option of modifierSelectHandler.options) {
|
||||
expect(option.modifierTypeOption.type.id.includes("DIRE_HIT") ||
|
||||
option.modifierTypeOption.type.id.includes("TEMP_STAT_BOOSTER")).toBeTruthy();
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
// Mock movesets
|
||||
scene.getParty().forEach(p => p.moveset = []);
|
||||
await game.phaseInterceptor.to(MysteryEncounterPhase, false);
|
||||
|
||||
const encounterPhase = scene.getCurrentPhase();
|
||||
expect(encounterPhase.constructor.name).toBe(MysteryEncounterPhase.name);
|
||||
const mysteryEncounterPhase = encounterPhase as MysteryEncounterPhase;
|
||||
vi.spyOn(mysteryEncounterPhase, "continueEncounter");
|
||||
vi.spyOn(mysteryEncounterPhase, "handleOptionSelect");
|
||||
vi.spyOn(scene.ui, "playError");
|
||||
|
||||
await runSelectMysteryEncounterOption(game, 3);
|
||||
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(MysteryEncounterPhase.name);
|
||||
expect(scene.ui.playError).not.toHaveBeenCalled(); // No error sfx, option is disabled
|
||||
expect(mysteryEncounterPhase.handleOptionSelect).not.toHaveBeenCalled();
|
||||
expect(mysteryEncounterPhase.continueEncounter).not.toHaveBeenCalled();
|
||||
expect(EncounterPhaseUtils.updatePlayerMoney).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should be selectable and give the player 2.5x money multiplier money with requirements met", async () => {
|
||||
vi.spyOn(EncounterPhaseUtils, "updatePlayerMoney");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
// Mock moveset
|
||||
scene.getParty()[0].moveset = [new PokemonMove(Moves.ATTRACT)];
|
||||
await runMysteryEncounterToEnd(game, 3);
|
||||
|
||||
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene, scene.getWaveMoneyAmount(2.5), true, false);
|
||||
// Expect PP of mon's moves to have been reduced to 2
|
||||
const moves = scene.getParty()[0].moveset;
|
||||
for (const move of moves) {
|
||||
expect(move.getMovePp() - move.ppUsed).toBe(2);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -211,42 +287,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
|
|||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 3);
|
||||
|
||||
expect(leaveEncounterWithoutBattleSpy).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Option 4 - Pokeball Shop", () => {
|
||||
it("should have the correct properties", () => {
|
||||
const option = PartTimerEncounter.options[3];
|
||||
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DEFAULT);
|
||||
expect(option.dialogue).toBeDefined();
|
||||
expect(option.dialogue).toStrictEqual({
|
||||
buttonLabel: `${namespace}.option.4.label`,
|
||||
buttonTooltip: `${namespace}.option.4.tooltip`,
|
||||
});
|
||||
});
|
||||
|
||||
it("should have shop with only Pokeballs", async () => {
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 4);
|
||||
expect(scene.getCurrentPhase().constructor.name).toBe(SelectModifierPhase.name);
|
||||
await game.phaseInterceptor.run(SelectModifierPhase);
|
||||
|
||||
expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT);
|
||||
const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler;
|
||||
expect(modifierSelectHandler.options.length).toEqual(4);
|
||||
for (const option of modifierSelectHandler.options) {
|
||||
expect(option.modifierTypeOption.type.id).toContain("BALL");
|
||||
}
|
||||
});
|
||||
|
||||
it("should leave encounter without battle", async () => {
|
||||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
|
||||
await runMysteryEncounterToEnd(game, 4);
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
|
||||
|
||||
expect(leaveEncounterWithoutBattleSpy).toBeCalled();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue