migrate mysterious-chest encounter

This commit is contained in:
Felix Staud 2024-07-11 14:10:21 -07:00
parent e6bf12ab8c
commit 71a047a1f6
3 changed files with 153 additions and 114 deletions

View File

@ -1,34 +0,0 @@
import MysteryEncounterDialogue from "#app/data/mystery-encounters/mystery-encounter-dialogue";
export const MysteriousChestDialogue: MysteryEncounterDialogue = {
intro: [
{
text: "mysteryEncounter:mysterious_chest_intro_message"
}
],
encounterOptionsDialogue: {
title: "mysteryEncounter:mysterious_chest_title",
description: "mysteryEncounter:mysterious_chest_description",
query: "mysteryEncounter:mysterious_chest_query",
options: [
{
buttonLabel: "mysteryEncounter:mysterious_chest_option_1_label",
buttonTooltip: "mysteryEncounter:mysterious_chest_option_1_tooltip",
selected: [
{
text: "mysteryEncounter:mysterious_chest_option_1_selected_message"
}
]
},
{
buttonLabel: "mysteryEncounter:mysterious_chest_option_2_label",
buttonTooltip: "mysteryEncounter:mysterious_chest_option_2_tooltip",
selected: [
{
text: "mysteryEncounter:mysterious_chest_option_2_selected_message"
}
]
}
]
}
};

View File

@ -4,90 +4,165 @@ import {
leaveEncounterWithoutBattle, leaveEncounterWithoutBattle,
queueEncounterMessage, queueEncounterMessage,
setEncounterRewards, setEncounterRewards,
showEncounterText showEncounterText,
} from "#app/data/mystery-encounters/mystery-encounter-utils"; } from "#app/data/mystery-encounters/mystery-encounter-utils";
import { ModifierTier } from "#app/modifier/modifier-tier"; import { ModifierTier } from "#app/modifier/modifier-tier";
import { GameOverPhase } from "#app/phases"; import { GameOverPhase } from "#app/phases";
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 BattleScene from "../../../battle-scene"; import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter"; import MysteryEncounter, {
MysteryEncounterBuilder,
MysteryEncounterTier,
} from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option";
export const MysteriousChestEncounter: MysteryEncounter = MysteryEncounterBuilder export const MysteriousChestEncounter: MysteryEncounter =
.withEncounterType(MysteryEncounterType.MYSTERIOUS_CHEST) MysteryEncounterBuilder.withEncounterType(
.withEncounterTier(MysteryEncounterTier.COMMON) MysteryEncounterType.MYSTERIOUS_CHEST
.withIntroSpriteConfigs([
{
spriteKey: "chest_blue",
fileRoot: "mystery-encounters",
hasShadow: true,
x: 4,
y: 8,
disableAnimation: true // Re-enabled after option select
}
])
.withHideIntroVisuals(false)
.withSceneWaveRangeRequirement(10, 180) // waves 2 to 180
.withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene) => {
// Play animation
const introVisuals = scene.currentBattle.mysteryEncounter.introVisuals;
introVisuals.spriteConfigs[0].disableAnimation = false;
introVisuals.playAnim();
})
.withOptionPhase(async (scene: BattleScene) => {
// Open the chest
const roll = randSeedInt(100);
if (roll > 60) {
// Choose between 2 COMMON / 2 GREAT tier items (40%)
setEncounterRewards(scene, { guaranteedModifierTiers: [ModifierTier.COMMON, ModifierTier.COMMON, ModifierTier.GREAT, ModifierTier.GREAT] });
// Display result message then proceed to rewards
queueEncounterMessage(scene, "mysteryEncounter:mysterious_chest_option_1_normal_result");
leaveEncounterWithoutBattle(scene);
} else if (roll > 40) {
// Choose between 3 ULTRA tier items (20%)
setEncounterRewards(scene, { guaranteedModifierTiers: [ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA] });
// Display result message then proceed to rewards
queueEncounterMessage(scene, "mysteryEncounter:mysterious_chest_option_1_good_result");
leaveEncounterWithoutBattle(scene);
} else if (roll > 36) {
// Choose between 2 ROGUE tier items (4%)
setEncounterRewards(scene, { guaranteedModifierTiers: [ModifierTier.ROGUE, ModifierTier.ROGUE] });
// Display result message then proceed to rewards
queueEncounterMessage(scene, "mysteryEncounter:mysterious_chest_option_1_great_result");
leaveEncounterWithoutBattle(scene);
} else if (roll > 35) {
// Choose 1 MASTER tier item (1%)
setEncounterRewards(scene, { guaranteedModifierTiers: [ModifierTier.MASTER] });
// Display result message then proceed to rewards
queueEncounterMessage(scene, "mysteryEncounter:mysterious_chest_option_1_amazing_result");
leaveEncounterWithoutBattle(scene);
} else {
// Your highest level unfainted Pok<6F>mon gets OHKO. Progress with no rewards (35%)
const highestLevelPokemon = getHighestLevelPlayerPokemon(scene, true);
koPlayerPokemon(highestLevelPokemon);
scene.currentBattle.mysteryEncounter.setDialogueToken("pokeName", highestLevelPokemon.name);
// Show which Pokemon was KOed, then leave encounter with no rewards
// Does this synchronously so that game over doesn't happen over result message
await showEncounterText(scene, "mysteryEncounter:mysterious_chest_option_1_bad_result")
.then(() => {
if (scene.getParty().filter(p => p.isAllowedInBattle()).length === 0) {
// All pokemon fainted, game over
scene.clearPhaseQueue();
scene.unshiftPhase(new GameOverPhase(scene));
} else {
leaveEncounterWithoutBattle(scene);
}
});
}
})
.build()
) )
.withSimpleOption(async (scene: BattleScene) => { .withEncounterTier(MysteryEncounterTier.COMMON)
// Leave encounter with no rewards or exp .withSceneWaveRangeRequirement(10, 180) // waves 2 to 180
leaveEncounterWithoutBattle(scene, true); .withHideIntroVisuals(false)
return true; .withIntroSpriteConfigs([
}) {
.build(); spriteKey: "chest_blue",
fileRoot: "mystery-encounters",
hasShadow: true,
x: 4,
y: 8,
disableAnimation: true, // Re-enabled after option select
},
])
.withIntroDialogue([
{
text: "mysteryEncounter:mysterious_chest_intro_message",
},
])
.withTitle("mysteryEncounter:mysterious_chest_title")
.withDescription("mysteryEncounter:mysterious_chest_description")
.withQuery("mysteryEncounter:mysterious_chest_query")
.withOption(
new MysteryEncounterOptionBuilder()
.withDialogue({
buttonLabel: "mysteryEncounter:mysterious_chest_option_1_label",
buttonTooltip: "mysteryEncounter:mysterious_chest_option_1_tooltip",
selected: [
{
text: "mysteryEncounter:mysterious_chest_option_1_selected_message",
},
],
})
.withPreOptionPhase(async (scene: BattleScene) => {
// Play animation
const introVisuals =
scene.currentBattle.mysteryEncounter.introVisuals;
introVisuals.spriteConfigs[0].disableAnimation = false;
introVisuals.playAnim();
})
.withOptionPhase(async (scene: BattleScene) => {
// Open the chest
const roll = randSeedInt(100);
if (roll > 60) {
// Choose between 2 COMMON / 2 GREAT tier items (40%)
setEncounterRewards(scene, {
guaranteedModifierTiers: [
ModifierTier.COMMON,
ModifierTier.COMMON,
ModifierTier.GREAT,
ModifierTier.GREAT,
],
});
// Display result message then proceed to rewards
queueEncounterMessage(
scene,
"mysteryEncounter:mysterious_chest_option_1_normal_result"
);
leaveEncounterWithoutBattle(scene);
} else if (roll > 40) {
// Choose between 3 ULTRA tier items (20%)
setEncounterRewards(scene, {
guaranteedModifierTiers: [
ModifierTier.ULTRA,
ModifierTier.ULTRA,
ModifierTier.ULTRA,
],
});
// Display result message then proceed to rewards
queueEncounterMessage(
scene,
"mysteryEncounter:mysterious_chest_option_1_good_result"
);
leaveEncounterWithoutBattle(scene);
} else if (roll > 36) {
// Choose between 2 ROGUE tier items (4%)
setEncounterRewards(scene, {
guaranteedModifierTiers: [ModifierTier.ROGUE, ModifierTier.ROGUE],
});
// Display result message then proceed to rewards
queueEncounterMessage(
scene,
"mysteryEncounter:mysterious_chest_option_1_great_result"
);
leaveEncounterWithoutBattle(scene);
} else if (roll > 35) {
// Choose 1 MASTER tier item (1%)
setEncounterRewards(scene, {
guaranteedModifierTiers: [ModifierTier.MASTER],
});
// Display result message then proceed to rewards
queueEncounterMessage(
scene,
"mysteryEncounter:mysterious_chest_option_1_amazing_result"
);
leaveEncounterWithoutBattle(scene);
} else {
// Your highest level unfainted Pok<6F>mon gets OHKO. Progress with no rewards (35%)
const highestLevelPokemon = getHighestLevelPlayerPokemon(
scene,
true
);
koPlayerPokemon(highestLevelPokemon);
scene.currentBattle.mysteryEncounter.setDialogueToken(
"pokeName",
highestLevelPokemon.name
);
// Show which Pokemon was KOed, then leave encounter with no rewards
// Does this synchronously so that game over doesn't happen over result message
await showEncounterText(
scene,
"mysteryEncounter:mysterious_chest_option_1_bad_result"
).then(() => {
if (
scene.getParty().filter((p) => p.isAllowedInBattle()).length ===
0
) {
// All pokemon fainted, game over
scene.clearPhaseQueue();
scene.unshiftPhase(new GameOverPhase(scene));
} else {
leaveEncounterWithoutBattle(scene);
}
});
}
})
.build()
)
.withSimpleOption(
{
buttonLabel: "mysteryEncounter:mysterious_chest_option_2_label",
buttonTooltip: "mysteryEncounter:mysterious_chest_option_2_tooltip",
selected: [
{
text: "mysteryEncounter:mysterious_chest_option_2_selected_message",
},
],
},
async (scene: BattleScene) => {
// Leave encounter with no rewards or exp
leaveEncounterWithoutBattle(scene, true);
return true;
}
)
.build();

View File

@ -1,5 +1,4 @@
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { MysteriousChestDialogue } from "#app/data/mystery-encounters/dialogue/mysterious-chest-dialogue";
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 { ShadyVitaminDealerDialogue } from "#app/data/mystery-encounters/dialogue/shady-vitamin-dealer";
@ -80,7 +79,6 @@ export default class MysteryEncounterDialogue {
export const allMysteryEncounterDialogue: { [encounterType: number]: MysteryEncounterDialogue } = {}; export const allMysteryEncounterDialogue: { [encounterType: number]: MysteryEncounterDialogue } = {};
export function initMysteryEncounterDialogue() { export function initMysteryEncounterDialogue() {
allMysteryEncounterDialogue[MysteryEncounterType.MYSTERIOUS_CHEST] = MysteriousChestDialogue;
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; allMysteryEncounterDialogue[MysteryEncounterType.SHADY_VITAMIN_DEALER] = ShadyVitaminDealerDialogue;