finishing touches

This commit is contained in:
Felix Staud 2024-07-11 14:58:52 -07:00
parent 39f98222a6
commit 941a8e71d6
5 changed files with 61 additions and 27 deletions

View File

@ -71,8 +71,3 @@ export default class MysteryEncounterDialogue {
}
*
*/
export const allMysteryEncounterDialogue: { [encounterType: number]: MysteryEncounterDialogue } = {};
export function initMysteryEncounterDialogue() {
}

View File

@ -7,7 +7,6 @@ import MysteryEncounterIntroVisuals, { MysteryEncounterSpriteConfig } from "../.
import * as Utils from "../../utils";
import { StatusEffect } from "../status-effect";
import MysteryEncounterDialogue, {
allMysteryEncounterDialogue,
OptionTextDisplay
} from "./mystery-encounter-dialogue";
import MysteryEncounterOption, { MysteryEncounterOptionBuilder, OptionPhaseCallback } from "./mystery-encounter-option";
@ -137,17 +136,12 @@ export default class MysteryEncounter implements MysteryEncounter {
Object.assign(this, encounter);
}
this.encounterTier = this.encounterTier ? this.encounterTier : MysteryEncounterTier.COMMON;
this.dialogue = Object.assign((this.dialogue ?? {}), allMysteryEncounterDialogue[this.encounterType] ?? {});
this.dialogue = {};
this.encounterVariant = MysteryEncounterVariant.DEFAULT;
this.requirements = this.requirements ? this.requirements : [];
this.hideBattleIntroMessage = !isNullOrUndefined(this.hideBattleIntroMessage) ? this.hideBattleIntroMessage : false;
this.hideIntroVisuals = !isNullOrUndefined(this.hideIntroVisuals) ? this.hideIntroVisuals : true;
// Populate options with respective dialogue
if (this.dialogue?.encounterOptionsDialogue) {
// this.options.forEach((o, i) => o.dialogue = this.dialogue.encounterOptionsDialogue.options[i]);
}
// Reset any dirty flags or encounter data
this.lockEncounterRewardTiers = true;
this.dialogueTokens = new Map<string, [RegExp, string]>;
@ -482,15 +476,37 @@ export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
return this.withSceneRequirement(new PartySizeRequirement([min, max ?? min]));
}
/**
* Add a primary pokemon requirement
*
* @param requirement {@linkcode EncounterPokemonRequirement}
* @returns
*/
withPrimaryPokemonRequirement(requirement: EncounterPokemonRequirement): this & Required<Pick<MysteryEncounter, "primaryPokemonRequirements">> {
this.primaryPokemonRequirements.push(requirement);
return Object.assign(this, { primaryPokemonRequirements: this.primaryPokemonRequirements });
}
/**
* Add a primary pokemon status effect requirement
*
* @param statusEffect the status effect/s to check
* @param minNumberOfPokemon minimum number of pokemon to have the effect
* @param invertQuery if true will invert the query
* @returns
*/
withPrimaryPokemonStatusEffectRequirement(statusEffect: StatusEffect | StatusEffect[], minNumberOfPokemon: number = 1, invertQuery: boolean = false): this & Required<Pick<MysteryEncounter, "primaryPokemonRequirements">> {
return this.withPrimaryPokemonRequirement(new StatusEffectRequirement(statusEffect, minNumberOfPokemon, invertQuery));
}
/**
* Add a primary pokemon health ratio requirement
*
* @param requiredHealthRange the health range to check
* @param minNumberOfPokemon minimum number of pokemon to have the health range
* @param invertQuery if true will invert the query
* @returns
*/
withPrimaryPokemonHealthRatioRequirement(requiredHealthRange: [number, number], minNumberOfPokemon: number = 1, invertQuery: boolean = false): this & Required<Pick<MysteryEncounter, "primaryPokemonRequirements">> {
return this.withPrimaryPokemonRequirement(new HealthRatioRequirement(requiredHealthRange, minNumberOfPokemon, invertQuery));
}
@ -579,12 +595,17 @@ export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
return Object.assign(this, { hideIntroVisuals: hideIntroVisuals });
}
/**
* Add a title for the encounter
*
* @param title - title of the encounter
* @returns
*/
withTitle(title: TemplateStringsArray | `mysteryEncounter:${string}`) {
const dialogue = this.dialogue ?? {};
const encounterOptionsDialogue = this.dialogue?.encounterOptionsDialogue ?? {};
const encounterOptionsDialogue = this.dialogue.encounterOptionsDialogue ?? {};
this.dialogue = {
...dialogue,
...this.dialogue,
encounterOptionsDialogue: {
...encounterOptionsDialogue,
title,
@ -594,12 +615,17 @@ export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
return this;
}
/**
* Add a description of the encounter
*
* @param description - description of the encounter
* @returns
*/
withDescription(description: TemplateStringsArray | `mysteryEncounter:${string}`) {
const dialogue = this.dialogue ?? {};
const encounterOptionsDialogue = this.dialogue?.encounterOptionsDialogue ?? {};
const encounterOptionsDialogue = this.dialogue.encounterOptionsDialogue ?? {};
this.dialogue = {
...dialogue,
...this.dialogue,
encounterOptionsDialogue: {
...encounterOptionsDialogue,
description,
@ -609,12 +635,17 @@ export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
return this;
}
/**
* Add a query for the encounter
*
* @param query - query to use for the encounter
* @returns
*/
withQuery(query: TemplateStringsArray | `mysteryEncounter:${string}`) {
const dialogue = this.dialogue ?? {};
const encounterOptionsDialogue = this.dialogue?.encounterOptionsDialogue ?? {};
const encounterOptionsDialogue = this.dialogue.encounterOptionsDialogue ?? {};
this.dialogue = {
...dialogue,
...this.dialogue,
encounterOptionsDialogue: {
...encounterOptionsDialogue,
query,
@ -624,11 +655,23 @@ export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
return this;
}
/**
* Add outro dialogue/s for the encounter
*
* @param dialogue - outro dialogue/s
* @returns
*/
withOutroDialogue(dialogue: MysteryEncounterDialogue["outro"] = []) {
this.dialogue = {...this.dialogue, outro: dialogue };
return this;
}
/**
* Builds the mystery encounter
*
* @param this - MysteryEncounter
* @returns
*/
build(this: MysteryEncounter) {
return new MysteryEncounter(this);
}

View File

@ -22,7 +22,6 @@ import { initStatsKeys } from "./ui/game-stats-ui-handler";
import { initVouchers } from "./system/voucher";
import { Biome } from "#enums/biome";
import { TrainerType } from "#enums/trainer-type";
import {initMysteryEncounterDialogue} from "#app/data/mystery-encounters/mystery-encounter-dialogue";
import {initMysteryEncounters} from "#app/data/mystery-encounters/mystery-encounters";
export class LoadingScene extends SceneBase {
@ -346,7 +345,6 @@ export class LoadingScene extends SceneBase {
initMoves();
initAbilities();
initChallenges();
initMysteryEncounterDialogue();
initMysteryEncounters();
}

View File

@ -117,9 +117,9 @@ export const EGG_GACHA_PULL_COUNT_OVERRIDE: number = 0;
*/
// 1 to 256, set to null to ignore
export const MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = 10000;
export const MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = null;
export const MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier = null;
export const MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = MysteryEncounterType.DARK_DEAL;
export const MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = null;
/**
* MODIFIER / ITEM OVERRIDES

View File

@ -13,7 +13,6 @@ import { initVouchers } from "#app/system/voucher";
import { initAchievements } from "#app/system/achv";
import { initStatsKeys } from "#app/ui/game-stats-ui-handler";
import { initMysteryEncounters } from "#app/data/mystery-encounters/mystery-encounters";
import { initMysteryEncounterDialogue } from "#app/data/mystery-encounters/mystery-encounter-dialogue";
import { beforeAll, beforeEach, vi } from "vitest";
import * as overrides from "#app/overrides";
@ -28,7 +27,6 @@ initSpecies();
initMoves();
initAbilities();
initLoggedInUser();
initMysteryEncounterDialogue();
initMysteryEncounters();
global.testFailed = false;