mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-27 01:06:09 +00:00
clean up data token logic
This commit is contained in:
parent
8e84e40e35
commit
7fb1506a97
@ -17,6 +17,7 @@ import {MysteryEncounterType} from "#enums/mystery-encounter-type";
|
||||
|
||||
export interface EncounterRequirement {
|
||||
meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string];
|
||||
}
|
||||
|
||||
export abstract class EncounterSceneRequirement implements EncounterRequirement {
|
||||
@ -24,8 +25,8 @@ export abstract class EncounterSceneRequirement implements EncounterRequirement
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [(/@/gi), ""];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["", ""];
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,8 +45,8 @@ export abstract class EncounterPokemonRequirement implements EncounterRequiremen
|
||||
|
||||
// Doesn't require the "@ec" as prefix, just the string; populates the token with the attribute
|
||||
// ex. @ec{primarySpecies} if strPrefix is simply "primary"
|
||||
getMatchingDialogueToken(strPrefix:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
return [(/@/gi), ""];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["", ""];
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +66,8 @@ export class PreviousEncounterRequirement extends EncounterSceneRequirement {
|
||||
return scene.mysteryEncounterFlags.encounteredEvents.some(e => e[0] === this.previousEncounterRequirement);
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [new RegExp("@ec\{previousEncounter\\}", "gi"), scene.mysteryEncounterFlags.encounteredEvents.find(e => e[0] === this.previousEncounterRequirement)[0].toString()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["previousEncounter", scene.mysteryEncounterFlags.encounteredEvents.find(e => e[0] === this.previousEncounterRequirement)[0].toString()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,8 +94,8 @@ export class WaveCountRequirement extends EncounterSceneRequirement {
|
||||
return true;
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [new RegExp("@ec\{waveCount\\}", "gi"), scene.currentBattle.waveIndex.toString()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["waveCount", scene.currentBattle.waveIndex.toString()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,8 +121,8 @@ export class TimeOfDayRequirement extends EncounterSceneRequirement {
|
||||
return true;
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [new RegExp("@ec\{timeOfDay\\}", "gi"), TimeOfDay[scene.arena.getTimeOfDay()].toLocaleLowerCase()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["timeOfDay", TimeOfDay[scene.arena.getTimeOfDay()].toLocaleLowerCase()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,8 +147,8 @@ export class WeatherRequirement extends EncounterSceneRequirement {
|
||||
|
||||
return true;
|
||||
}
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [new RegExp("@ec\{weather\\}", "gi"), WeatherType[scene.arena?.weather?.weatherType].replace("_", " ").toLocaleLowerCase()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["weather", WeatherType[scene.arena?.weather?.weatherType].replace("_", " ").toLocaleLowerCase()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,8 +176,8 @@ export class PartySizeRequirement extends EncounterSceneRequirement {
|
||||
return true;
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [new RegExp("@ec\{partySize\\}", "gi"), scene.getParty().length.toString()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["partySize", scene.getParty().length.toString()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,12 +203,12 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement {
|
||||
return true;
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const requiredItemsInInventory = this.requiredItems.filter((a) => {
|
||||
scene.modifiers.filter((itemInScene) => itemInScene.type.id === a.id).length > 0;
|
||||
});
|
||||
if (requiredItemsInInventory.length > 0) {
|
||||
return [new RegExp("@ec\{requiredItem\\}", "gi"), requiredItemsInInventory[0].name];
|
||||
return ["requiredItem", requiredItemsInInventory[0].name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -229,8 +230,8 @@ export class MoneyRequirement extends EncounterSceneRequirement {
|
||||
return true;
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
||||
return [new RegExp("@ec\{money\\}", "gi"), "₽" + scene.money.toString()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["money", "₽" + scene.money.toString()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,9 +269,9 @@ export class SpeciesRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
if (this.requiredSpecies.includes(pokemon.species.speciesId)) {
|
||||
return [new RegExp("@ec\{" + str + "Species\\}", "gi"), Species[pokemon.species.speciesId]];
|
||||
return ["species", Species[pokemon.species.speciesId]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -311,9 +312,9 @@ export class NatureRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
if (this.requiredNature.includes(pokemon.nature)) {
|
||||
return [new RegExp("@ec\{" + str + "Nature\\}", "gi"), Nature[pokemon.nature]];
|
||||
return ["nature", Nature[pokemon.nature]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -353,10 +354,10 @@ export class TypeRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedTypes = this.requiredType.filter((ty) => pokemon.getTypes().includes(ty));
|
||||
if (includedTypes.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "Type\\}", "gi"), Type[includedTypes[0]]];
|
||||
return ["type", Type[includedTypes[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -397,10 +398,10 @@ export class MoveRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedMoves = this.requiredMoves.filter((reqMove) => pokemon.moveset.filter((move) => move.moveId === reqMove).length > 0);
|
||||
if (includedMoves.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "Move\\}", "gi"), Moves[includedMoves[0]].replace("_", " ")];
|
||||
return ["move", Moves[includedMoves[0]].replace("_", " ")];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -446,10 +447,10 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const includedCompatMoves = this.requiredMoves.filter((reqMove) => pokemon.compatibleTms.filter((tm) => !pokemon.moveset.find(m => m.moveId === tm)).includes(reqMove));
|
||||
if (includedCompatMoves.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "CompatibleMove\\}", "gi"), Moves[includedCompatMoves[0]]];
|
||||
return ["compatibleMove", Moves[includedCompatMoves[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -494,7 +495,7 @@ export class EvolutionTargetSpeciesRequirement extends EncounterPokemonRequireme
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
const evos = this.requiredEvolutionTargetSpecies.filter((evolutionTargetSpecies) => pokemon.getEvolution().speciesId === evolutionTargetSpecies);
|
||||
if (evos.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "Evolution\\}", "gi"), Species[evos[0]]];
|
||||
return ["Evolution", Species[evos[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -535,12 +536,12 @@ export class AbilityRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const reqAbilities = this.requiredAbilities.filter((a) => {
|
||||
pokemon.hasAbility(a);
|
||||
});
|
||||
if (reqAbilities.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "Ability\\}", "gi"), Abilities[reqAbilities[0]]];
|
||||
return ["ability", Abilities[reqAbilities[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -582,12 +583,12 @@ export class StatusEffectRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const reqStatus = this.requiredStatusEffect.filter((a) => {
|
||||
pokemon.status?.effect ===(a);
|
||||
});
|
||||
if (reqStatus.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "Status\\}", "gi"), StatusEffect[reqStatus[0]]];
|
||||
return ["status", StatusEffect[reqStatus[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -645,10 +646,10 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const requiredItems = this.requiredFormChangeItem.filter((formChangeItem) => this.filterByForm(pokemon, formChangeItem));
|
||||
if (requiredItems.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "FormChangeItem\\}", "gi"), FormChangeItem[requiredItems[0]]];
|
||||
return ["formChangeItem", FormChangeItem[requiredItems[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -700,10 +701,10 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const requiredItems = this.requiredEvolutionItem.filter((evoItem) => this.filterByEvo(pokemon, evoItem));
|
||||
if (requiredItems.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "EvolutionItem\\}", "gi"), EvolutionItem[requiredItems[0]]];
|
||||
return ["evolutionItem", EvolutionItem[requiredItems[0]]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -743,19 +744,17 @@ export class HeldItemRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
const requiredItems = this.requiredHeldItemModifier.filter((a) => {
|
||||
pokemon.getHeldItems().filter((it) => it.type.id === a.id ).length > 0;
|
||||
});
|
||||
if (requiredItems.length > 0) {
|
||||
return [new RegExp("@ec\{" + str + "HeldItem\\}", "gi"), requiredItems[0].name];
|
||||
return ["heldItem", requiredItems[0].name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export class LevelRequirement extends EncounterPokemonRequirement {
|
||||
requiredLevelRange?: [number, number];
|
||||
minNumberOfPokemon:number;
|
||||
@ -789,8 +788,9 @@ export class LevelRequirement extends EncounterPokemonRequirement {
|
||||
return partyPokemon.filter((pokemon) => pokemon.level < this.requiredLevelRange[0] || pokemon.level > this.requiredLevelRange[1]);
|
||||
}
|
||||
}
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
return [new RegExp("@ec\{" + str + "Level\\}", "gi"), pokemon.level.toString()];
|
||||
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["level", pokemon.level.toString()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -827,8 +827,8 @@ export class FriendshipRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
return [new RegExp("@ec\{" + str + "Friendship\\}", "gi"), pokemon.friendship.toString()];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["friendship", pokemon.friendship.toString()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,8 +870,8 @@ export class HealthRatioRequirement extends EncounterPokemonRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
return [new RegExp("@ec\{" + str + "HealthRatio\\}", "gi"), Math.floor(pokemon.getHpRatio()*100).toString() + "%"];
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["healthRatio", Math.floor(pokemon.getHpRatio()*100).toString() + "%"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -907,7 +907,8 @@ export class WeightRequirement extends EncounterPokemonRequirement {
|
||||
return partyPokemon.filter((pokemon) => pokemon.getWeight() < this.requiredWeightRange[0] || pokemon.getWeight() > this.requiredWeightRange[1]);
|
||||
}
|
||||
}
|
||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||
return [new RegExp("@ec\{" + str + "Weight\\}", "gi"), pokemon.getWeight().toString()];
|
||||
|
||||
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||
return ["weight", pokemon.getWeight().toString()];
|
||||
}
|
||||
}
|
||||
|
@ -262,22 +262,22 @@ export default class MysteryEncounter implements MysteryEncounter {
|
||||
* Will use the first support pokemon in list
|
||||
* For multiple support pokemon in the dialogue token, it will have to be overridden.
|
||||
*/
|
||||
populateDialogueTokensFromRequirements?() {
|
||||
populateDialogueTokensFromRequirements?(scene: BattleScene) {
|
||||
if (this.primaryPokemon?.length > 0) {
|
||||
this.dialogueTokens.set("primaryName", [/@ec\{primaryName\}/gi, this.primaryPokemon.name]);
|
||||
this.setDialogueToken("primaryName", this.primaryPokemon.name);
|
||||
for (const req of this.primaryPokemonRequirements) {
|
||||
if (!req.invertQuery) {
|
||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("primary", this.primaryPokemon);
|
||||
this.dialogueTokens.set("primary", entry);
|
||||
const value = req.getDialogueToken(scene, this.primaryPokemon);
|
||||
this.setDialogueToken("primary" + this.capitalizeFirstLetter(value[0]), value[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.secondaryPokemonRequirements?.length > 0 && this.secondaryPokemon?.length > 0) {
|
||||
this.dialogueTokens.set("secondaryName", [/@ec\{secondaryName\}/gi, this.secondaryPokemon[0].name]);
|
||||
this.setDialogueToken("secondaryName", this.secondaryPokemon[0].name);
|
||||
for (const req of this.secondaryPokemonRequirements) {
|
||||
if (!req.invertQuery) {
|
||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("secondary", this.secondaryPokemon[0]);
|
||||
this.dialogueTokens.set("secondary", entry);
|
||||
const value = req.getDialogueToken(scene, this.secondaryPokemon[0]);
|
||||
this.setDialogueToken("secondary" + this.capitalizeFirstLetter(value[0]), value[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -285,25 +285,33 @@ export default class MysteryEncounter implements MysteryEncounter {
|
||||
const opt = this.options[i];
|
||||
const j = i + 1;
|
||||
if (opt.primaryPokemonRequirements?.length > 0 && opt.primaryPokemon?.length > 0) {
|
||||
this.dialogueTokens.set("option" + j + "PrimaryName", [new RegExp("@ec\{option" + j + "PrimaryName\\}", "gi"), opt.primaryPokemon.name]);
|
||||
this.setDialogueToken("option" + j + "PrimaryName", opt.primaryPokemon.name);
|
||||
for (const req of opt.primaryPokemonRequirements) {
|
||||
if (!req.invertQuery) {
|
||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("option" + j + "Primary", opt.primaryPokemon);
|
||||
this.dialogueTokens.set("option" + j + "Primary", entry);
|
||||
const value = req.getDialogueToken(scene, opt.primaryPokemon);
|
||||
this.setDialogueToken("option" + j + "Primary", value[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (opt.secondaryPokemonRequirements?.length > 0 && opt.secondaryPokemon?.length > 0) {
|
||||
this.dialogueTokens.set("option" + j + "SecondaryName", [new RegExp("@ec\{option" + j + "SecondaryName\\}", "gi"), opt.secondaryPokemon[0].name]);
|
||||
this.setDialogueToken("option" + j + "SecondaryName", opt.secondaryPokemon[0].name);
|
||||
for (const req of opt.secondaryPokemonRequirements) {
|
||||
if (!req.invertQuery) {
|
||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("option" + j + "Secondary", opt.secondaryPokemon[0]);
|
||||
this.dialogueTokens.set("option" + j + "Secondary", entry);
|
||||
const value = req.getDialogueToken(scene, opt.secondaryPokemon[0]);
|
||||
this.setDialogueToken("option" + j + "Secondary", value[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setDialogueToken?(key: string, value: string) {
|
||||
this.dialogueTokens.set(key, [new RegExp("@ec\{" + value + "\\}", "gi"), value]);
|
||||
}
|
||||
|
||||
private capitalizeFirstLetter?(str: string) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
export class MysteryEncounterBuilder implements Partial<MysteryEncounter> {
|
||||
|
@ -92,7 +92,8 @@ export const DarkDealEncounter: MysteryEncounter = new MysteryEncounterBuilder()
|
||||
// Will never return last battle able mon and instead pick fainted/unable to battle
|
||||
const removedPokemon = getRandomPlayerPokemon(scene, false, true);
|
||||
scene.removePokemonFromPlayerParty(removedPokemon);
|
||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("pokeName", [/@ec\{pokeName\}/gi, removedPokemon.name]);
|
||||
|
||||
scene.currentBattle.mysteryEncounter.setDialogueToken("pokeName", removedPokemon.name);
|
||||
|
||||
// Store removed pokemon types
|
||||
scene.currentBattle.mysteryEncounter.misc = [removedPokemon.species.type1];
|
||||
|
@ -32,7 +32,7 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil
|
||||
.withCatchAllowed(true)
|
||||
.withHideWildIntroMessage(true)
|
||||
.withOnInit((scene: BattleScene) => {
|
||||
const instance = scene.currentBattle.mysteryEncounter;
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
|
||||
// Calculate boss mon
|
||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, scene.currentBattle.waveIndex, 0, getPartyLuckValue(scene.getParty()), true);
|
||||
@ -40,17 +40,17 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil
|
||||
levelAdditiveMultiplier: 1,
|
||||
pokemonConfigs: [{species: bossSpecies, isBoss: true}]
|
||||
};
|
||||
instance.enemyPartyConfigs = [config];
|
||||
encounter.enemyPartyConfigs = [config];
|
||||
|
||||
// Calculate item
|
||||
// 10-60 GREAT, 60-110 ULTRA, 110-160 ROGUE, 160-180 MASTER
|
||||
const tier = scene.currentBattle.waveIndex > 160 ? ModifierTier.MASTER : scene.currentBattle.waveIndex > 110 ? ModifierTier.ROGUE : scene.currentBattle.waveIndex > 60 ? ModifierTier.ULTRA : ModifierTier.GREAT;
|
||||
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0); // refresh player item pool
|
||||
const item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [tier]})[0];
|
||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("itemName", [/@ec\{itemName\}/gi, item.type.name]);
|
||||
scene.currentBattle.mysteryEncounter.misc = item;
|
||||
encounter.setDialogueToken("itemName", item.type.name);
|
||||
encounter.misc = item;
|
||||
|
||||
instance.spriteConfigs = [
|
||||
encounter.spriteConfigs = [
|
||||
{
|
||||
spriteKey: item.type.iconImage,
|
||||
fileRoot: "items",
|
||||
@ -92,7 +92,7 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil
|
||||
const config = scene.currentBattle.mysteryEncounter.enemyPartyConfigs[0];
|
||||
config.pokemonConfigs[0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON];
|
||||
config.pokemonConfigs[0].mysteryEncounterBattleEffects = (pokemon: Pokemon) => {
|
||||
pokemon.scene.currentBattle.mysteryEncounter.dialogueTokens.set("enemyPokemon", [/@ec\{enemyPokemon\}/gi, pokemon.name]);
|
||||
pokemon.scene.currentBattle.mysteryEncounter.setDialogueToken("enemyPokemon", pokemon.name);
|
||||
queueEncounterMessage(pokemon.scene, "mysteryEncounter:fight_or_flight_boss_enraged");
|
||||
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD], 1));
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
||||
.withIntroSpriteConfigs([]) // These are set in onInit()
|
||||
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
|
||||
.withOnInit((scene: BattleScene) => {
|
||||
const instance = scene.currentBattle.mysteryEncounter;
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
// Calculates what trainers are available for battle in the encounter
|
||||
|
||||
// Normal difficulty trainer is randomly pulled from biome
|
||||
@ -32,7 +32,7 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
||||
female = !!(Utils.randSeedInt(2));
|
||||
}
|
||||
const normalSpriteKey = normalConfig.getSpriteKey(female, normalConfig.doubleOnly);
|
||||
instance.enemyPartyConfigs.push({
|
||||
encounter.enemyPartyConfigs.push({
|
||||
trainerConfig: normalConfig,
|
||||
female: female
|
||||
});
|
||||
@ -50,7 +50,7 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
||||
female = !!(Utils.randSeedInt(2));
|
||||
}
|
||||
const hardSpriteKey = hardConfig.getSpriteKey(female, hardConfig.doubleOnly);
|
||||
instance.enemyPartyConfigs.push({
|
||||
encounter.enemyPartyConfigs.push({
|
||||
trainerConfig: hardConfig,
|
||||
levelAdditiveMultiplier: 0.5,
|
||||
female: female,
|
||||
@ -68,13 +68,13 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
||||
female = !!(Utils.randSeedInt(2));
|
||||
}
|
||||
const brutalSpriteKey = brutalConfig.getSpriteKey(female, brutalConfig.doubleOnly);
|
||||
instance.enemyPartyConfigs.push({
|
||||
encounter.enemyPartyConfigs.push({
|
||||
trainerConfig: brutalConfig,
|
||||
levelAdditiveMultiplier: 1.1,
|
||||
female: female
|
||||
});
|
||||
|
||||
instance.spriteConfigs = [
|
||||
encounter.spriteConfigs = [
|
||||
{
|
||||
spriteKey: normalSpriteKey,
|
||||
fileRoot: "trainer",
|
||||
|
@ -69,7 +69,7 @@ export const MysteriousChestEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
const highestLevelPokemon = getHighestLevelPlayerPokemon(scene, true);
|
||||
koPlayerPokemon(highestLevelPokemon);
|
||||
|
||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("pokeName", [/@ec\{pokeName\}/gi, highestLevelPokemon.name]);
|
||||
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")
|
||||
|
@ -62,12 +62,11 @@ export function getRandomPlayerPokemon(scene: BattleScene, isAllowedInBattle: bo
|
||||
return chosenPokemon;
|
||||
}
|
||||
|
||||
|
||||
export function getTokensFromScene(scene: BattleScene, reqs: EncounterSceneRequirement[]): Array<[RegExp, String]> {
|
||||
const arr = [];
|
||||
if (scene) {
|
||||
for (const req of reqs) {
|
||||
req.getMatchingDialogueToken(scene);
|
||||
req.getDialogueToken(scene);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
@ -450,7 +449,7 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
|
||||
const pokemon = scene.getParty()[slotIndex];
|
||||
const secondaryOptions = onPokemonSelected(pokemon);
|
||||
if (!secondaryOptions) {
|
||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("selectedPokemon", [/@ec\{selectedPokemon\}/gi, pokemon.name]);
|
||||
scene.currentBattle.mysteryEncounter.setDialogueToken("selectedPokemon", pokemon.name);
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
@ -464,7 +463,7 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
|
||||
const onSelect = option.handler;
|
||||
option.handler = () => {
|
||||
onSelect();
|
||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("selectedPokemon", [/@ec\{selectedPokemon\}/gi, pokemon.name]);
|
||||
scene.currentBattle.mysteryEncounter.setDialogueToken("selectedPokemon", pokemon.name);
|
||||
resolve(true);
|
||||
return true;
|
||||
};
|
||||
|
@ -38,8 +38,8 @@ export const SleepingSnorlaxEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
.withCatchAllowed(true)
|
||||
.withHideWildIntroMessage(true)
|
||||
.withOnInit((scene: BattleScene) => {
|
||||
const instance = scene.currentBattle.mysteryEncounter;
|
||||
console.log(instance);
|
||||
const encounter = scene.currentBattle.mysteryEncounter;
|
||||
console.log(encounter);
|
||||
|
||||
// Calculate boss mon
|
||||
const bossSpecies = getPokemonSpecies(Species.SNORLAX);
|
||||
@ -52,7 +52,7 @@ export const SleepingSnorlaxEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
levelAdditiveMultiplier: 2,
|
||||
pokemonConfigs: [pokemonConfig]
|
||||
};
|
||||
instance.enemyPartyConfigs = [config];
|
||||
encounter.enemyPartyConfigs = [config];
|
||||
return true;
|
||||
})
|
||||
.withOption(new MysteryEncounterOptionBuilder()
|
||||
|
@ -77,8 +77,8 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
};
|
||||
|
||||
const onBeforeRewardsPhase = () => {
|
||||
encounter.dialogueTokens.set("stat1", [/@ec\{stat1\}/gi, "-"]);
|
||||
encounter.dialogueTokens.set("stat2", [/@ec\{stat2\}/gi, "-"]);
|
||||
encounter.setDialogueToken("stat1", "-");
|
||||
encounter.setDialogueToken("stat2", "-");
|
||||
// Add the pokemon back to party with IV boost
|
||||
const ivIndexes = [];
|
||||
playerPokemon.ivs.forEach((iv, index) => {
|
||||
@ -100,9 +100,9 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
const ivToChange = ivIndexes.pop();
|
||||
let newVal = ivToChange.iv;
|
||||
if (improvedCount === 0) {
|
||||
encounter.dialogueTokens.set("stat1", [/@ec\{stat1\}/gi, getIvName(ivToChange.index)]);
|
||||
encounter.setDialogueToken("stat1", getIvName(ivToChange.index));
|
||||
} else {
|
||||
encounter.dialogueTokens.set("stat2", [/@ec\{stat2\}/gi, getIvName(ivToChange.index)]);
|
||||
encounter.setDialogueToken("stat2", getIvName(ivToChange.index));
|
||||
}
|
||||
|
||||
// Corrects required encounter breakpoints to be continuous for all IV values
|
||||
@ -148,7 +148,7 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
label: getNatureName(nature, true, true, true, scene.uiTheme),
|
||||
handler: () => {
|
||||
// Pokemon and second option selected
|
||||
encounter.dialogueTokens.set("nature", [/@ec\{nature\}/gi, getNatureName(nature)]);
|
||||
encounter.setDialogueToken("nature", getNatureName(nature));
|
||||
encounter.misc = {
|
||||
playerPokemon: pokemon,
|
||||
chosenNature: nature
|
||||
@ -206,7 +206,7 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
||||
label: ability.name,
|
||||
handler: () => {
|
||||
// Pokemon and ability selected
|
||||
encounter.dialogueTokens.set("ability", [/@ec\{ability\}/gi, ability.name]);
|
||||
encounter.setDialogueToken("ability", ability.name);
|
||||
encounter.misc = {
|
||||
playerPokemon: pokemon,
|
||||
abilityIndex: index
|
||||
|
Loading…
Reference in New Issue
Block a user