migrate training session encounter
This commit is contained in:
parent
2d42697321
commit
39f98222a6
|
@ -1,50 +0,0 @@
|
|||
import MysteryEncounterDialogue from "#app/data/mystery-encounters/mystery-encounter-dialogue";
|
||||
|
||||
export const TrainingSessionDialogue: MysteryEncounterDialogue = {
|
||||
intro: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_intro_message"
|
||||
}
|
||||
],
|
||||
encounterOptionsDialogue: {
|
||||
title: "mysteryEncounter:training_session_title",
|
||||
description: "mysteryEncounter:training_session_description",
|
||||
query: "mysteryEncounter:training_session_query",
|
||||
options: [
|
||||
{
|
||||
buttonLabel: "mysteryEncounter:training_session_option_1_label",
|
||||
buttonTooltip: "mysteryEncounter:training_session_option_1_tooltip",
|
||||
selected: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_option_selected_message"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
buttonLabel: "mysteryEncounter:training_session_option_2_label",
|
||||
buttonTooltip: "mysteryEncounter:training_session_option_2_tooltip",
|
||||
secondOptionPrompt: "mysteryEncounter:training_session_option_2_select_prompt",
|
||||
selected: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_option_selected_message"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
buttonLabel: "mysteryEncounter:training_session_option_3_label",
|
||||
buttonTooltip: "mysteryEncounter:training_session_option_3_tooltip",
|
||||
secondOptionPrompt: "mysteryEncounter:training_session_option_3_select_prompt",
|
||||
selected: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_option_selected_message"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
outro: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_outro_win"
|
||||
}
|
||||
]
|
||||
};
|
|
@ -4,7 +4,7 @@ import {
|
|||
getEncounterText,
|
||||
initBattleWithEnemyConfig,
|
||||
selectPokemonForOption,
|
||||
setEncounterRewards
|
||||
setEncounterRewards,
|
||||
} from "#app/data/mystery-encounters/mystery-encounter-utils";
|
||||
import { getNatureName, Nature } from "#app/data/nature";
|
||||
import { speciesStarters } from "#app/data/pokemon-species";
|
||||
|
@ -20,28 +20,51 @@ import { randSeedShuffle } from "#app/utils";
|
|||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
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";
|
||||
|
||||
export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilder
|
||||
.withEncounterType(MysteryEncounterType.TRAINING_SESSION)
|
||||
export const TrainingSessionEncounter: MysteryEncounter =
|
||||
MysteryEncounterBuilder.withEncounterType(
|
||||
MysteryEncounterType.TRAINING_SESSION
|
||||
)
|
||||
.withEncounterTier(MysteryEncounterTier.ULTRA)
|
||||
.withSceneWaveRangeRequirement(10, 180) // waves 10 to 180
|
||||
.withHideWildIntroMessage(true)
|
||||
.withIntroSpriteConfigs([
|
||||
{
|
||||
spriteKey: "training_gear",
|
||||
fileRoot: "mystery-encounters",
|
||||
hasShadow: true,
|
||||
y: 3
|
||||
}
|
||||
y: 3,
|
||||
},
|
||||
])
|
||||
.withSceneWaveRangeRequirement(10, 180) // waves 10 to 180
|
||||
.withHideWildIntroMessage(true)
|
||||
.withOption(new MysteryEncounterOptionBuilder()
|
||||
.withIntroDialogue([
|
||||
{
|
||||
text: "mysteryEncounter:training_session_intro_message",
|
||||
},
|
||||
])
|
||||
.withTitle("mysteryEncounter:training_session_title")
|
||||
.withDescription("mysteryEncounter:training_session_description")
|
||||
.withQuery("mysteryEncounter:training_session_query")
|
||||
.withOption(
|
||||
new MysteryEncounterOptionBuilder()
|
||||
.withDialogue({
|
||||
buttonLabel: "mysteryEncounter:training_session_option_1_label",
|
||||
buttonTooltip: "mysteryEncounter:training_session_option_1_tooltip",
|
||||
selected: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_option_selected_message",
|
||||
},
|
||||
],
|
||||
})
|
||||
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
encounter.misc = {
|
||||
playerPokemon: pokemon
|
||||
playerPokemon: pokemon,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -53,9 +76,17 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
|
||||
// Spawn light training session with chosen pokemon
|
||||
// Every 50 waves, add +1 boss segment, capping at 5
|
||||
const segments = Math.min(2 + Math.floor(scene.currentBattle.waveIndex / 50), 5);
|
||||
const segments = Math.min(
|
||||
2 + Math.floor(scene.currentBattle.waveIndex / 50),
|
||||
5
|
||||
);
|
||||
const modifiers = new ModifiersHolder();
|
||||
const config = getEnemyConfig(scene, playerPokemon, segments, modifiers);
|
||||
const config = getEnemyConfig(
|
||||
scene,
|
||||
playerPokemon,
|
||||
segments,
|
||||
modifiers
|
||||
);
|
||||
scene.removePokemonFromPlayerParty(playerPokemon, false);
|
||||
|
||||
const getIvName = (index: number) => {
|
||||
|
@ -99,13 +130,19 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
const ivToChange = ivIndexes.pop();
|
||||
let newVal = ivToChange.iv;
|
||||
if (improvedCount === 0) {
|
||||
encounter.setDialogueToken("stat1", getIvName(ivToChange.index));
|
||||
encounter.setDialogueToken(
|
||||
"stat1",
|
||||
getIvName(ivToChange.index)
|
||||
);
|
||||
} else {
|
||||
encounter.setDialogueToken("stat2", getIvName(ivToChange.index));
|
||||
encounter.setDialogueToken(
|
||||
"stat2",
|
||||
getIvName(ivToChange.index)
|
||||
);
|
||||
}
|
||||
|
||||
// Corrects required encounter breakpoints to be continuous for all IV values
|
||||
if (ivToChange.iv <= 21 && ivToChange.iv - 1 % 5 === 0) {
|
||||
if (ivToChange.iv <= 21 && ivToChange.iv - (1 % 5) === 0) {
|
||||
newVal += 1;
|
||||
}
|
||||
|
||||
|
@ -117,7 +154,10 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
|
||||
if (improvedCount > 0) {
|
||||
playerPokemon.calculateStats();
|
||||
scene.gameData.updateSpeciesDexIvs(playerPokemon.species.getRootSpeciesId(true), playerPokemon.ivs);
|
||||
scene.gameData.updateSpeciesDexIvs(
|
||||
playerPokemon.species.getRootSpeciesId(true),
|
||||
playerPokemon.ivs
|
||||
);
|
||||
scene.gameData.setPokemonCaught(playerPokemon, false);
|
||||
}
|
||||
|
||||
|
@ -127,16 +167,40 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
scene.addModifier(mod, true, false, false, true);
|
||||
}
|
||||
scene.updateModifiers(true);
|
||||
scene.queueMessage(getEncounterText(scene, "mysteryEncounter:training_session_battle_finished_1"), null, true);
|
||||
scene.queueMessage(
|
||||
getEncounterText(
|
||||
scene,
|
||||
"mysteryEncounter:training_session_battle_finished_1"
|
||||
),
|
||||
null,
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
setEncounterRewards(scene, { fillRemaining: true }, null, onBeforeRewardsPhase);
|
||||
setEncounterRewards(
|
||||
scene,
|
||||
{ fillRemaining: true },
|
||||
null,
|
||||
onBeforeRewardsPhase
|
||||
);
|
||||
|
||||
return initBattleWithEnemyConfig(scene, config);
|
||||
})
|
||||
.build()
|
||||
)
|
||||
.withOption(new MysteryEncounterOptionBuilder()
|
||||
.withOption(
|
||||
new MysteryEncounterOptionBuilder()
|
||||
.withDialogue({
|
||||
buttonLabel: "mysteryEncounter:training_session_option_2_label",
|
||||
buttonTooltip: "mysteryEncounter:training_session_option_2_tooltip",
|
||||
secondOptionPrompt:
|
||||
"mysteryEncounter:training_session_option_2_select_prompt",
|
||||
selected: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_option_selected_message",
|
||||
},
|
||||
],
|
||||
})
|
||||
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
|
||||
// Open menu for selecting pokemon and Nature
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
|
@ -151,10 +215,10 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
encounter.setDialogueToken("nature", getNatureName(nature));
|
||||
encounter.misc = {
|
||||
playerPokemon: pokemon,
|
||||
chosenNature: nature
|
||||
chosenNature: nature,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
return option;
|
||||
});
|
||||
|
@ -168,13 +232,28 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
|
||||
// Spawn medium training session with chosen pokemon
|
||||
// Every 40 waves, add +1 boss segment, capping at 6
|
||||
const segments = Math.min(2 + Math.floor(scene.currentBattle.waveIndex / 40), 6);
|
||||
const segments = Math.min(
|
||||
2 + Math.floor(scene.currentBattle.waveIndex / 40),
|
||||
6
|
||||
);
|
||||
const modifiers = new ModifiersHolder();
|
||||
const config = getEnemyConfig(scene, playerPokemon, segments, modifiers);
|
||||
const config = getEnemyConfig(
|
||||
scene,
|
||||
playerPokemon,
|
||||
segments,
|
||||
modifiers
|
||||
);
|
||||
scene.removePokemonFromPlayerParty(playerPokemon, false);
|
||||
|
||||
const onBeforeRewardsPhase = () => {
|
||||
scene.queueMessage(getEncounterText(scene, "mysteryEncounter:training_session_battle_finished_2"), null, true);
|
||||
scene.queueMessage(
|
||||
getEncounterText(
|
||||
scene,
|
||||
"mysteryEncounter:training_session_battle_finished_2"
|
||||
),
|
||||
null,
|
||||
true
|
||||
);
|
||||
// Add the pokemon back to party with Nature change
|
||||
playerPokemon.setNature(encounter.misc.chosenNature);
|
||||
scene.gameData.setPokemonCaught(playerPokemon, false);
|
||||
|
@ -187,21 +266,42 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
scene.updateModifiers(true);
|
||||
};
|
||||
|
||||
setEncounterRewards(scene, { fillRemaining: true }, null, onBeforeRewardsPhase);
|
||||
setEncounterRewards(
|
||||
scene,
|
||||
{ fillRemaining: true },
|
||||
null,
|
||||
onBeforeRewardsPhase
|
||||
);
|
||||
|
||||
return initBattleWithEnemyConfig(scene, config);
|
||||
})
|
||||
.build()
|
||||
)
|
||||
.withOption(new MysteryEncounterOptionBuilder()
|
||||
.withOption(
|
||||
new MysteryEncounterOptionBuilder()
|
||||
.withDialogue({
|
||||
buttonLabel: "mysteryEncounter:training_session_option_3_label",
|
||||
buttonTooltip: "mysteryEncounter:training_session_option_3_tooltip",
|
||||
secondOptionPrompt:
|
||||
"mysteryEncounter:training_session_option_3_select_prompt",
|
||||
selected: [
|
||||
{
|
||||
text: "mysteryEncounter:training_session_option_selected_message",
|
||||
},
|
||||
],
|
||||
})
|
||||
.withPreOptionPhase(async (scene: BattleScene): Promise<boolean> => {
|
||||
// Open menu for selecting pokemon and ability to learn
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
// Return the options for ability selection
|
||||
const speciesForm = !!pokemon.getFusionSpeciesForm() ? pokemon.getFusionSpeciesForm() : pokemon.getSpeciesForm();
|
||||
const speciesForm = !!pokemon.getFusionSpeciesForm()
|
||||
? pokemon.getFusionSpeciesForm()
|
||||
: pokemon.getSpeciesForm();
|
||||
const abilityCount = speciesForm.getAbilityCount();
|
||||
const abilities = new Array(abilityCount).fill(null).map((val, i) => allAbilities[speciesForm.getAbility(i)]);
|
||||
const abilities = new Array(abilityCount)
|
||||
.fill(null)
|
||||
.map((val, i) => allAbilities[speciesForm.getAbility(i)]);
|
||||
return abilities.map((ability: Ability, index) => {
|
||||
const option: OptionSelectItem = {
|
||||
label: ability.name,
|
||||
|
@ -210,13 +310,13 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
encounter.setDialogueToken("ability", ability.name);
|
||||
encounter.misc = {
|
||||
playerPokemon: pokemon,
|
||||
abilityIndex: index
|
||||
abilityIndex: index,
|
||||
};
|
||||
return true;
|
||||
},
|
||||
onHover: () => {
|
||||
scene.ui.showText(ability.description);
|
||||
}
|
||||
},
|
||||
};
|
||||
return option;
|
||||
});
|
||||
|
@ -231,27 +331,56 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
// Spawn hard training session with chosen pokemon
|
||||
// Every 30 waves, add +1 boss segment, capping at 6
|
||||
// Also starts with +1 to all stats
|
||||
const segments = Math.min(2 + Math.floor(scene.currentBattle.waveIndex / 30), 6);
|
||||
const segments = Math.min(
|
||||
2 + Math.floor(scene.currentBattle.waveIndex / 30),
|
||||
6
|
||||
);
|
||||
const modifiers = new ModifiersHolder();
|
||||
const config = getEnemyConfig(scene, playerPokemon, segments, modifiers);
|
||||
config.pokemonConfigs[0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON];
|
||||
const config = getEnemyConfig(
|
||||
scene,
|
||||
playerPokemon,
|
||||
segments,
|
||||
modifiers
|
||||
);
|
||||
config.pokemonConfigs[0].tags = [
|
||||
BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON,
|
||||
];
|
||||
scene.removePokemonFromPlayerParty(playerPokemon, false);
|
||||
|
||||
const onBeforeRewardsPhase = () => {
|
||||
scene.queueMessage(getEncounterText(scene, "mysteryEncounter:training_session_battle_finished_3"), null, true);
|
||||
scene.queueMessage(
|
||||
getEncounterText(
|
||||
scene,
|
||||
"mysteryEncounter:training_session_battle_finished_3"
|
||||
),
|
||||
null,
|
||||
true
|
||||
);
|
||||
// Add the pokemon back to party with ability change
|
||||
const abilityIndex = encounter.misc.abilityIndex;
|
||||
if (!!playerPokemon.getFusionSpeciesForm()) {
|
||||
playerPokemon.fusionAbilityIndex = abilityIndex;
|
||||
if (speciesStarters.hasOwnProperty(playerPokemon.fusionSpecies.speciesId)) {
|
||||
scene.gameData.starterData[playerPokemon.fusionSpecies.speciesId].abilityAttr |= abilityIndex !== 1 || playerPokemon.fusionSpecies.ability2
|
||||
if (
|
||||
speciesStarters.hasOwnProperty(
|
||||
playerPokemon.fusionSpecies.speciesId
|
||||
)
|
||||
) {
|
||||
scene.gameData.starterData[
|
||||
playerPokemon.fusionSpecies.speciesId
|
||||
].abilityAttr |=
|
||||
abilityIndex !== 1 || playerPokemon.fusionSpecies.ability2
|
||||
? Math.pow(2, playerPokemon.fusionAbilityIndex)
|
||||
: AbilityAttr.ABILITY_HIDDEN;
|
||||
}
|
||||
} else {
|
||||
playerPokemon.abilityIndex = abilityIndex;
|
||||
if (speciesStarters.hasOwnProperty(playerPokemon.species.speciesId)) {
|
||||
scene.gameData.starterData[playerPokemon.species.speciesId].abilityAttr |= abilityIndex !== 1 || playerPokemon.species.ability2
|
||||
if (
|
||||
speciesStarters.hasOwnProperty(playerPokemon.species.speciesId)
|
||||
) {
|
||||
scene.gameData.starterData[
|
||||
playerPokemon.species.speciesId
|
||||
].abilityAttr |=
|
||||
abilityIndex !== 1 || playerPokemon.species.ability2
|
||||
? Math.pow(2, playerPokemon.abilityIndex)
|
||||
: AbilityAttr.ABILITY_HIDDEN;
|
||||
}
|
||||
|
@ -269,7 +398,12 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
scene.updateModifiers(true);
|
||||
};
|
||||
|
||||
setEncounterRewards(scene, { fillRemaining: true }, null, onBeforeRewardsPhase);
|
||||
setEncounterRewards(
|
||||
scene,
|
||||
{ fillRemaining: true },
|
||||
null,
|
||||
onBeforeRewardsPhase
|
||||
);
|
||||
|
||||
return initBattleWithEnemyConfig(scene, config);
|
||||
})
|
||||
|
@ -277,13 +411,23 @@ export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilde
|
|||
)
|
||||
.build();
|
||||
|
||||
function getEnemyConfig(scene: BattleScene, playerPokemon: PlayerPokemon, segments: number, modifiers: ModifiersHolder): EnemyPartyConfig {
|
||||
function getEnemyConfig(
|
||||
scene: BattleScene,
|
||||
playerPokemon: PlayerPokemon,
|
||||
segments: number,
|
||||
modifiers: ModifiersHolder
|
||||
): EnemyPartyConfig {
|
||||
playerPokemon.resetSummonData();
|
||||
|
||||
// Passes modifiers by reference
|
||||
modifiers.value = scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& (m as PokemonHeldItemModifier).pokemonId === playerPokemon.id) as PokemonHeldItemModifier[];
|
||||
const modifierTypes = modifiers.value.map(mod => mod.type) as PokemonHeldItemModifierType[];
|
||||
modifiers.value = scene.findModifiers(
|
||||
(m) =>
|
||||
m instanceof PokemonHeldItemModifier &&
|
||||
(m as PokemonHeldItemModifier).pokemonId === playerPokemon.id
|
||||
) as PokemonHeldItemModifier[];
|
||||
const modifierTypes = modifiers.value.map(
|
||||
(mod) => mod.type
|
||||
) as PokemonHeldItemModifierType[];
|
||||
|
||||
const data = new PokemonData(playerPokemon);
|
||||
return {
|
||||
|
@ -295,15 +439,14 @@ function getEnemyConfig(scene: BattleScene, playerPokemon: PlayerPokemon, segmen
|
|||
formIndex: playerPokemon.formIndex,
|
||||
level: playerPokemon.level,
|
||||
dataSource: data,
|
||||
modifierTypes: modifierTypes
|
||||
}
|
||||
]
|
||||
modifierTypes: modifierTypes,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
class ModifiersHolder {
|
||||
public value: PokemonHeldItemModifier[] = [];
|
||||
|
||||
constructor() {
|
||||
}
|
||||
constructor() {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { TrainingSessionDialogue } from "#app/data/mystery-encounters/dialogue/training-session-dialogue";
|
||||
import { TextStyle } from "#app/ui/text";
|
||||
|
||||
export class TextDisplay {
|
||||
|
@ -77,5 +75,4 @@ export default class MysteryEncounterDialogue {
|
|||
export const allMysteryEncounterDialogue: { [encounterType: number]: MysteryEncounterDialogue } = {};
|
||||
|
||||
export function initMysteryEncounterDialogue() {
|
||||
allMysteryEncounterDialogue[MysteryEncounterType.TRAINING_SESSION] = TrainingSessionDialogue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue