migrate field-trip encounter

This commit is contained in:
Felix Staud 2024-07-11 13:47:10 -07:00
parent d9e0957d40
commit ce73c38e33
3 changed files with 311 additions and 250 deletions

View File

@ -1,50 +0,0 @@
import MysteryEncounterDialogue from "#app/data/mystery-encounters/mystery-encounter-dialogue";
export const FieldTripDialogue: MysteryEncounterDialogue = {
intro: [
{
text: "mysteryEncounter:field_trip_intro_message"
},
{
text: "mysteryEncounter:field_trip_intro_dialogue",
speaker: "mysteryEncounter:field_trip_speaker"
}
],
encounterOptionsDialogue: {
title: "mysteryEncounter:field_trip_title",
description: "mysteryEncounter:field_trip_description",
query: "mysteryEncounter:field_trip_query",
options: [
{
buttonLabel: "mysteryEncounter:field_trip_option_1_label",
buttonTooltip: "mysteryEncounter:field_trip_option_1_tooltip",
secondOptionPrompt: "mysteryEncounter:field_trip_second_option_prompt",
selected: [
{
text: "mysteryEncounter:field_trip_option_selected"
}
]
},
{
buttonLabel: "mysteryEncounter:field_trip_option_2_label",
buttonTooltip: "mysteryEncounter:field_trip_option_2_tooltip",
secondOptionPrompt: "mysteryEncounter:field_trip_second_option_prompt",
selected: [
{
text: "mysteryEncounter:field_trip_option_selected"
}
]
},
{
buttonLabel: "mysteryEncounter:field_trip_option_3_label",
buttonTooltip: "mysteryEncounter:field_trip_option_3_tooltip",
secondOptionPrompt: "mysteryEncounter:field_trip_second_option_prompt",
selected: [
{
text: "mysteryEncounter:field_trip_option_selected"
}
]
}
]
}
};

View File

@ -1,220 +1,333 @@
import { generateModifierTypeOption, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterExp, setEncounterRewards, } from "#app/data/mystery-encounters/mystery-encounter-utils";
import { MoveCategory } from "#app/data/move";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import {
generateModifierTypeOption,
leaveEncounterWithoutBattle,
selectPokemonForOption,
setEncounterExp,
setEncounterRewards,
} from "#app/data/mystery-encounters/mystery-encounter-utils";
import { TempBattleStat } from "#app/data/temp-battle-stat";
import { PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { modifierTypes } from "#app/modifier/modifier-type";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import BattleScene from "../../../battle-scene";
import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier } from "../mystery-encounter";
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
import { PlayerPokemon, PokemonMove } from "#app/field/pokemon";
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { MoveCategory } from "#app/data/move";
import { TempBattleStat } from "#app/data/temp-battle-stat";
import MysteryEncounter, {
MysteryEncounterBuilder,
MysteryEncounterTier,
} from "../mystery-encounter";
export const FieldTripEncounter: MysteryEncounter = MysteryEncounterBuilder
.withEncounterType(MysteryEncounterType.FIELD_TRIP)
.withEncounterTier(MysteryEncounterTier.COMMON)
.withIntroSpriteConfigs([
{
spriteKey: "preschooler_m",
fileRoot: "trainer",
hasShadow: true
},
{
spriteKey: "teacher",
fileRoot: "mystery-encounters",
hasShadow: true
},
{
spriteKey: "preschooler_f",
fileRoot: "trainer",
hasShadow: true
},
])
.withHideIntroVisuals(false)
.withSceneWaveRangeRequirement(10, 180)
.withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Return the options for Pokemon move valid for this option
return pokemon.moveset.map((move: PokemonMove) => {
const option: OptionSelectItem = {
label: move.getName(),
handler: () => {
// Pokemon and move selected
const correctMove = move.getMove().category === MoveCategory.PHYSICAL;
encounter.setDialogueToken("moveCategory", "Physical");
if (!correctMove) {
encounter.dialogue.encounterOptionsDialogue.options[0].selected = [
{
text: "mysteryEncounter:field_trip_option_incorrect",
speaker: "mysteryEncounter:field_trip_speaker"
},
{
text: "mysteryEncounter:field_trip_lesson_learned",
/** i18n namespace for the encounter */
const namespace = "mysteryEncounter:field_trip";
export const FieldTripEncounter: MysteryEncounter =
MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.FIELD_TRIP)
.withEncounterTier(MysteryEncounterTier.COMMON)
.withSceneWaveRangeRequirement(10, 180)
.withIntroSpriteConfigs([
{
spriteKey: "preschooler_m",
fileRoot: "trainer",
hasShadow: true,
},
{
spriteKey: "teacher",
fileRoot: "mystery-encounters",
hasShadow: true,
},
{
spriteKey: "preschooler_f",
fileRoot: "trainer",
hasShadow: true,
},
])
.withIntroDialogue([
{
text: `${namespace}_intro_message`,
},
{
text: `${namespace}_intro_dialogue`,
speaker: `${namespace}_speaker`,
},
])
.withHideIntroVisuals(false)
.withTitle(`${namespace}_title`)
.withDescription(`${namespace}_description`)
.withQuery(`${namespace}_query`)
.withOption(
new MysteryEncounterOptionBuilder()
.withDialogue({
buttonLabel: `${namespace}_option_1_label`,
buttonTooltip: `${namespace}_option_1_tooltip`,
secondOptionPrompt: `${namespace}_second_option_prompt`,
selected: [
{
text: `${namespace}_option_selected`,
},
],
})
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Return the options for Pokemon move valid for this option
return pokemon.moveset.map((move: PokemonMove) => {
const option: OptionSelectItem = {
label: move.getName(),
handler: () => {
// Pokemon and move selected
const correctMove =
move.getMove().category === MoveCategory.PHYSICAL;
encounter.setDialogueToken("moveCategory", "Physical");
if (!correctMove) {
encounter.options[0].dialogue.selected = [
{
text: `${namespace}_option_incorrect`,
speaker: `${namespace}_speaker`,
},
{
text: `${namespace}_lesson_learned`,
},
];
setEncounterExp(
scene,
scene.getParty().map((p) => p.id),
50
);
} else {
encounter.setDialogueToken("pokeName", pokemon.name);
encounter.setDialogueToken("move", move.getName());
encounter.options[0].dialogue.selected = [
{
text: `${namespace}_option_selected`,
},
];
setEncounterExp(scene, [pokemon.id], 100);
}
];
setEncounterExp(scene, scene.getParty().map(p => p.id), 50);
} else {
encounter.setDialogueToken("pokeName", pokemon.name);
encounter.setDialogueToken("move", move.getName());
encounter.dialogue.encounterOptionsDialogue.options[0].selected = [
{
text: "mysteryEncounter:field_trip_option_selected"
}
];
setEncounterExp(scene, [pokemon.id], 100);
}
encounter.misc = {
correctMove: correctMove
encounter.misc = {
correctMove: correctMove,
};
return true;
},
};
return true;
}
return option;
});
};
return option;
});
};
return selectPokemonForOption(scene, onPokemonSelected);
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
if (encounter.misc.correctMove) {
const modifiers = [
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.ATK]),
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.DEF]),
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.SPD]),
generateModifierTypeOption(scene, modifierTypes.DIRE_HIT)
];
return selectPokemonForOption(scene, onPokemonSelected);
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
if (encounter.misc.correctMove) {
const modifiers = [
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.ATK]
),
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.DEF]
),
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.SPD]
),
generateModifierTypeOption(scene, modifierTypes.DIRE_HIT),
];
setEncounterRewards(scene, { guaranteedModifierTypeOptions: modifiers, fillRemaining: false });
}
setEncounterRewards(scene, {
guaranteedModifierTypeOptions: modifiers,
fillRemaining: false,
});
}
leaveEncounterWithoutBattle(scene, !encounter.misc.correctMove);
})
.build()
)
.withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Return the options for Pokemon move valid for this option
return pokemon.moveset.map((move: PokemonMove) => {
const option: OptionSelectItem = {
label: move.getName(),
handler: () => {
// Pokemon and move selected
const correctMove = move.getMove().category === MoveCategory.SPECIAL;
encounter.setDialogueToken("moveCategory", "Special");
if (!correctMove) {
encounter.dialogue.encounterOptionsDialogue.options[1].selected = [
{
text: "mysteryEncounter:field_trip_option_incorrect",
speaker: "mysteryEncounter:field_trip_speaker"
},
{
text: "mysteryEncounter:field_trip_lesson_learned",
leaveEncounterWithoutBattle(scene, !encounter.misc.correctMove);
})
.build()
)
.withOption(
new MysteryEncounterOptionBuilder()
.withDialogue({
buttonLabel: `${namespace}_option_2_label`,
buttonTooltip: `${namespace}_option_2_tooltip`,
secondOptionPrompt: `${namespace}_second_option_prompt`,
selected: [
{
text: `${namespace}_option_selected`,
},
],
})
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Return the options for Pokemon move valid for this option
return pokemon.moveset.map((move: PokemonMove) => {
const option: OptionSelectItem = {
label: move.getName(),
handler: () => {
// Pokemon and move selected
const correctMove =
move.getMove().category === MoveCategory.SPECIAL;
encounter.setDialogueToken("moveCategory", "Special");
if (!correctMove) {
encounter.options[1].dialogue.selected = [
{
text: `${namespace}_option_incorrect`,
speaker: `${namespace}_speaker`,
},
{
text: `${namespace}_lesson_learned`,
},
];
setEncounterExp(
scene,
scene.getParty().map((p) => p.id),
50
);
} else {
encounter.setDialogueToken("pokeName", pokemon.name);
encounter.setDialogueToken("move", move.getName());
encounter.options[1].dialogue.selected = [
{
text: `${namespace}_option_selected`,
},
];
setEncounterExp(scene, [pokemon.id], 100);
}
];
setEncounterExp(scene, scene.getParty().map(p => p.id), 50);
} else {
encounter.setDialogueToken("pokeName", pokemon.name);
encounter.setDialogueToken("move", move.getName());
encounter.dialogue.encounterOptionsDialogue.options[1].selected = [
{
text: "mysteryEncounter:field_trip_option_selected"
}
];
setEncounterExp(scene, [pokemon.id], 100);
}
encounter.misc = {
correctMove: correctMove
encounter.misc = {
correctMove: correctMove,
};
return true;
},
};
return true;
}
return option;
});
};
return option;
});
};
return selectPokemonForOption(scene, onPokemonSelected);
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
if (encounter.misc.correctMove) {
const modifiers = [
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.SPATK]),
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.SPDEF]),
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.SPD]),
generateModifierTypeOption(scene, modifierTypes.DIRE_HIT)
];
return selectPokemonForOption(scene, onPokemonSelected);
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
if (encounter.misc.correctMove) {
const modifiers = [
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.SPATK]
),
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.SPDEF]
),
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.SPD]
),
generateModifierTypeOption(scene, modifierTypes.DIRE_HIT),
];
setEncounterRewards(scene, { guaranteedModifierTypeOptions: modifiers, fillRemaining: false });
}
setEncounterRewards(scene, {
guaranteedModifierTypeOptions: modifiers,
fillRemaining: false,
});
}
leaveEncounterWithoutBattle(scene, !encounter.misc.correctMove);
})
.build()
)
.withOption(new MysteryEncounterOptionBuilder()
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Return the options for Pokemon move valid for this option
return pokemon.moveset.map((move: PokemonMove) => {
const option: OptionSelectItem = {
label: move.getName(),
handler: () => {
// Pokemon and move selected
const correctMove = move.getMove().category === MoveCategory.STATUS;
encounter.setDialogueToken("moveCategory", "Status");
if (!correctMove) {
encounter.dialogue.encounterOptionsDialogue.options[2].selected = [
{
text: "mysteryEncounter:field_trip_option_incorrect",
speaker: "mysteryEncounter:field_trip_speaker"
},
{
text: "mysteryEncounter:field_trip_lesson_learned",
leaveEncounterWithoutBattle(scene, !encounter.misc.correctMove);
})
.build()
)
.withOption(
new MysteryEncounterOptionBuilder()
.withDialogue({
buttonLabel: `${namespace}_option_3_label`,
buttonTooltip: `${namespace}_option_3_tooltip`,
secondOptionPrompt: `${namespace}_second_option_prompt`,
selected: [
{
text: `${namespace}_option_selected`,
},
],
})
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
const encounter = scene.currentBattle.mysteryEncounter;
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Return the options for Pokemon move valid for this option
return pokemon.moveset.map((move: PokemonMove) => {
const option: OptionSelectItem = {
label: move.getName(),
handler: () => {
// Pokemon and move selected
const correctMove =
move.getMove().category === MoveCategory.STATUS;
encounter.setDialogueToken("moveCategory", "Status");
if (!correctMove) {
encounter.options[2].dialogue.selected = [
{
text: `${namespace}_option_incorrect`,
speaker: `${namespace}_speaker`,
},
{
text: `${namespace}_lesson_learned`,
},
];
setEncounterExp(
scene,
scene.getParty().map((p) => p.id),
50
);
} else {
encounter.setDialogueToken("pokeName", pokemon.name);
encounter.setDialogueToken("move", move.getName());
encounter.options[2].dialogue.selected = [
{
text: `${namespace}_option_selected`,
},
];
setEncounterExp(scene, [pokemon.id], 100);
}
];
setEncounterExp(scene, scene.getParty().map(p => p.id), 50);
} else {
encounter.setDialogueToken("pokeName", pokemon.name);
encounter.setDialogueToken("move", move.getName());
encounter.dialogue.encounterOptionsDialogue.options[2].selected = [
{
text: "mysteryEncounter:field_trip_option_selected"
}
];
setEncounterExp(scene, [pokemon.id], 100);
}
encounter.misc = {
correctMove: correctMove
encounter.misc = {
correctMove: correctMove,
};
return true;
},
};
return true;
}
return option;
});
};
return option;
});
};
return selectPokemonForOption(scene, onPokemonSelected);
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
if (encounter.misc.correctMove) {
const modifiers = [
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.ACC]),
generateModifierTypeOption(scene, modifierTypes.TEMP_STAT_BOOSTER, [TempBattleStat.SPD]),
generateModifierTypeOption(scene, modifierTypes.GREAT_BALL),
generateModifierTypeOption(scene, modifierTypes.IV_SCANNER)
];
return selectPokemonForOption(scene, onPokemonSelected);
})
.withOptionPhase(async (scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter;
if (encounter.misc.correctMove) {
const modifiers = [
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.ACC]
),
generateModifierTypeOption(
scene,
modifierTypes.TEMP_STAT_BOOSTER,
[TempBattleStat.SPD]
),
generateModifierTypeOption(scene, modifierTypes.GREAT_BALL),
generateModifierTypeOption(scene, modifierTypes.IV_SCANNER),
];
setEncounterRewards(scene, { guaranteedModifierTypeOptions: modifiers, fillRemaining: false });
}
setEncounterRewards(scene, {
guaranteedModifierTypeOptions: modifiers,
fillRemaining: false,
});
}
leaveEncounterWithoutBattle(scene, !encounter.misc.correctMove);
})
.build()
)
.build();
leaveEncounterWithoutBattle(scene, !encounter.misc.correctMove);
})
.build()
)
.build();

View File

@ -6,7 +6,6 @@ import { TrainingSessionDialogue } from "#app/data/mystery-encounters/dialogue/t
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 { FieldTripDialogue } from "#app/data/mystery-encounters/dialogue/field-trip-dialogue";
export class TextDisplay {
speaker?: TemplateStringsArray | `mysteryEncounter:${string}`;
@ -89,5 +88,4 @@ export function initMysteryEncounterDialogue() {
allMysteryEncounterDialogue[MysteryEncounterType.TRAINING_SESSION] = TrainingSessionDialogue;
allMysteryEncounterDialogue[MysteryEncounterType.SLEEPING_SNORLAX] = SleepingSnorlaxDialogue;
allMysteryEncounterDialogue[MysteryEncounterType.SHADY_VITAMIN_DEALER] = ShadyVitaminDealerDialogue;
allMysteryEncounterDialogue[MysteryEncounterType.FIELD_TRIP] = FieldTripDialogue;
}