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 {
|
export interface EncounterRequirement {
|
||||||
meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met
|
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 {
|
export abstract class EncounterSceneRequirement implements EncounterRequirement {
|
||||||
@ -24,8 +25,8 @@ export abstract class EncounterSceneRequirement implements EncounterRequirement
|
|||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [(/@/gi), ""];
|
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
|
// Doesn't require the "@ec" as prefix, just the string; populates the token with the attribute
|
||||||
// ex. @ec{primarySpecies} if strPrefix is simply "primary"
|
// ex. @ec{primarySpecies} if strPrefix is simply "primary"
|
||||||
getMatchingDialogueToken(strPrefix:string, pokemon: PlayerPokemon): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [(/@/gi), ""];
|
return ["", ""];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,8 +66,8 @@ export class PreviousEncounterRequirement extends EncounterSceneRequirement {
|
|||||||
return scene.mysteryEncounterFlags.encounteredEvents.some(e => e[0] === this.previousEncounterRequirement);
|
return scene.mysteryEncounterFlags.encounteredEvents.some(e => e[0] === this.previousEncounterRequirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{previousEncounter\\}", "gi"), scene.mysteryEncounterFlags.encounteredEvents.find(e => e[0] === this.previousEncounterRequirement)[0].toString()];
|
return ["previousEncounter", scene.mysteryEncounterFlags.encounteredEvents.find(e => e[0] === this.previousEncounterRequirement)[0].toString()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +94,8 @@ export class WaveCountRequirement extends EncounterSceneRequirement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{waveCount\\}", "gi"), scene.currentBattle.waveIndex.toString()];
|
return ["waveCount", scene.currentBattle.waveIndex.toString()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,8 +121,8 @@ export class TimeOfDayRequirement extends EncounterSceneRequirement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{timeOfDay\\}", "gi"), TimeOfDay[scene.arena.getTimeOfDay()].toLocaleLowerCase()];
|
return ["timeOfDay", TimeOfDay[scene.arena.getTimeOfDay()].toLocaleLowerCase()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +147,8 @@ export class WeatherRequirement extends EncounterSceneRequirement {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{weather\\}", "gi"), WeatherType[scene.arena?.weather?.weatherType].replace("_", " ").toLocaleLowerCase()];
|
return ["weather", WeatherType[scene.arena?.weather?.weatherType].replace("_", " ").toLocaleLowerCase()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +176,8 @@ export class PartySizeRequirement extends EncounterSceneRequirement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{partySize\\}", "gi"), scene.getParty().length.toString()];
|
return ["partySize", scene.getParty().length.toString()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,12 +203,12 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
const requiredItemsInInventory = this.requiredItems.filter((a) => {
|
const requiredItemsInInventory = this.requiredItems.filter((a) => {
|
||||||
scene.modifiers.filter((itemInScene) => itemInScene.type.id === a.id).length > 0;
|
scene.modifiers.filter((itemInScene) => itemInScene.type.id === a.id).length > 0;
|
||||||
});
|
});
|
||||||
if (requiredItemsInInventory.length > 0) {
|
if (requiredItemsInInventory.length > 0) {
|
||||||
return [new RegExp("@ec\{requiredItem\\}", "gi"), requiredItemsInInventory[0].name];
|
return ["requiredItem", requiredItemsInInventory[0].name];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -229,8 +230,8 @@ export class MoneyRequirement extends EncounterSceneRequirement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(scene:BattleScene): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{money\\}", "gi"), "₽" + scene.money.toString()];
|
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)) {
|
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;
|
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)) {
|
if (this.requiredNature.includes(pokemon.nature)) {
|
||||||
return [new RegExp("@ec\{" + str + "Nature\\}", "gi"), Nature[pokemon.nature]];
|
return ["nature", Nature[pokemon.nature]];
|
||||||
}
|
}
|
||||||
return null;
|
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));
|
const includedTypes = this.requiredType.filter((ty) => pokemon.getTypes().includes(ty));
|
||||||
if (includedTypes.length > 0) {
|
if (includedTypes.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "Type\\}", "gi"), Type[includedTypes[0]]];
|
return ["type", Type[includedTypes[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
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);
|
const includedMoves = this.requiredMoves.filter((reqMove) => pokemon.moveset.filter((move) => move.moveId === reqMove).length > 0);
|
||||||
if (includedMoves.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;
|
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));
|
const includedCompatMoves = this.requiredMoves.filter((reqMove) => pokemon.compatibleTms.filter((tm) => !pokemon.moveset.find(m => m.moveId === tm)).includes(reqMove));
|
||||||
if (includedCompatMoves.length > 0) {
|
if (includedCompatMoves.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "CompatibleMove\\}", "gi"), Moves[includedCompatMoves[0]]];
|
return ["compatibleMove", Moves[includedCompatMoves[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -494,7 +495,7 @@ export class EvolutionTargetSpeciesRequirement extends EncounterPokemonRequireme
|
|||||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
||||||
const evos = this.requiredEvolutionTargetSpecies.filter((evolutionTargetSpecies) => pokemon.getEvolution().speciesId === evolutionTargetSpecies);
|
const evos = this.requiredEvolutionTargetSpecies.filter((evolutionTargetSpecies) => pokemon.getEvolution().speciesId === evolutionTargetSpecies);
|
||||||
if (evos.length > 0) {
|
if (evos.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "Evolution\\}", "gi"), Species[evos[0]]];
|
return ["Evolution", Species[evos[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
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) => {
|
const reqAbilities = this.requiredAbilities.filter((a) => {
|
||||||
pokemon.hasAbility(a);
|
pokemon.hasAbility(a);
|
||||||
});
|
});
|
||||||
if (reqAbilities.length > 0) {
|
if (reqAbilities.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "Ability\\}", "gi"), Abilities[reqAbilities[0]]];
|
return ["ability", Abilities[reqAbilities[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
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) => {
|
const reqStatus = this.requiredStatusEffect.filter((a) => {
|
||||||
pokemon.status?.effect ===(a);
|
pokemon.status?.effect ===(a);
|
||||||
});
|
});
|
||||||
if (reqStatus.length > 0) {
|
if (reqStatus.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "Status\\}", "gi"), StatusEffect[reqStatus[0]]];
|
return ["status", StatusEffect[reqStatus[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
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));
|
const requiredItems = this.requiredFormChangeItem.filter((formChangeItem) => this.filterByForm(pokemon, formChangeItem));
|
||||||
if (requiredItems.length > 0) {
|
if (requiredItems.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "FormChangeItem\\}", "gi"), FormChangeItem[requiredItems[0]]];
|
return ["formChangeItem", FormChangeItem[requiredItems[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
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));
|
const requiredItems = this.requiredEvolutionItem.filter((evoItem) => this.filterByEvo(pokemon, evoItem));
|
||||||
if (requiredItems.length > 0) {
|
if (requiredItems.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "EvolutionItem\\}", "gi"), EvolutionItem[requiredItems[0]]];
|
return ["evolutionItem", EvolutionItem[requiredItems[0]]];
|
||||||
}
|
}
|
||||||
return null;
|
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) => {
|
const requiredItems = this.requiredHeldItemModifier.filter((a) => {
|
||||||
pokemon.getHeldItems().filter((it) => it.type.id === a.id ).length > 0;
|
pokemon.getHeldItems().filter((it) => it.type.id === a.id ).length > 0;
|
||||||
});
|
});
|
||||||
if (requiredItems.length > 0) {
|
if (requiredItems.length > 0) {
|
||||||
return [new RegExp("@ec\{" + str + "HeldItem\\}", "gi"), requiredItems[0].name];
|
return ["heldItem", requiredItems[0].name];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class LevelRequirement extends EncounterPokemonRequirement {
|
export class LevelRequirement extends EncounterPokemonRequirement {
|
||||||
requiredLevelRange?: [number, number];
|
requiredLevelRange?: [number, number];
|
||||||
minNumberOfPokemon: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]);
|
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] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{" + str + "Friendship\\}", "gi"), pokemon.friendship.toString()];
|
return ["friendship", pokemon.friendship.toString()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,8 +870,8 @@ export class HealthRatioRequirement extends EncounterPokemonRequirement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getMatchingDialogueToken(str:string, pokemon: PlayerPokemon): [RegExp, string] {
|
getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
|
||||||
return [new RegExp("@ec\{" + str + "HealthRatio\\}", "gi"), Math.floor(pokemon.getHpRatio()*100).toString() + "%"];
|
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]);
|
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
|
* Will use the first support pokemon in list
|
||||||
* For multiple support pokemon in the dialogue token, it will have to be overridden.
|
* For multiple support pokemon in the dialogue token, it will have to be overridden.
|
||||||
*/
|
*/
|
||||||
populateDialogueTokensFromRequirements?() {
|
populateDialogueTokensFromRequirements?(scene: BattleScene) {
|
||||||
if (this.primaryPokemon?.length > 0) {
|
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) {
|
for (const req of this.primaryPokemonRequirements) {
|
||||||
if (!req.invertQuery) {
|
if (!req.invertQuery) {
|
||||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("primary", this.primaryPokemon);
|
const value = req.getDialogueToken(scene, this.primaryPokemon);
|
||||||
this.dialogueTokens.set("primary", entry);
|
this.setDialogueToken("primary" + this.capitalizeFirstLetter(value[0]), value[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.secondaryPokemonRequirements?.length > 0 && this.secondaryPokemon?.length > 0) {
|
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) {
|
for (const req of this.secondaryPokemonRequirements) {
|
||||||
if (!req.invertQuery) {
|
if (!req.invertQuery) {
|
||||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("secondary", this.secondaryPokemon[0]);
|
const value = req.getDialogueToken(scene, this.secondaryPokemon[0]);
|
||||||
this.dialogueTokens.set("secondary", entry);
|
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 opt = this.options[i];
|
||||||
const j = i + 1;
|
const j = i + 1;
|
||||||
if (opt.primaryPokemonRequirements?.length > 0 && opt.primaryPokemon?.length > 0) {
|
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) {
|
for (const req of opt.primaryPokemonRequirements) {
|
||||||
if (!req.invertQuery) {
|
if (!req.invertQuery) {
|
||||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("option" + j + "Primary", opt.primaryPokemon);
|
const value = req.getDialogueToken(scene, opt.primaryPokemon);
|
||||||
this.dialogueTokens.set("option" + j + "Primary", entry);
|
this.setDialogueToken("option" + j + "Primary", value[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opt.secondaryPokemonRequirements?.length > 0 && opt.secondaryPokemon?.length > 0) {
|
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) {
|
for (const req of opt.secondaryPokemonRequirements) {
|
||||||
if (!req.invertQuery) {
|
if (!req.invertQuery) {
|
||||||
const entry: [RegExp, string] = req.getMatchingDialogueToken("option" + j + "Secondary", opt.secondaryPokemon[0]);
|
const value = req.getDialogueToken(scene, opt.secondaryPokemon[0]);
|
||||||
this.dialogueTokens.set("option" + j + "Secondary", entry);
|
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> {
|
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
|
// Will never return last battle able mon and instead pick fainted/unable to battle
|
||||||
const removedPokemon = getRandomPlayerPokemon(scene, false, true);
|
const removedPokemon = getRandomPlayerPokemon(scene, false, true);
|
||||||
scene.removePokemonFromPlayerParty(removedPokemon);
|
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
|
// Store removed pokemon types
|
||||||
scene.currentBattle.mysteryEncounter.misc = [removedPokemon.species.type1];
|
scene.currentBattle.mysteryEncounter.misc = [removedPokemon.species.type1];
|
||||||
|
@ -32,7 +32,7 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil
|
|||||||
.withCatchAllowed(true)
|
.withCatchAllowed(true)
|
||||||
.withHideWildIntroMessage(true)
|
.withHideWildIntroMessage(true)
|
||||||
.withOnInit((scene: BattleScene) => {
|
.withOnInit((scene: BattleScene) => {
|
||||||
const instance = scene.currentBattle.mysteryEncounter;
|
const encounter = scene.currentBattle.mysteryEncounter;
|
||||||
|
|
||||||
// Calculate boss mon
|
// Calculate boss mon
|
||||||
const bossSpecies = scene.arena.randomSpecies(scene.currentBattle.waveIndex, scene.currentBattle.waveIndex, 0, getPartyLuckValue(scene.getParty()), true);
|
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,
|
levelAdditiveMultiplier: 1,
|
||||||
pokemonConfigs: [{species: bossSpecies, isBoss: true}]
|
pokemonConfigs: [{species: bossSpecies, isBoss: true}]
|
||||||
};
|
};
|
||||||
instance.enemyPartyConfigs = [config];
|
encounter.enemyPartyConfigs = [config];
|
||||||
|
|
||||||
// Calculate item
|
// Calculate item
|
||||||
// 10-60 GREAT, 60-110 ULTRA, 110-160 ROGUE, 160-180 MASTER
|
// 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;
|
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
|
regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0); // refresh player item pool
|
||||||
const item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [tier]})[0];
|
const item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [tier]})[0];
|
||||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("itemName", [/@ec\{itemName\}/gi, item.type.name]);
|
encounter.setDialogueToken("itemName", item.type.name);
|
||||||
scene.currentBattle.mysteryEncounter.misc = item;
|
encounter.misc = item;
|
||||||
|
|
||||||
instance.spriteConfigs = [
|
encounter.spriteConfigs = [
|
||||||
{
|
{
|
||||||
spriteKey: item.type.iconImage,
|
spriteKey: item.type.iconImage,
|
||||||
fileRoot: "items",
|
fileRoot: "items",
|
||||||
@ -92,7 +92,7 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil
|
|||||||
const config = scene.currentBattle.mysteryEncounter.enemyPartyConfigs[0];
|
const config = scene.currentBattle.mysteryEncounter.enemyPartyConfigs[0];
|
||||||
config.pokemonConfigs[0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON];
|
config.pokemonConfigs[0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON];
|
||||||
config.pokemonConfigs[0].mysteryEncounterBattleEffects = (pokemon: Pokemon) => {
|
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");
|
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));
|
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()
|
.withIntroSpriteConfigs([]) // These are set in onInit()
|
||||||
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
|
.withSceneRequirement(new WaveCountRequirement([10, 180])) // waves 10 to 180
|
||||||
.withOnInit((scene: BattleScene) => {
|
.withOnInit((scene: BattleScene) => {
|
||||||
const instance = scene.currentBattle.mysteryEncounter;
|
const encounter = scene.currentBattle.mysteryEncounter;
|
||||||
// Calculates what trainers are available for battle in the encounter
|
// Calculates what trainers are available for battle in the encounter
|
||||||
|
|
||||||
// Normal difficulty trainer is randomly pulled from biome
|
// Normal difficulty trainer is randomly pulled from biome
|
||||||
@ -32,7 +32,7 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
|||||||
female = !!(Utils.randSeedInt(2));
|
female = !!(Utils.randSeedInt(2));
|
||||||
}
|
}
|
||||||
const normalSpriteKey = normalConfig.getSpriteKey(female, normalConfig.doubleOnly);
|
const normalSpriteKey = normalConfig.getSpriteKey(female, normalConfig.doubleOnly);
|
||||||
instance.enemyPartyConfigs.push({
|
encounter.enemyPartyConfigs.push({
|
||||||
trainerConfig: normalConfig,
|
trainerConfig: normalConfig,
|
||||||
female: female
|
female: female
|
||||||
});
|
});
|
||||||
@ -50,7 +50,7 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
|||||||
female = !!(Utils.randSeedInt(2));
|
female = !!(Utils.randSeedInt(2));
|
||||||
}
|
}
|
||||||
const hardSpriteKey = hardConfig.getSpriteKey(female, hardConfig.doubleOnly);
|
const hardSpriteKey = hardConfig.getSpriteKey(female, hardConfig.doubleOnly);
|
||||||
instance.enemyPartyConfigs.push({
|
encounter.enemyPartyConfigs.push({
|
||||||
trainerConfig: hardConfig,
|
trainerConfig: hardConfig,
|
||||||
levelAdditiveMultiplier: 0.5,
|
levelAdditiveMultiplier: 0.5,
|
||||||
female: female,
|
female: female,
|
||||||
@ -68,13 +68,13 @@ export const MysteriousChallengersEncounter: MysteryEncounter = new MysteryEncou
|
|||||||
female = !!(Utils.randSeedInt(2));
|
female = !!(Utils.randSeedInt(2));
|
||||||
}
|
}
|
||||||
const brutalSpriteKey = brutalConfig.getSpriteKey(female, brutalConfig.doubleOnly);
|
const brutalSpriteKey = brutalConfig.getSpriteKey(female, brutalConfig.doubleOnly);
|
||||||
instance.enemyPartyConfigs.push({
|
encounter.enemyPartyConfigs.push({
|
||||||
trainerConfig: brutalConfig,
|
trainerConfig: brutalConfig,
|
||||||
levelAdditiveMultiplier: 1.1,
|
levelAdditiveMultiplier: 1.1,
|
||||||
female: female
|
female: female
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.spriteConfigs = [
|
encounter.spriteConfigs = [
|
||||||
{
|
{
|
||||||
spriteKey: normalSpriteKey,
|
spriteKey: normalSpriteKey,
|
||||||
fileRoot: "trainer",
|
fileRoot: "trainer",
|
||||||
|
@ -69,7 +69,7 @@ export const MysteriousChestEncounter: MysteryEncounter = new MysteryEncounterBu
|
|||||||
const highestLevelPokemon = getHighestLevelPlayerPokemon(scene, true);
|
const highestLevelPokemon = getHighestLevelPlayerPokemon(scene, true);
|
||||||
koPlayerPokemon(highestLevelPokemon);
|
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
|
// Show which Pokemon was KOed, then leave encounter with no rewards
|
||||||
// Does this synchronously so that game over doesn't happen over result message
|
// Does this synchronously so that game over doesn't happen over result message
|
||||||
await showEncounterText(scene, "mysteryEncounter:mysterious_chest_option_1_bad_result")
|
await showEncounterText(scene, "mysteryEncounter:mysterious_chest_option_1_bad_result")
|
||||||
|
@ -62,12 +62,11 @@ export function getRandomPlayerPokemon(scene: BattleScene, isAllowedInBattle: bo
|
|||||||
return chosenPokemon;
|
return chosenPokemon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function getTokensFromScene(scene: BattleScene, reqs: EncounterSceneRequirement[]): Array<[RegExp, String]> {
|
export function getTokensFromScene(scene: BattleScene, reqs: EncounterSceneRequirement[]): Array<[RegExp, String]> {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
if (scene) {
|
if (scene) {
|
||||||
for (const req of reqs) {
|
for (const req of reqs) {
|
||||||
req.getMatchingDialogueToken(scene);
|
req.getDialogueToken(scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
@ -450,7 +449,7 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
|
|||||||
const pokemon = scene.getParty()[slotIndex];
|
const pokemon = scene.getParty()[slotIndex];
|
||||||
const secondaryOptions = onPokemonSelected(pokemon);
|
const secondaryOptions = onPokemonSelected(pokemon);
|
||||||
if (!secondaryOptions) {
|
if (!secondaryOptions) {
|
||||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("selectedPokemon", [/@ec\{selectedPokemon\}/gi, pokemon.name]);
|
scene.currentBattle.mysteryEncounter.setDialogueToken("selectedPokemon", pokemon.name);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -464,7 +463,7 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p
|
|||||||
const onSelect = option.handler;
|
const onSelect = option.handler;
|
||||||
option.handler = () => {
|
option.handler = () => {
|
||||||
onSelect();
|
onSelect();
|
||||||
scene.currentBattle.mysteryEncounter.dialogueTokens.set("selectedPokemon", [/@ec\{selectedPokemon\}/gi, pokemon.name]);
|
scene.currentBattle.mysteryEncounter.setDialogueToken("selectedPokemon", pokemon.name);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -38,8 +38,8 @@ export const SleepingSnorlaxEncounter: MysteryEncounter = new MysteryEncounterBu
|
|||||||
.withCatchAllowed(true)
|
.withCatchAllowed(true)
|
||||||
.withHideWildIntroMessage(true)
|
.withHideWildIntroMessage(true)
|
||||||
.withOnInit((scene: BattleScene) => {
|
.withOnInit((scene: BattleScene) => {
|
||||||
const instance = scene.currentBattle.mysteryEncounter;
|
const encounter = scene.currentBattle.mysteryEncounter;
|
||||||
console.log(instance);
|
console.log(encounter);
|
||||||
|
|
||||||
// Calculate boss mon
|
// Calculate boss mon
|
||||||
const bossSpecies = getPokemonSpecies(Species.SNORLAX);
|
const bossSpecies = getPokemonSpecies(Species.SNORLAX);
|
||||||
@ -52,7 +52,7 @@ export const SleepingSnorlaxEncounter: MysteryEncounter = new MysteryEncounterBu
|
|||||||
levelAdditiveMultiplier: 2,
|
levelAdditiveMultiplier: 2,
|
||||||
pokemonConfigs: [pokemonConfig]
|
pokemonConfigs: [pokemonConfig]
|
||||||
};
|
};
|
||||||
instance.enemyPartyConfigs = [config];
|
encounter.enemyPartyConfigs = [config];
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.withOption(new MysteryEncounterOptionBuilder()
|
.withOption(new MysteryEncounterOptionBuilder()
|
||||||
|
@ -77,8 +77,8 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onBeforeRewardsPhase = () => {
|
const onBeforeRewardsPhase = () => {
|
||||||
encounter.dialogueTokens.set("stat1", [/@ec\{stat1\}/gi, "-"]);
|
encounter.setDialogueToken("stat1", "-");
|
||||||
encounter.dialogueTokens.set("stat2", [/@ec\{stat2\}/gi, "-"]);
|
encounter.setDialogueToken("stat2", "-");
|
||||||
// Add the pokemon back to party with IV boost
|
// Add the pokemon back to party with IV boost
|
||||||
const ivIndexes = [];
|
const ivIndexes = [];
|
||||||
playerPokemon.ivs.forEach((iv, index) => {
|
playerPokemon.ivs.forEach((iv, index) => {
|
||||||
@ -100,9 +100,9 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
|||||||
const ivToChange = ivIndexes.pop();
|
const ivToChange = ivIndexes.pop();
|
||||||
let newVal = ivToChange.iv;
|
let newVal = ivToChange.iv;
|
||||||
if (improvedCount === 0) {
|
if (improvedCount === 0) {
|
||||||
encounter.dialogueTokens.set("stat1", [/@ec\{stat1\}/gi, getIvName(ivToChange.index)]);
|
encounter.setDialogueToken("stat1", getIvName(ivToChange.index));
|
||||||
} else {
|
} 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
|
// 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),
|
label: getNatureName(nature, true, true, true, scene.uiTheme),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
// Pokemon and second option selected
|
// Pokemon and second option selected
|
||||||
encounter.dialogueTokens.set("nature", [/@ec\{nature\}/gi, getNatureName(nature)]);
|
encounter.setDialogueToken("nature", getNatureName(nature));
|
||||||
encounter.misc = {
|
encounter.misc = {
|
||||||
playerPokemon: pokemon,
|
playerPokemon: pokemon,
|
||||||
chosenNature: nature
|
chosenNature: nature
|
||||||
@ -206,7 +206,7 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu
|
|||||||
label: ability.name,
|
label: ability.name,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
// Pokemon and ability selected
|
// Pokemon and ability selected
|
||||||
encounter.dialogueTokens.set("ability", [/@ec\{ability\}/gi, ability.name]);
|
encounter.setDialogueToken("ability", ability.name);
|
||||||
encounter.misc = {
|
encounter.misc = {
|
||||||
playerPokemon: pokemon,
|
playerPokemon: pokemon,
|
||||||
abilityIndex: index
|
abilityIndex: index
|
||||||
|
Loading…
Reference in New Issue
Block a user