migrate shady-vitamin-dealer encounter

This commit is contained in:
Felix Staud 2024-07-11 14:39:18 -07:00
parent 71a047a1f6
commit 19d96ed381
4 changed files with 273 additions and 221 deletions

View File

@ -2646,7 +2646,7 @@ export default class BattleScene extends SceneBase {
if (encounter) { if (encounter) {
encounter = new MysteryEncounter(encounter); encounter = new MysteryEncounter(encounter);
encounter.meetsRequirements(this); encounter.populateDialogueTokensFromRequirements(this);
return encounter; return encounter;
} }
@ -2674,7 +2674,7 @@ export default class BattleScene extends SceneBase {
tier = Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE; tier = Overrides.MYSTERY_ENCOUNTER_TIER_OVERRIDE;
} }
let availableEncounters = []; let availableEncounters: MysteryEncounter[] = [];
// New encounter will never be the same as the most recent encounter // New encounter will never be the same as the most recent encounter
const previousEncounter = this.mysteryEncounterData.encounteredEvents?.length > 0 ? this.mysteryEncounterData.encounteredEvents[this.mysteryEncounterData.encounteredEvents.length - 1][0] : null; const previousEncounter = this.mysteryEncounterData.encounteredEvents?.length > 0 ? this.mysteryEncounterData.encounteredEvents[this.mysteryEncounterData.encounteredEvents.length - 1][0] : null;
const biomeMysteryEncounters = mysteryEncountersByBiome.get(this.arena.biomeType); const biomeMysteryEncounters = mysteryEncountersByBiome.get(this.arena.biomeType);

View File

@ -1,42 +0,0 @@
import MysteryEncounterDialogue from "#app/data/mystery-encounters/mystery-encounter-dialogue";
export const ShadyVitaminDealerDialogue: MysteryEncounterDialogue = {
intro: [
{
text: "mysteryEncounter:shady_vitamin_dealer_intro_message"
},
{
text: "mysteryEncounter:shady_vitamin_dealer_intro_dialogue",
speaker: "mysteryEncounter:shady_vitamin_dealer_speaker"
}
],
encounterOptionsDialogue: {
title: "mysteryEncounter:shady_vitamin_dealer_title",
description: "mysteryEncounter:shady_vitamin_dealer_description",
query: "mysteryEncounter:shady_vitamin_dealer_query",
options: [
{
buttonLabel: "mysteryEncounter:shady_vitamin_dealer_option_1_label",
buttonTooltip: "mysteryEncounter:shady_vitamin_dealer_option_1_tooltip",
selected: [
{
text: "mysteryEncounter:shady_vitamin_dealer_option_selected"
}
]
},
{
buttonLabel: "mysteryEncounter:shady_vitamin_dealer_option_2_label",
buttonTooltip: "mysteryEncounter:shady_vitamin_dealer_option_2_tooltip",
selected: [
{
text: "mysteryEncounter:shady_vitamin_dealer_option_selected"
}
]
},
{
buttonLabel: "mysteryEncounter:shady_vitamin_dealer_option_3_label",
buttonTooltip: "mysteryEncounter:shady_vitamin_dealer_option_3_tooltip"
}
]
}
};

View File

@ -2,7 +2,8 @@ import {
generateModifierTypeOption, generateModifierTypeOption,
leaveEncounterWithoutBattle, leaveEncounterWithoutBattle,
queueEncounterMessage, queueEncounterMessage,
selectPokemonForOption, setEncounterExp, selectPokemonForOption,
setEncounterExp,
updatePlayerMoney, updatePlayerMoney,
} from "#app/data/mystery-encounters/mystery-encounter-utils"; } from "#app/data/mystery-encounters/mystery-encounter-utils";
import { StatusEffect } from "#app/data/status-effect"; import { StatusEffect } from "#app/data/status-effect";
@ -11,17 +12,23 @@ import { modifierTypes } from "#app/modifier/modifier-type";
import { randSeedInt } from "#app/utils"; import { randSeedInt } from "#app/utils";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import {
MoneyRequirement
} from "../mystery-encounter-requirements";
import i18next from "i18next"; import i18next from "i18next";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, {
MysteryEncounterBuilder,
MysteryEncounterTier,
} from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
import { MoneyRequirement } from "../mystery-encounter-requirements";
export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBuilder export const ShadyVitaminDealerEncounter: MysteryEncounter =
.withEncounterType(MysteryEncounterType.SHADY_VITAMIN_DEALER) MysteryEncounterBuilder.withEncounterType(
MysteryEncounterType.SHADY_VITAMIN_DEALER
)
.withEncounterTier(MysteryEncounterTier.COMMON) .withEncounterTier(MysteryEncounterTier.COMMON)
.withSceneWaveRangeRequirement(10, 180)
.withPrimaryPokemonStatusEffectRequirement([StatusEffect.NONE]) // Pokemon must not have status
.withPrimaryPokemonHealthRatioRequirement([0.34, 1]) // Pokemon must have above 1/3rd HP
.withIntroSpriteConfigs([ .withIntroSpriteConfigs([
{ {
spriteKey: Species.KROOKODILE.toString(), spriteKey: Species.KROOKODILE.toString(),
@ -29,51 +36,87 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBui
hasShadow: true, hasShadow: true,
repeat: true, repeat: true,
x: 10, x: 10,
y: -1 y: -1,
}, },
{ {
spriteKey: "b2w2_veteran_m", spriteKey: "b2w2_veteran_m",
fileRoot: "mystery-encounters", fileRoot: "mystery-encounters",
hasShadow: true, hasShadow: true,
x: -10, x: -10,
y: 2 y: 2,
} },
]) ])
.withSceneWaveRangeRequirement(10, 180) .withIntroDialogue([
.withPrimaryPokemonStatusEffectRequirement([StatusEffect.NONE]) // Pokemon must not have status {
.withPrimaryPokemonHealthRatioRequirement([0.34, 1]) // Pokemon must have above 1/3rd HP text: "mysteryEncounter:shady_vitamin_dealer_intro_message",
.withOption(new MysteryEncounterOptionBuilder() },
{
text: "mysteryEncounter:shady_vitamin_dealer_intro_dialogue",
speaker: "mysteryEncounter:shady_vitamin_dealer_speaker",
},
])
.withTitle("mysteryEncounter:shady_vitamin_dealer_title")
.withDescription("mysteryEncounter:shady_vitamin_dealer_description")
.withQuery("mysteryEncounter:shady_vitamin_dealer_query")
.withOption(
new MysteryEncounterOptionBuilder()
.withSceneMoneyRequirement(0, 2) // Wave scaling money multiplier of 2 .withSceneMoneyRequirement(0, 2) // Wave scaling money multiplier of 2
.withDialogue({
buttonLabel: "mysteryEncounter:shady_vitamin_dealer_option_1_label",
buttonTooltip:
"mysteryEncounter:shady_vitamin_dealer_option_1_tooltip",
selected: [
{
text: "mysteryEncounter:shady_vitamin_dealer_option_selected",
},
],
})
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => { .withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter; const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => { const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Update money // Update money
updatePlayerMoney(scene, -(encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney); updatePlayerMoney(
scene,
-(encounter.options[0].requirements[0] as MoneyRequirement)
.requiredMoney
);
// Calculate modifiers and dialogue tokens // Calculate modifiers and dialogue tokens
const modifiers = [ const modifiers = [
generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER).type, generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER)
generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER).type .type,
generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER)
.type,
]; ];
encounter.setDialogueToken("boost1", modifiers[0].name); encounter.setDialogueToken("boost1", modifiers[0].name);
encounter.setDialogueToken("boost2", modifiers[1].name); encounter.setDialogueToken("boost2", modifiers[1].name);
encounter.misc = { encounter.misc = {
chosenPokemon: pokemon, chosenPokemon: pokemon,
modifiers: modifiers modifiers: modifiers,
}; };
}; };
// Only Pokemon that can gain benefits are above 1/3rd HP with no status // Only Pokemon that can gain benefits are above 1/3rd HP with no status
const selectableFilter = (pokemon: Pokemon) => { const selectableFilter = (pokemon: Pokemon) => {
// If pokemon meets primary pokemon reqs, it can be selected // If pokemon meets primary pokemon reqs, it can be selected
const meetsReqs = encounter.pokemonMeetsPrimaryRequirements(scene, pokemon); const meetsReqs = encounter.pokemonMeetsPrimaryRequirements(
scene,
pokemon
);
if (!meetsReqs) { if (!meetsReqs) {
return i18next.t("mysteryEncounter:shady_vitamin_dealer_invalid_selection"); return i18next.t(
"mysteryEncounter:shady_vitamin_dealer_invalid_selection"
);
} }
return null; return null;
}; };
return selectPokemonForOption(scene, onPokemonSelected, null, selectableFilter); return selectPokemonForOption(
scene,
onPokemonSelected,
null,
selectableFilter
);
}) })
.withOptionPhase(async (scene: BattleScene) => { .withOptionPhase(async (scene: BattleScene) => {
// Choose Cheap Option // Choose Cheap Option
@ -102,52 +145,89 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBui
if (randSeedInt(10) < 8) { if (randSeedInt(10) < 8) {
if (chosenPokemon.trySetStatus(StatusEffect.TOXIC)) { if (chosenPokemon.trySetStatus(StatusEffect.TOXIC)) {
// Toxic applied // Toxic applied
queueEncounterMessage(scene, "mysteryEncounter:shady_vitamin_dealer_bad_poison"); queueEncounterMessage(
scene,
"mysteryEncounter:shady_vitamin_dealer_bad_poison"
);
} else { } else {
// Pokemon immune or something else prevents status // Pokemon immune or something else prevents status
queueEncounterMessage(scene, "mysteryEncounter:shady_vitamin_dealer_damage_only"); queueEncounterMessage(
scene,
"mysteryEncounter:shady_vitamin_dealer_damage_only"
);
} }
} else { } else {
queueEncounterMessage(scene, "mysteryEncounter:shady_vitamin_dealer_damage_only"); queueEncounterMessage(
scene,
"mysteryEncounter:shady_vitamin_dealer_damage_only"
);
} }
setEncounterExp(scene, [chosenPokemon.id], 100); setEncounterExp(scene, [chosenPokemon.id], 100);
chosenPokemon.updateInfo(); chosenPokemon.updateInfo();
}) })
.build()) .build()
.withOption(new MysteryEncounterOptionBuilder() )
.withOption(
new MysteryEncounterOptionBuilder()
.withDialogue({
buttonLabel: "mysteryEncounter:shady_vitamin_dealer_option_2_label",
buttonTooltip:
"mysteryEncounter:shady_vitamin_dealer_option_2_tooltip",
selected: [
{
text: "mysteryEncounter:shady_vitamin_dealer_option_selected",
},
],
})
.withSceneMoneyRequirement(0, 5) // Wave scaling money multiplier of 5 .withSceneMoneyRequirement(0, 5) // Wave scaling money multiplier of 5
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => { .withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter; const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => { const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Update money // Update money
updatePlayerMoney(scene, -(encounter.options[1].requirements[0] as MoneyRequirement).requiredMoney); updatePlayerMoney(
scene,
-(encounter.options[1].requirements[0] as MoneyRequirement)
.requiredMoney
);
// Calculate modifiers and dialogue tokens // Calculate modifiers and dialogue tokens
const modifiers = [ const modifiers = [
generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER).type, generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER)
generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER).type .type,
generateModifierTypeOption(scene, modifierTypes.BASE_STAT_BOOSTER)
.type,
]; ];
encounter.setDialogueToken("boost1", modifiers[0].name); encounter.setDialogueToken("boost1", modifiers[0].name);
encounter.setDialogueToken("boost2", modifiers[1].name); encounter.setDialogueToken("boost2", modifiers[1].name);
encounter.misc = { encounter.misc = {
chosenPokemon: pokemon, chosenPokemon: pokemon,
modifiers: modifiers modifiers: modifiers,
}; };
}; };
// Only Pokemon that can gain benefits are above 1/3rd HP with no status // Only Pokemon that can gain benefits are above 1/3rd HP with no status
const selectableFilter = (pokemon: Pokemon) => { const selectableFilter = (pokemon: Pokemon) => {
// If pokemon meets primary pokemon reqs, it can be selected // If pokemon meets primary pokemon reqs, it can be selected
const meetsReqs = encounter.pokemonMeetsPrimaryRequirements(scene, pokemon); const meetsReqs = encounter.pokemonMeetsPrimaryRequirements(
scene,
pokemon
);
if (!meetsReqs) { if (!meetsReqs) {
return i18next.t("mysteryEncounter:shady_vitamin_dealer_invalid_selection"); return i18next.t(
"mysteryEncounter:shady_vitamin_dealer_invalid_selection"
);
} }
return null; return null;
}; };
return selectPokemonForOption(scene, onPokemonSelected, null, selectableFilter); return selectPokemonForOption(
scene,
onPokemonSelected,
null,
selectableFilter
);
}) })
.withOptionPhase(async (scene: BattleScene) => { .withOptionPhase(async (scene: BattleScene) => {
// Choose Expensive Option // Choose Expensive Option
@ -172,23 +252,39 @@ export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBui
if (randSeedInt(10) < 2) { if (randSeedInt(10) < 2) {
if (chosenPokemon.trySetStatus(StatusEffect.POISON)) { if (chosenPokemon.trySetStatus(StatusEffect.POISON)) {
// Poison applied // Poison applied
queueEncounterMessage(scene, "mysteryEncounter:shady_vitamin_dealer_poison"); queueEncounterMessage(
scene,
"mysteryEncounter:shady_vitamin_dealer_poison"
);
} else { } else {
// Pokemon immune or something else prevents status // Pokemon immune or something else prevents status
queueEncounterMessage(scene, "mysteryEncounter:shady_vitamin_dealer_no_bad_effects"); queueEncounterMessage(
scene,
"mysteryEncounter:shady_vitamin_dealer_no_bad_effects"
);
} }
} else { } else {
queueEncounterMessage(scene, "mysteryEncounter:shady_vitamin_dealer_no_bad_effects"); queueEncounterMessage(
scene,
"mysteryEncounter:shady_vitamin_dealer_no_bad_effects"
);
} }
setEncounterExp(scene, [chosenPokemon.id], 100); setEncounterExp(scene, [chosenPokemon.id], 100);
chosenPokemon.updateInfo(); chosenPokemon.updateInfo();
}) })
.build()) .build()
.withSimpleOption(async (scene: BattleScene) => { )
.withSimpleOption(
{
buttonLabel: "mysteryEncounter:shady_vitamin_dealer_option_3_label",
buttonTooltip: "mysteryEncounter:shady_vitamin_dealer_option_3_tooltip",
},
async (scene: BattleScene) => {
// Leave encounter with no rewards or exp // Leave encounter with no rewards or exp
leaveEncounterWithoutBattle(scene, true); leaveEncounterWithoutBattle(scene, true);
return true; return true;
}) }
)
.build(); .build();

View File

@ -1,7 +1,6 @@
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { TrainingSessionDialogue } from "#app/data/mystery-encounters/dialogue/training-session-dialogue"; import { TrainingSessionDialogue } from "#app/data/mystery-encounters/dialogue/training-session-dialogue";
import { SleepingSnorlaxDialogue } from "./dialogue/sleeping-snorlax-dialogue"; import { SleepingSnorlaxDialogue } from "./dialogue/sleeping-snorlax-dialogue";
import { ShadyVitaminDealerDialogue } from "#app/data/mystery-encounters/dialogue/shady-vitamin-dealer";
import { TextStyle } from "#app/ui/text"; import { TextStyle } from "#app/ui/text";
export class TextDisplay { export class TextDisplay {
@ -81,5 +80,4 @@ export const allMysteryEncounterDialogue: { [encounterType: number]: MysteryEnco
export function initMysteryEncounterDialogue() { export function initMysteryEncounterDialogue() {
allMysteryEncounterDialogue[MysteryEncounterType.TRAINING_SESSION] = TrainingSessionDialogue; allMysteryEncounterDialogue[MysteryEncounterType.TRAINING_SESSION] = TrainingSessionDialogue;
allMysteryEncounterDialogue[MysteryEncounterType.SLEEPING_SNORLAX] = SleepingSnorlaxDialogue; allMysteryEncounterDialogue[MysteryEncounterType.SLEEPING_SNORLAX] = SleepingSnorlaxDialogue;
allMysteryEncounterDialogue[MysteryEncounterType.SHADY_VITAMIN_DEALER] = ShadyVitaminDealerDialogue;
} }