mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-26 17:29:30 +02:00
Almost done
This commit is contained in:
parent
06b782cd06
commit
cb7cb3332f
@ -10,6 +10,7 @@ import { cos, sin } from "./field/anims";
|
|||||||
import { PlayerPokemon } from "./field/pokemon";
|
import { PlayerPokemon } from "./field/pokemon";
|
||||||
import { getTypeRgb } from "./data/type";
|
import { getTypeRgb } from "./data/type";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
import * as LoggerTools from "./logger";
|
||||||
|
|
||||||
export class EvolutionPhase extends Phase {
|
export class EvolutionPhase extends Phase {
|
||||||
protected pokemon: PlayerPokemon;
|
protected pokemon: PlayerPokemon;
|
||||||
@ -194,12 +195,14 @@ export class EvolutionPhase extends Phase {
|
|||||||
this.scene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: preName }), null, () => {
|
this.scene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: preName }), null, () => {
|
||||||
this.scene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: preName }), null, () => {
|
this.scene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: preName }), null, () => {
|
||||||
const end = () => {
|
const end = () => {
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Cancel " + preName + "'s evolution")
|
||||||
this.scene.ui.showText(null, 0);
|
this.scene.ui.showText(null, 0);
|
||||||
this.scene.playBgm();
|
this.scene.playBgm();
|
||||||
evolvedPokemon.destroy();
|
evolvedPokemon.destroy();
|
||||||
this.end();
|
this.end();
|
||||||
};
|
};
|
||||||
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Cancel " + preName + "'s evolution and pause evolutions")
|
||||||
this.scene.ui.revertMode();
|
this.scene.ui.revertMode();
|
||||||
this.pokemon.pauseEvolutions = true;
|
this.pokemon.pauseEvolutions = true;
|
||||||
this.scene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: preName }), null, end, 3000);
|
this.scene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: preName }), null, end, 3000);
|
||||||
@ -219,6 +222,7 @@ export class EvolutionPhase extends Phase {
|
|||||||
evolutionHandler.canCancel = false;
|
evolutionHandler.canCancel = false;
|
||||||
|
|
||||||
this.pokemon.evolve(this.evolution).then(() => {
|
this.pokemon.evolve(this.evolution).then(() => {
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Evolve " + preName)
|
||||||
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
|
const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true);
|
||||||
for (const lm of levelMoves) {
|
for (const lm of levelMoves) {
|
||||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getParty().indexOf(this.pokemon), lm[1]));
|
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.scene.getParty().indexOf(this.pokemon), lm[1]));
|
||||||
|
404
src/logger.ts
404
src/logger.ts
@ -40,18 +40,41 @@ export const logKeys: string[] = [
|
|||||||
"d", // Debug
|
"d", // Debug
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the save's RNG seed to create a log ID. Used to assign each save its own log.
|
||||||
|
* @param scene The BattleScene.
|
||||||
|
* @returns The ID of the current save's log.
|
||||||
|
*/
|
||||||
export function getLogID(scene: BattleScene) {
|
export function getLogID(scene: BattleScene) {
|
||||||
return "drpd_log:" + scene.seed
|
return "drpd_log:" + scene.seed
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Gets a log's item list storage, for detecting reloads via a change in the loot rewards.
|
||||||
|
*
|
||||||
|
* Not used yet.
|
||||||
|
* @param scene The BattleScene.
|
||||||
|
* @returns The ID of the current save's log.
|
||||||
|
*/
|
||||||
|
export function getItemsID(scene: BattleScene) {
|
||||||
|
return "drpd_items:" + scene.seed
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Resets the `logs` array, and creates a list of all game logs in LocalStorage.
|
||||||
|
*/
|
||||||
export function getLogs() {
|
export function getLogs() {
|
||||||
while(logs.length > 0)
|
while(logs.length > 0)
|
||||||
logs.pop()
|
logs.pop()
|
||||||
for (var i = 0; i < localStorage.length; i++) {
|
for (var i = 0; i < localStorage.length; i++) {
|
||||||
if (localStorage.key(i).substring(0, 9) == "drpd_log:") {
|
if (localStorage.key(i).substring(0, 9) == "drpd_log:") {
|
||||||
logs.push(["drpd.json", localStorage.key(i), localStorage.key(i).substring(9), "", "", ""])
|
logs.push(["drpd.json", localStorage.key(i), localStorage.key(i).substring(9), "drpd_items:" + localStorage.key(i).substring(9), "", ""])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Returns a string for the name of the current game mode.
|
||||||
|
* @param scene The BattleScene. Used to get the game mode.
|
||||||
|
* @returns The name of the game mode, for use in naming a game log.
|
||||||
|
*/
|
||||||
export function getMode(scene: BattleScene) {
|
export function getMode(scene: BattleScene) {
|
||||||
switch (scene.gameMode.modeId) {
|
switch (scene.gameMode.modeId) {
|
||||||
case GameModes.CLASSIC:
|
case GameModes.CLASSIC:
|
||||||
@ -67,9 +90,37 @@ export function getMode(scene: BattleScene) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a Pokemon in the player's party.
|
||||||
|
* @param scene The BattleScene, for getting the player's party.
|
||||||
|
* @param index The slot index.
|
||||||
|
* @returns [INDEX] NAME (example: `[1] Walking Wake` is a Walking Wake in the first party slot)
|
||||||
|
*/
|
||||||
|
export function playerPokeName(scene: BattleScene, index: integer | Pokemon | PlayerPokemon) {
|
||||||
|
if (typeof index == "number") {
|
||||||
|
return "[" + (index + 1) + "] " + scene.getParty()[index].name
|
||||||
|
}
|
||||||
|
return "[" + (scene.getParty().indexOf(index as PlayerPokemon) + 1) + "] " + index.name
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Formats a Pokemon in the opposing party.
|
||||||
|
* @param scene The BattleScene, for getting the enemy's party.
|
||||||
|
* @param index The slot index.
|
||||||
|
* @returns [INDEX] NAME (example: `[2] Zigzagoon` is a Zigzagoon in the right slot (for a double battle) or in the second party slot (for a single battle against a Trainer))
|
||||||
|
*/
|
||||||
|
export function enemyPokeName(scene: BattleScene, index: integer | Pokemon | EnemyPokemon) {
|
||||||
|
if (typeof index == "number") {
|
||||||
|
return "[" + (index + 1) + "] " + scene.getEnemyParty()[index].name
|
||||||
|
}
|
||||||
|
return "[" + (scene.getEnemyParty().indexOf(index as EnemyPokemon) + 1) + "] " + index.name
|
||||||
|
}
|
||||||
|
// LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "")
|
||||||
|
|
||||||
export const rarities = []
|
export const rarities = []
|
||||||
export const rarityslot = [0]
|
export const rarityslot = [0]
|
||||||
|
|
||||||
|
export const isPreSwitch: Utils.BooleanHolder = new Utils.BooleanHolder(false);
|
||||||
|
|
||||||
export var StoredLog: DRPD = undefined;
|
export var StoredLog: DRPD = undefined;
|
||||||
|
|
||||||
export const DRPD_Version = "1.0.0"
|
export const DRPD_Version = "1.0.0"
|
||||||
@ -129,13 +180,19 @@ export interface TrainerData {
|
|||||||
type: string,
|
type: string,
|
||||||
}
|
}
|
||||||
export interface ItemData {
|
export interface ItemData {
|
||||||
id: string,
|
id: integer,
|
||||||
name: string,
|
name: string,
|
||||||
quantity: integer,
|
quantity: integer,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Actions = []
|
export const Actions = []
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new document in the DRPD format
|
||||||
|
* @param name (Optional) The name for the file. Defaults to "Untitled Run".
|
||||||
|
* @param authorName (Optional) The author(s) of the file. Defaults to "Write your name here".
|
||||||
|
* @returns The fresh DRPD document.
|
||||||
|
*/
|
||||||
export function newDocument(name: string = "Untitled Run", authorName: string | string[] = "Write your name here"): DRPD {
|
export function newDocument(name: string = "Untitled Run", authorName: string | string[] = "Write your name here"): DRPD {
|
||||||
return {
|
return {
|
||||||
version: DRPD_Version,
|
version: DRPD_Version,
|
||||||
@ -146,9 +203,20 @@ export function newDocument(name: string = "Untitled Run", authorName: string |
|
|||||||
starters: new Array(3),
|
starters: new Array(3),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Imports a string as a DRPD.
|
||||||
|
* @param drpd The JSON string to import.
|
||||||
|
* @returns The imported document.
|
||||||
|
*/
|
||||||
export function importDocument(drpd: string): DRPD {
|
export function importDocument(drpd: string): DRPD {
|
||||||
return JSON.parse(drpd) as DRPD;
|
return JSON.parse(drpd) as DRPD;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Exports a Pokemon's data as `PokeData`.
|
||||||
|
* @param pokemon The Pokemon to store.
|
||||||
|
* @param encounterRarity The rarity tier of the Pokemon for this biome.
|
||||||
|
* @returns The Pokemon data.
|
||||||
|
*/
|
||||||
export function exportPokemon(pokemon: Pokemon, encounterRarity?: string): PokeData {
|
export function exportPokemon(pokemon: Pokemon, encounterRarity?: string): PokeData {
|
||||||
return {
|
return {
|
||||||
id: pokemon.species.speciesId,
|
id: pokemon.species.speciesId,
|
||||||
@ -161,10 +229,15 @@ export function exportPokemon(pokemon: Pokemon, encounterRarity?: string): PokeD
|
|||||||
rarity: encounterRarity,
|
rarity: encounterRarity,
|
||||||
captured: false,
|
captured: false,
|
||||||
level: pokemon.level,
|
level: pokemon.level,
|
||||||
items: pokemon.getHeldItems().map(item => exportItem(item)),
|
items: pokemon.getHeldItems().map((item, idx) => exportItem(item, idx)),
|
||||||
ivs: exportIVs(pokemon.ivs)
|
ivs: exportIVs(pokemon.ivs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Exports a Pokemon's nature as `NatureData`.
|
||||||
|
* @param nature The nature to store.
|
||||||
|
* @returns The nature data.
|
||||||
|
*/
|
||||||
export function exportNature(nature: Nature): NatureData {
|
export function exportNature(nature: Nature): NatureData {
|
||||||
return {
|
return {
|
||||||
name: getNatureName(nature),
|
name: getNatureName(nature),
|
||||||
@ -172,13 +245,23 @@ export function exportNature(nature: Nature): NatureData {
|
|||||||
decreased: getNatureDecrease(nature),
|
decreased: getNatureDecrease(nature),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function exportItem(item: PokemonHeldItemModifier): ItemData {
|
/**
|
||||||
|
* Exports a Held Item as `ItemData`.
|
||||||
|
* @param item The item to store.
|
||||||
|
* @returns The item data.
|
||||||
|
*/
|
||||||
|
export function exportItem(item: PokemonHeldItemModifier, index: integer): ItemData {
|
||||||
return {
|
return {
|
||||||
id: item.type.id,
|
id: index,
|
||||||
name: item.type.name,
|
name: item.type.name,
|
||||||
quantity: item.getStackCount()
|
quantity: item.getStackCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Exports a Pokemon's IVs as `IVData`.
|
||||||
|
* @param ivs The IV array to store.
|
||||||
|
* @returns The IV data.
|
||||||
|
*/
|
||||||
export function exportIVs(ivs: integer[]): IVData {
|
export function exportIVs(ivs: integer[]): IVData {
|
||||||
return {
|
return {
|
||||||
hp: ivs[0],
|
hp: ivs[0],
|
||||||
@ -189,6 +272,11 @@ export function exportIVs(ivs: integer[]): IVData {
|
|||||||
speed: ivs[5]
|
speed: ivs[5]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Exports the current battle as a `Wave`.
|
||||||
|
* @param scene The BattleScene. Used to retrieve information about the current wave.
|
||||||
|
* @returns The wave data.
|
||||||
|
*/
|
||||||
export function exportWave(scene: BattleScene): Wave {
|
export function exportWave(scene: BattleScene): Wave {
|
||||||
var ret: Wave = {
|
var ret: Wave = {
|
||||||
id: scene.currentBattle.waveIndex,
|
id: scene.currentBattle.waveIndex,
|
||||||
@ -221,6 +309,11 @@ export function exportWave(scene: BattleScene): Wave {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Exports the opposing trainer as `TrainerData`.
|
||||||
|
* @param trainer The Trainer to store.
|
||||||
|
* @returns The Trainer data.
|
||||||
|
*/
|
||||||
export function exportTrainer(trainer: Trainer): TrainerData {
|
export function exportTrainer(trainer: Trainer): TrainerData {
|
||||||
if (trainer.config.getTitle(0, trainer.variant) == "Finn") {
|
if (trainer.config.getTitle(0, trainer.variant) == "Finn") {
|
||||||
return {
|
return {
|
||||||
@ -255,6 +348,12 @@ export function getSize(str: string) {
|
|||||||
return d.toString() + filesizes[unit]
|
return d.toString() + filesizes[unit]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a UI option to save a log to your device.
|
||||||
|
* @param i The slot number. Corresponds to an index in `logs`.
|
||||||
|
* @param saves Your session data. Used to label logs if they match one of your save slots.
|
||||||
|
* @returns A UI option.
|
||||||
|
*/
|
||||||
export function generateOption(i: integer, saves: any): OptionSelectItem {
|
export function generateOption(i: integer, saves: any): OptionSelectItem {
|
||||||
var filename: string = (JSON.parse(localStorage.getItem(logs[i][1])) as DRPD).title
|
var filename: string = (JSON.parse(localStorage.getItem(logs[i][1])) as DRPD).title
|
||||||
var op: OptionSelectItem = {
|
var op: OptionSelectItem = {
|
||||||
@ -267,7 +366,7 @@ export function generateOption(i: integer, saves: any): OptionSelectItem {
|
|||||||
for (var j = 0; j < saves.length; j++) {
|
for (var j = 0; j < saves.length; j++) {
|
||||||
console.log(saves[j].seed, logs[i][2], saves[j].seed == logs[i][2])
|
console.log(saves[j].seed, logs[i][2], saves[j].seed == logs[i][2])
|
||||||
if (saves[j].seed == logs[i][2]) {
|
if (saves[j].seed == logs[i][2]) {
|
||||||
op.label = "[Slot " + (j + 1) + "]" + op.label.substring(6)
|
op.label = "[Slot " + (saves[j].slot + 1) + "]" + op.label.substring(6)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (logs[i][4] != "") {
|
if (logs[i][4] != "") {
|
||||||
@ -276,6 +375,18 @@ export function generateOption(i: integer, saves: any): OptionSelectItem {
|
|||||||
}
|
}
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Generates an option to create a new log.
|
||||||
|
*
|
||||||
|
* Not used.
|
||||||
|
* @param i The slot number. Corresponds to an index in `logs`.
|
||||||
|
* @param scene The current scene. Not used.
|
||||||
|
* @param o The current game phase. Used to return to the previous menu. Not necessary anymore lol
|
||||||
|
* @returns A UI option.
|
||||||
|
*
|
||||||
|
* wow this function sucks
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export function generateAddOption(i: integer, scene: BattleScene, o: TitlePhase) {
|
export function generateAddOption(i: integer, scene: BattleScene, o: TitlePhase) {
|
||||||
var op: OptionSelectItem = {
|
var op: OptionSelectItem = {
|
||||||
label: "Generate log " + logs[i][0],
|
label: "Generate log " + logs[i][0],
|
||||||
@ -314,7 +425,7 @@ export function clearLog(keyword: string) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Saves a log to your device.
|
* Saves a log to your device.
|
||||||
* @param keyword The identifier key for the log you want to reste
|
* @param keyword The identifier key for the log you want to save.
|
||||||
*/
|
*/
|
||||||
export function downloadLog(keyword: string) {
|
export function downloadLog(keyword: string) {
|
||||||
var d = JSON.parse(localStorage.getItem(logs[logKeys.indexOf(keyword)][1]))
|
var d = JSON.parse(localStorage.getItem(logs[logKeys.indexOf(keyword)][1]))
|
||||||
@ -327,6 +438,10 @@ export function downloadLog(keyword: string) {
|
|||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Saves a log to your device.
|
||||||
|
* @param i The index of the log you want to save.
|
||||||
|
*/
|
||||||
export function downloadLogByID(i: integer) {
|
export function downloadLogByID(i: integer) {
|
||||||
console.log(i)
|
console.log(i)
|
||||||
var d = JSON.parse(localStorage.getItem(logs[i][1]))
|
var d = JSON.parse(localStorage.getItem(logs[i][1]))
|
||||||
@ -339,6 +454,11 @@ export function downloadLogByID(i: integer) {
|
|||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Calls `logPokemon` once for each opponent or, if it's a trainer battle, logs the trainer's data.
|
||||||
|
* @param scene The BattleScene. Used to get the enemy team and whether it's a trainer battle or not.
|
||||||
|
* @param floor The wave index to write to. Defaults to the current wave.
|
||||||
|
*/
|
||||||
export function logTeam(scene: BattleScene, floor: integer = undefined) {
|
export function logTeam(scene: BattleScene, floor: integer = undefined) {
|
||||||
if (floor == undefined) floor = scene.currentBattle.waveIndex
|
if (floor == undefined) floor = scene.currentBattle.waveIndex
|
||||||
var team = scene.getEnemyParty()
|
var team = scene.getEnemyParty()
|
||||||
@ -356,6 +476,14 @@ export function logTeam(scene: BattleScene, floor: integer = undefined) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Logs the actions that the player took.
|
||||||
|
*
|
||||||
|
* This includes attacks you perform, items you transfer during the shop, Poke Balls you throw, running from battl, (or attempting to), and switching (including pre-switches).
|
||||||
|
* @param scene The BattleScene. Used to get the log ID.
|
||||||
|
* @param floor The wave index to write to.
|
||||||
|
* @param action The text you want to add to the actions list.
|
||||||
|
*/
|
||||||
export function logActions(scene: BattleScene, floor: integer, action: string) {
|
export function logActions(scene: BattleScene, floor: integer, action: string) {
|
||||||
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
||||||
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
||||||
@ -365,6 +493,12 @@ export function logActions(scene: BattleScene, floor: integer, action: string) {
|
|||||||
console.log(drpd)
|
console.log(drpd)
|
||||||
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Logs what the player took from the rewards pool and, if applicable, who they used it on.
|
||||||
|
* @param scene The BattleScene. Used to get the log ID.
|
||||||
|
* @param floor The wave index to write to.
|
||||||
|
* @param action The shop action. Left blank if there was no shop this floor or if you ran away. Logged as "Skip taking items" if you didn't take anything for some reason.
|
||||||
|
*/
|
||||||
export function logShop(scene: BattleScene, floor: integer, action: string) {
|
export function logShop(scene: BattleScene, floor: integer, action: string) {
|
||||||
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
||||||
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
||||||
@ -374,31 +508,24 @@ export function logShop(scene: BattleScene, floor: integer, action: string) {
|
|||||||
console.log(drpd)
|
console.log(drpd)
|
||||||
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
||||||
}
|
}
|
||||||
export function getWave(drpd: DRPD, floor: integer, scene: BattleScene) {
|
/**
|
||||||
|
* Retrieves a wave from the DRPD. If the wave doesn't exist, it creates a new one.
|
||||||
|
* @param drpd The document to read from.
|
||||||
|
* @param floor The wave index to retrieve.
|
||||||
|
* @param scene The BattleScene, used for creating a new wave
|
||||||
|
* @returns The requested `Wave`.
|
||||||
|
*/
|
||||||
|
export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
|
||||||
var wv: Wave;
|
var wv: Wave;
|
||||||
var insertPos: integer;
|
var insertPos: integer;
|
||||||
console.log(drpd.waves)
|
console.log(drpd.waves)
|
||||||
if (drpd.waves[floor - 1] != undefined) {
|
|
||||||
return drpd.waves[floor - 1]
|
|
||||||
}
|
|
||||||
drpd.waves[floor - 1] = {
|
|
||||||
id: floor,
|
|
||||||
reload: false,
|
|
||||||
//type: floor % 10 == 0 ? "boss" : (floor % 10 == 5 ? "trainer" : "wild"),
|
|
||||||
type: floor % 10 == 0 ? "boss" : "wild",
|
|
||||||
double: scene.currentBattle.double,
|
|
||||||
actions: [],
|
|
||||||
shop: "",
|
|
||||||
biome: getBiomeName(scene.arena.biomeType),
|
|
||||||
pokemon: []
|
|
||||||
}
|
|
||||||
return drpd.waves[floor - 1]
|
|
||||||
for (var i = 0; i < drpd.waves.length; i++) {
|
for (var i = 0; i < drpd.waves.length; i++) {
|
||||||
if (drpd.waves[i] != undefined && drpd.waves[i] != null) {
|
if (drpd.waves[i] != undefined && drpd.waves[i] != null) {
|
||||||
if (drpd.waves[i].id == floor) {
|
if (drpd.waves[i].id == floor) {
|
||||||
wv = drpd.waves[i]
|
wv = drpd.waves[i]
|
||||||
console.log("Found wave for floor " + floor + " at index " + i)
|
console.log("Found wave for floor " + floor + " at index " + i)
|
||||||
if (wv.pokemon == undefined) wv.pokemon = []
|
if (wv.pokemon == undefined) wv.pokemon = []
|
||||||
|
return wv;
|
||||||
}
|
}
|
||||||
} else if (insertPos == undefined) {
|
} else if (insertPos == undefined) {
|
||||||
insertPos = i
|
insertPos = i
|
||||||
@ -489,14 +616,28 @@ export function getWave(drpd: DRPD, floor: integer, scene: BattleScene) {
|
|||||||
})
|
})
|
||||||
if (wv == undefined) {
|
if (wv == undefined) {
|
||||||
scene.ui.showText("Failed to make space\nPress F12 for info")
|
scene.ui.showText("Failed to make space\nPress F12 for info")
|
||||||
console.error("There should be space to store a new wave, but the program failed to find space anyways")
|
console.error("There should be space to store a new wave, but the program failed to find space anyways")
|
||||||
console.error("Go yell at @redstonewolf8557 to fix this")
|
console.error("Go yell at @redstonewolf8557 to fix this")
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (wv == undefined) {
|
||||||
|
scene.ui.showText("Failed to retrieve wave\nPress F12 for info")
|
||||||
|
console.error("Failed to retrieve wave??")
|
||||||
|
console.error("this mod i stg")
|
||||||
|
console.error("Go yell at @redstonewolf8557 to fix this")
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return wv;
|
return wv;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Compares a Species to a biome's tier pool.
|
||||||
|
* @param species The species to search for.
|
||||||
|
* @param pool The SpeciesPool tier to compare.
|
||||||
|
* @returns whether or not `species` was found in the `pool`.
|
||||||
|
*/
|
||||||
function checkForPokeInBiome(species: Species, pool: (Species | SpeciesTree)[]): boolean {
|
function checkForPokeInBiome(species: Species, pool: (Species | SpeciesTree)[]): boolean {
|
||||||
//console.log(species, pool)
|
//console.log(species, pool)
|
||||||
for (var i = 0; i < pool.length; i++) {
|
for (var i = 0; i < pool.length; i++) {
|
||||||
@ -514,38 +655,16 @@ function checkForPokeInBiome(species: Species, pool: (Species | SpeciesTree)[]):
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Logs a wild Pokemon to a wave's data.
|
||||||
|
* @param scene The BattleScene. Used to retrieve the log ID.
|
||||||
|
* @param floor The wave index to write to. Defaults to the current floor.
|
||||||
|
* @param slot The slot to write to. In a single battle, 0 = the Pokemon that is out first. In a double battle, 0 = Left and 1 = Right.
|
||||||
|
* @param pokemon The `EnemyPokemon` to store the data of. (Automatically converted via `exportPokemon`)
|
||||||
|
* @param encounterRarity The rarity tier of this Pokemon. If not specified, it calculates this automatically by searching the current biome's species pool.
|
||||||
|
*/
|
||||||
export function logPokemon(scene: BattleScene, floor: integer = undefined, slot: integer, pokemon: EnemyPokemon, encounterRarity?: string) {
|
export function logPokemon(scene: BattleScene, floor: integer = undefined, slot: integer, pokemon: EnemyPokemon, encounterRarity?: string) {
|
||||||
if (floor == undefined) floor = scene.currentBattle.waveIndex
|
if (floor == undefined) floor = scene.currentBattle.waveIndex
|
||||||
/*
|
|
||||||
var modifiers: string[] = []
|
|
||||||
var mods = pokemon.getHeldItems()
|
|
||||||
for (var i = 0; i < mods.length; i++) {
|
|
||||||
modifiers.push(mods[i].type.name + (mods[i].getMaxStackCount(scene) == 1 ? "" : " x" + mods[i].getStackCount()))
|
|
||||||
}
|
|
||||||
var sprite = pokemon.getBattleSpriteAtlasPath()
|
|
||||||
// floor,party slot,encounter,species,ability,passive,level,gender,isBoss,nature,HP IV,Attack IV,Defense IV,Sp. Atk IV,Sp. Def IV,Speed IV,Items separated by slashes /
|
|
||||||
var newLine = floor + ","
|
|
||||||
+ slot + ","
|
|
||||||
+ sprite + ","
|
|
||||||
+ (pokemon.hasTrainer() ? "trainer_pokemon" : "wild") + ","
|
|
||||||
+ pokemon.species.getName(pokemon.formIndex) + (pokemon.getFormKey() == "" ? "" : " (" + pokemon.getFormKey() + ")") + ","
|
|
||||||
+ pokemon.getAbility().name.toLowerCase() + ","
|
|
||||||
+ pokemon.getPassiveAbility().name.toLowerCase() + ","
|
|
||||||
+ pokemon.level + ","
|
|
||||||
+ (pokemon.gender == 0 ? "M" : (pokemon.gender == 1 ? "F" : "")) + ","
|
|
||||||
+ (pokemon.isBoss() ? "true" : "false") + ","
|
|
||||||
+ getNatureName(pokemon.nature) + ","
|
|
||||||
+ pokemon.ivs[0] + ","
|
|
||||||
+ pokemon.ivs[1] + ","
|
|
||||||
+ pokemon.ivs[2] + ","
|
|
||||||
+ pokemon.ivs[3] + ","
|
|
||||||
+ pokemon.ivs[4] + ","
|
|
||||||
+ pokemon.ivs[5] + ","
|
|
||||||
+ modifiers.join("/")
|
|
||||||
//console.log(idx, data.slice(0, idx), newLine, data.slice(idx))
|
|
||||||
setRow("e", newLine, floor, slot)
|
|
||||||
//console.log(localStorage.getItem(logs[logKeys.indexOf("e")][1]).split("\n"))
|
|
||||||
*/
|
|
||||||
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
||||||
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
||||||
console.log("Log Enemy Pokemon", drpd)
|
console.log("Log Enemy Pokemon", drpd)
|
||||||
@ -563,10 +682,10 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
|
|||||||
"Rare",
|
"Rare",
|
||||||
"Super Rare",
|
"Super Rare",
|
||||||
"Ultra Rare",
|
"Ultra Rare",
|
||||||
"Common",
|
"Common Boss",
|
||||||
"Rare",
|
"Rare Boss",
|
||||||
"Super Rare",
|
"Super Rare Boss",
|
||||||
"Ultra Rare",
|
"Ultra Rare Boss",
|
||||||
]
|
]
|
||||||
for (var i = 0; i < tiernames.length; i++) {
|
for (var i = 0; i < tiernames.length; i++) {
|
||||||
if (checkForPokeInBiome(wv.pokemon[slot].id, scene.arena.pokemonPool[i]) == true) {
|
if (checkForPokeInBiome(wv.pokemon[slot].id, scene.arena.pokemonPool[i]) == true) {
|
||||||
@ -590,10 +709,10 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
|
|||||||
"Rare",
|
"Rare",
|
||||||
"Super Rare",
|
"Super Rare",
|
||||||
"Ultra Rare",
|
"Ultra Rare",
|
||||||
"Common",
|
"Common Boss",
|
||||||
"Rare",
|
"Rare Boss",
|
||||||
"Super Rare",
|
"Super Rare Boss",
|
||||||
"Ultra Rare",
|
"Ultra Rare Boss",
|
||||||
]
|
]
|
||||||
for (var i = 0; i < tiernames.length; i++) {
|
for (var i = 0; i < tiernames.length; i++) {
|
||||||
if (wv.pokemon[slot] != undefined)
|
if (wv.pokemon[slot] != undefined)
|
||||||
@ -603,14 +722,38 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pk.rarity == undefined) pk.rarity = "[Unknown]"
|
if (pk.rarity == undefined)
|
||||||
|
pk.rarity = "[Unknown]"
|
||||||
wv.pokemon[slot] = pk;
|
wv.pokemon[slot] = pk;
|
||||||
while (wv.actions.length > 0)
|
while (wv.actions.length > 0)
|
||||||
wv.actions.pop()
|
wv.actions.pop()
|
||||||
|
wv.actions = []
|
||||||
|
wv.shop = ""
|
||||||
console.log(drpd)
|
console.log(drpd)
|
||||||
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Clears the action list for a wave.
|
||||||
|
* @param scene The BattleScene. Used to get the log ID and trainer data.
|
||||||
|
* @param floor The wave index to write to. Defaults to the current floor.
|
||||||
|
*/
|
||||||
|
export function resetWaveActions(scene: BattleScene, floor: integer = undefined) {
|
||||||
|
if (floor == undefined) floor = scene.currentBattle.waveIndex
|
||||||
|
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
||||||
|
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
||||||
|
console.log("Clear Actions", drpd)
|
||||||
|
var wv: Wave = getWave(drpd, floor, scene)
|
||||||
|
wv.actions = []
|
||||||
|
console.log(drpd, wv)
|
||||||
|
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Logs the current floor's Trainer.
|
||||||
|
* @param scene The BattleScene. Used to get the log ID and trainer data.
|
||||||
|
* @param floor The wave index to write to. Defaults to the current floor.
|
||||||
|
*/
|
||||||
export function logTrainer(scene: BattleScene, floor: integer = undefined) {
|
export function logTrainer(scene: BattleScene, floor: integer = undefined) {
|
||||||
|
if (floor == undefined) floor = scene.currentBattle.waveIndex
|
||||||
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
||||||
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
||||||
console.log("Log Trainer", drpd)
|
console.log("Log Trainer", drpd)
|
||||||
@ -621,6 +764,12 @@ export function logTrainer(scene: BattleScene, floor: integer = undefined) {
|
|||||||
console.log(drpd)
|
console.log(drpd)
|
||||||
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Logs the player's current party.
|
||||||
|
*
|
||||||
|
* Called on Floor 1 to store the starters list.
|
||||||
|
* @param scene The BattleScene. Used to get the log ID and the player's party.
|
||||||
|
*/
|
||||||
export function logPlayerTeam(scene: BattleScene) {
|
export function logPlayerTeam(scene: BattleScene) {
|
||||||
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
|
||||||
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
|
||||||
@ -633,7 +782,12 @@ export function logPlayerTeam(scene: BattleScene) {
|
|||||||
console.log(drpd)
|
console.log(drpd)
|
||||||
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* A sort function, used to sort csv columns.
|
||||||
|
*
|
||||||
|
* No longer used as we are using .json format instead.
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export function dataSorter(a: string, b: string) {
|
export function dataSorter(a: string, b: string) {
|
||||||
var da = a.split(",")
|
var da = a.split(",")
|
||||||
var db = b.split(",")
|
var db = b.split(",")
|
||||||
@ -648,6 +802,16 @@ export function dataSorter(a: string, b: string) {
|
|||||||
}
|
}
|
||||||
return ((da[0] as any) * 1) - ((db[0] as any) * 1)
|
return ((da[0] as any) * 1) - ((db[0] as any) * 1)
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Writes or replaces a csv row.
|
||||||
|
*
|
||||||
|
* No longer used as we are using .json format instead.
|
||||||
|
* @param keyword The keyword/ID of the log to write to.
|
||||||
|
* @param newLine The data to write.
|
||||||
|
* @param floor The floor to write to. Used for sorting.
|
||||||
|
* @param slot The slot to write to. Used for sorting.
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export function setRow(keyword: string, newLine: string, floor: integer, slot: integer) {
|
export function setRow(keyword: string, newLine: string, floor: integer, slot: integer) {
|
||||||
var data = localStorage.getItem(logs[logKeys.indexOf(keyword)][1]).split("\n")
|
var data = localStorage.getItem(logs[logKeys.indexOf(keyword)][1]).split("\n")
|
||||||
data.sort(dataSorter)
|
data.sort(dataSorter)
|
||||||
@ -713,27 +877,49 @@ export function setRow(keyword: string, newLine: string, floor: integer, slot: i
|
|||||||
}
|
}
|
||||||
localStorage.setItem(logs[logKeys.indexOf(keyword)][1], data.slice(0, idx).join("\n") + "\n" + newLine + (data.slice(idx).length == 0 ? "" : "\n") + data.slice(idx).join("\n"));
|
localStorage.setItem(logs[logKeys.indexOf(keyword)][1], data.slice(0, idx).join("\n") + "\n" + newLine + (data.slice(idx).length == 0 ? "" : "\n") + data.slice(idx).join("\n"));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints a DRPD as a string, for saving it to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param drpd The `DRPD` to export.
|
||||||
|
* @returns `inData`, with all the DRPD's data appended to it.
|
||||||
|
*
|
||||||
|
* @see printWave
|
||||||
|
*/
|
||||||
export function printDRPD(inData: string, indent: string, drpd: DRPD): string {
|
export function printDRPD(inData: string, indent: string, drpd: DRPD): string {
|
||||||
inData += indent + "{"
|
inData += indent + "{"
|
||||||
inData += "\n" + indent + " \"version\": \"" + drpd.version + "\""
|
inData += "\n" + indent + " \"version\": \"" + drpd.version + "\""
|
||||||
inData += ",\n" + indent + " \"title\": \"" + drpd.title + "\""
|
inData += ",\n" + indent + " \"title\": \"" + drpd.title + "\""
|
||||||
inData += ",\n" + indent + " \"authors\": [\"" + drpd.authors.join("\", \"") + "\"]"
|
inData += ",\n" + indent + " \"authors\": [\"" + drpd.authors.join("\", \"") + "\"]"
|
||||||
inData += ",\n" + indent + " \"date\": \"" + drpd.date + "\""
|
inData += ",\n" + indent + " \"date\": \"" + drpd.date + "\""
|
||||||
inData += ",\n" + indent + " \"waves\": [\n"
|
if (drpd.waves) {
|
||||||
var isFirst = true
|
inData += ",\n" + indent + " \"waves\": [\n"
|
||||||
for (var i = 0; i < drpd.waves.length; i++) {
|
var isFirst = true
|
||||||
if (drpd.waves[i] != undefined) {
|
for (var i = 0; i < drpd.waves.length; i++) {
|
||||||
if (isFirst) {
|
if (drpd.waves[i] != undefined && drpd.waves[i] != null) {
|
||||||
isFirst = false;
|
if (isFirst) {
|
||||||
} else {
|
isFirst = false;
|
||||||
inData += ",\n"
|
} else {
|
||||||
|
inData += ",\n"
|
||||||
|
}
|
||||||
|
inData = printWave(inData, indent + " ", drpd.waves[i])
|
||||||
}
|
}
|
||||||
inData = printWave(inData, indent + " ", drpd.waves[i])
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
inData += ",\n" + indent + " \"waves\": []"
|
||||||
}
|
}
|
||||||
inData += "\n" + indent + " ]\n" + indent + "}"
|
inData += "\n" + indent + " ]\n" + indent + "}"
|
||||||
return inData;
|
return inData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints a wave as a string, for saving a DRPD to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param wave The `Wave` to export.
|
||||||
|
* @returns `inData`, with all the wave's data appended to it.
|
||||||
|
*
|
||||||
|
* @see printDRPD
|
||||||
|
*/
|
||||||
function printWave(inData: string, indent: string, wave: Wave): string {
|
function printWave(inData: string, indent: string, wave: Wave): string {
|
||||||
inData += indent + "{"
|
inData += indent + "{"
|
||||||
inData += "\n" + indent + " \"id\": " + wave.id + ""
|
inData += "\n" + indent + " \"id\": " + wave.id + ""
|
||||||
@ -764,24 +950,34 @@ function printWave(inData: string, indent: string, wave: Wave): string {
|
|||||||
inData += ",\n " + indent + "\"trainer\": "
|
inData += ",\n " + indent + "\"trainer\": "
|
||||||
inData = printTrainer(inData, indent + " ", wave.trainer)
|
inData = printTrainer(inData, indent + " ", wave.trainer)
|
||||||
}
|
}
|
||||||
if (wave.pokemon.length > 0) {
|
if (wave.pokemon)
|
||||||
inData += ",\n " + indent + "\"pokemon\": [\n"
|
if (wave.pokemon.length > 0) {
|
||||||
isFirst = true
|
inData += ",\n " + indent + "\"pokemon\": [\n"
|
||||||
for (var i = 0; i < wave.pokemon.length; i++) {
|
isFirst = true
|
||||||
if (wave.pokemon[i] != undefined) {
|
for (var i = 0; i < wave.pokemon.length; i++) {
|
||||||
if (isFirst) {
|
if (wave.pokemon[i] != undefined) {
|
||||||
isFirst = false;
|
if (isFirst) {
|
||||||
} else {
|
isFirst = false;
|
||||||
inData += ",\n"
|
} else {
|
||||||
|
inData += ",\n"
|
||||||
|
}
|
||||||
|
inData = printPoke(inData, indent + " ", wave.pokemon[i])
|
||||||
}
|
}
|
||||||
inData = printPoke(inData, indent + " ", wave.pokemon[i])
|
|
||||||
}
|
}
|
||||||
|
inData += "\n" + indent + " ]"
|
||||||
}
|
}
|
||||||
inData += "\n" + indent + " ]"
|
|
||||||
}
|
|
||||||
inData += "\n" + indent + "}"
|
inData += "\n" + indent + "}"
|
||||||
return inData;
|
return inData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints a Pokemon as a string, for saving a DRPD to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param wave The `PokeData` to export.
|
||||||
|
* @returns `inData`, with all the Pokemon's data appended to it.
|
||||||
|
*
|
||||||
|
* @see printDRPD
|
||||||
|
*/
|
||||||
function printPoke(inData: string, indent: string, pokemon: PokeData) {
|
function printPoke(inData: string, indent: string, pokemon: PokeData) {
|
||||||
inData += indent + "{"
|
inData += indent + "{"
|
||||||
inData += "\n" + indent + " \"id\": " + pokemon.id
|
inData += "\n" + indent + " \"id\": " + pokemon.id
|
||||||
@ -819,6 +1015,15 @@ function printPoke(inData: string, indent: string, pokemon: PokeData) {
|
|||||||
inData += "\n" + indent + "}"
|
inData += "\n" + indent + "}"
|
||||||
return inData;
|
return inData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints a Nature as a string, for saving a DRPD to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param wave The `NatureData` to export.
|
||||||
|
* @returns `inData`, with all the nature data appended to it.
|
||||||
|
*
|
||||||
|
* @see printDRPD
|
||||||
|
*/
|
||||||
function printNature(inData: string, indent: string, nature: NatureData) {
|
function printNature(inData: string, indent: string, nature: NatureData) {
|
||||||
inData += indent + "{"
|
inData += indent + "{"
|
||||||
inData += "\n" + indent + " \"name\": \"" + nature.name + "\""
|
inData += "\n" + indent + " \"name\": \"" + nature.name + "\""
|
||||||
@ -827,6 +1032,15 @@ function printNature(inData: string, indent: string, nature: NatureData) {
|
|||||||
inData += "\n" + indent + "}"
|
inData += "\n" + indent + "}"
|
||||||
return inData;
|
return inData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints a Pokemon's IV data as a string, for saving a DRPD to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param wave The `IVData` to export.
|
||||||
|
* @returns `inData`, with the IV data appended to it.
|
||||||
|
*
|
||||||
|
* @see printDRPD
|
||||||
|
*/
|
||||||
function printIV(inData: string, indent: string, iv: IVData) {
|
function printIV(inData: string, indent: string, iv: IVData) {
|
||||||
inData += "{"
|
inData += "{"
|
||||||
inData += "\n" + indent + " \"hp\": " + iv.hp
|
inData += "\n" + indent + " \"hp\": " + iv.hp
|
||||||
@ -838,6 +1052,15 @@ function printIV(inData: string, indent: string, iv: IVData) {
|
|||||||
inData += "\n" + indent + "}"
|
inData += "\n" + indent + "}"
|
||||||
return inData;
|
return inData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints a Trainer as a string, for saving a DRPD to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param wave The `TrainerData` to export.
|
||||||
|
* @returns `inData`, with all the Trainer's data appended to it.
|
||||||
|
*
|
||||||
|
* @see printDRPD
|
||||||
|
*/
|
||||||
function printTrainer(inData: string, indent: string, trainer: TrainerData) {
|
function printTrainer(inData: string, indent: string, trainer: TrainerData) {
|
||||||
inData += "{"
|
inData += "{"
|
||||||
inData += "\n" + indent + " \"id\": \"" + trainer.id + "\""
|
inData += "\n" + indent + " \"id\": \"" + trainer.id + "\""
|
||||||
@ -846,6 +1069,15 @@ function printTrainer(inData: string, indent: string, trainer: TrainerData) {
|
|||||||
inData += "\n" + indent + "}"
|
inData += "\n" + indent + "}"
|
||||||
return inData;
|
return inData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Prints an item as a string, for saving a DRPD to your device.
|
||||||
|
* @param inData The data to add on to.
|
||||||
|
* @param indent The indent string (just a bunch of spaces).
|
||||||
|
* @param wave The `ItemData` to export.
|
||||||
|
* @returns `inData`, with all the Item's data appended to it.
|
||||||
|
*
|
||||||
|
* @see printDRPD
|
||||||
|
*/
|
||||||
function printItem(inData: string, indent: string, item: ItemData) {
|
function printItem(inData: string, indent: string, item: ItemData) {
|
||||||
inData += indent + "{"
|
inData += indent + "{"
|
||||||
inData += "\n" + indent + " \"id\": \"" + item.id + "\""
|
inData += "\n" + indent + " \"id\": \"" + item.id + "\""
|
||||||
|
@ -64,6 +64,10 @@ export class ModifierType {
|
|||||||
return i18next.t(`${this.localeKey}.name` as any);
|
return i18next.t(`${this.localeKey}.name` as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Modifier:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t(`${this.localeKey}.description` as any);
|
return i18next.t(`${this.localeKey}.description` as any);
|
||||||
}
|
}
|
||||||
@ -159,6 +163,9 @@ class AddPokeballModifierType extends ModifierType {
|
|||||||
"pokeballName": getPokeballName(this.pokeballType),
|
"pokeballName": getPokeballName(this.pokeballType),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
get identifier(): string {
|
||||||
|
return "PokeballModifier:" + Utils.getEnumKeys(PokeballType)[this.pokeballType];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.AddPokeballModifierType.description", {
|
return i18next.t("modifierType:ModifierType.AddPokeballModifierType.description", {
|
||||||
@ -198,6 +205,10 @@ class AddVoucherModifierType extends ModifierType {
|
|||||||
export class PokemonModifierType extends ModifierType {
|
export class PokemonModifierType extends ModifierType {
|
||||||
public selectFilter: PokemonSelectFilter;
|
public selectFilter: PokemonSelectFilter;
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "PokemonModifier:undefined";
|
||||||
|
}
|
||||||
|
|
||||||
constructor(localeKey: string, iconImage: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, group?: string, soundName?: string) {
|
constructor(localeKey: string, iconImage: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, group?: string, soundName?: string) {
|
||||||
super(localeKey, iconImage, newModifierFunc, group, soundName);
|
super(localeKey, iconImage, newModifierFunc, group, soundName);
|
||||||
|
|
||||||
@ -221,6 +232,10 @@ export class PokemonHeldItemModifierType extends PokemonModifierType {
|
|||||||
}, group, soundName);
|
}, group, soundName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "HeldItem:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
newModifier(...args: any[]): Modifiers.PokemonHeldItemModifier {
|
newModifier(...args: any[]): Modifiers.PokemonHeldItemModifier {
|
||||||
return super.newModifier(...args) as Modifiers.PokemonHeldItemModifier;
|
return super.newModifier(...args) as Modifiers.PokemonHeldItemModifier;
|
||||||
}
|
}
|
||||||
@ -245,6 +260,10 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType {
|
|||||||
this.healStatus = healStatus;
|
this.healStatus = healStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "HpRestore:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return this.restorePoints
|
return this.restorePoints
|
||||||
? i18next.t("modifierType:ModifierType.PokemonHpRestoreModifierType.description", {
|
? i18next.t("modifierType:ModifierType.PokemonHpRestoreModifierType.description", {
|
||||||
@ -274,6 +293,9 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
get identifier(): string {
|
||||||
|
return "Revive:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonReviveModifierType.description", { restorePercent: this.restorePercent });
|
return i18next.t("modifierType:ModifierType.PokemonReviveModifierType.description", { restorePercent: this.restorePercent });
|
||||||
@ -291,6 +313,10 @@ export class PokemonStatusHealModifierType extends PokemonModifierType {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "StatusCure:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonStatusHealModifierType.description");
|
return i18next.t("modifierType:ModifierType.PokemonStatusHealModifierType.description");
|
||||||
}
|
}
|
||||||
@ -323,6 +349,10 @@ export class PokemonPpRestoreModifierType extends PokemonMoveModifierType {
|
|||||||
this.restorePoints = restorePoints;
|
this.restorePoints = restorePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "PpRestore:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return this.restorePoints > -1
|
return this.restorePoints > -1
|
||||||
? i18next.t("modifierType:ModifierType.PokemonPpRestoreModifierType.description", { restorePoints: this.restorePoints })
|
? i18next.t("modifierType:ModifierType.PokemonPpRestoreModifierType.description", { restorePoints: this.restorePoints })
|
||||||
@ -346,6 +376,10 @@ export class PokemonAllMovePpRestoreModifierType extends PokemonModifierType {
|
|||||||
this.restorePoints = restorePoints;
|
this.restorePoints = restorePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "PpAllRestore:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return this.restorePoints > -1
|
return this.restorePoints > -1
|
||||||
? i18next.t("modifierType:ModifierType.PokemonAllMovePpRestoreModifierType.description", { restorePoints: this.restorePoints })
|
? i18next.t("modifierType:ModifierType.PokemonAllMovePpRestoreModifierType.description", { restorePoints: this.restorePoints })
|
||||||
@ -371,6 +405,10 @@ export class PokemonPpUpModifierType extends PokemonMoveModifierType {
|
|||||||
this.upPoints = upPoints;
|
this.upPoints = upPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "PpBooster:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonPpUpModifierType.description", { upPoints: this.upPoints });
|
return i18next.t("modifierType:ModifierType.PokemonPpUpModifierType.description", { upPoints: this.upPoints });
|
||||||
}
|
}
|
||||||
@ -395,6 +433,10 @@ export class PokemonNatureChangeModifierType extends PokemonModifierType {
|
|||||||
return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.name", { natureName: getNatureName(this.nature) });
|
return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.name", { natureName: getNatureName(this.nature) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Mint:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.description", { natureName: getNatureName(this.nature, true, true, true) });
|
return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.description", { natureName: getNatureName(this.nature, true, true, true) });
|
||||||
}
|
}
|
||||||
@ -410,6 +452,10 @@ export class RememberMoveModifierType extends PokemonModifierType {
|
|||||||
return null;
|
return null;
|
||||||
}, group);
|
}, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "MemoryMushroom:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DoubleBattleChanceBoosterModifierType extends ModifierType {
|
export class DoubleBattleChanceBoosterModifierType extends ModifierType {
|
||||||
@ -421,6 +467,10 @@ export class DoubleBattleChanceBoosterModifierType extends ModifierType {
|
|||||||
this.battleCount = battleCount;
|
this.battleCount = battleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "DoubleModifier:" + this.localeKey.split(".")[1];
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.DoubleBattleChanceBoosterModifierType.description", { battleCount: this.battleCount });
|
return i18next.t("modifierType:ModifierType.DoubleBattleChanceBoosterModifierType.description", { battleCount: this.battleCount });
|
||||||
}
|
}
|
||||||
@ -440,6 +490,10 @@ export class TempBattleStatBoosterModifierType extends ModifierType implements G
|
|||||||
return i18next.t(`modifierType:TempBattleStatBoosterItem.${getTempBattleStatBoosterItemName(this.tempBattleStat).replace(/\./g, "").replace(/[ ]/g, "_").toLowerCase()}`);
|
return i18next.t(`modifierType:TempBattleStatBoosterItem.${getTempBattleStatBoosterItemName(this.tempBattleStat).replace(/\./g, "").replace(/[ ]/g, "_").toLowerCase()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "TempStatBooster:" + Utils.getEnumKeys(TempBattleStat)[this.tempBattleStat]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.TempBattleStatBoosterModifierType.description", { tempBattleStatName: getTempBattleStatName(this.tempBattleStat) });
|
return i18next.t("modifierType:ModifierType.TempBattleStatBoosterModifierType.description", { tempBattleStatName: getTempBattleStatName(this.tempBattleStat) });
|
||||||
}
|
}
|
||||||
@ -462,6 +516,10 @@ export class BerryModifierType extends PokemonHeldItemModifierType implements Ge
|
|||||||
return getBerryName(this.berryType);
|
return getBerryName(this.berryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Berry:" + Utils.getEnumKeys(BerryType)[this.berryType]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return getBerryEffectDescription(this.berryType);
|
return getBerryEffectDescription(this.berryType);
|
||||||
}
|
}
|
||||||
@ -528,6 +586,10 @@ export class AttackTypeBoosterModifierType extends PokemonHeldItemModifierType i
|
|||||||
return i18next.t(`modifierType:AttackTypeBoosterItem.${getAttackTypeBoosterItemName(this.moveType).replace(/[ \-]/g, "_").toLowerCase()}`);
|
return i18next.t(`modifierType:AttackTypeBoosterItem.${getAttackTypeBoosterItemName(this.moveType).replace(/[ \-]/g, "_").toLowerCase()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "MoveBooster:" + Utils.getEnumKeys(Type)[this.moveType]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
// TODO: Need getTypeName?
|
// TODO: Need getTypeName?
|
||||||
return i18next.t("modifierType:ModifierType.AttackTypeBoosterModifierType.description", { moveType: i18next.t(`pokemonInfo:Type.${Type[this.moveType]}`) });
|
return i18next.t("modifierType:ModifierType.AttackTypeBoosterModifierType.description", { moveType: i18next.t(`pokemonInfo:Type.${Type[this.moveType]}`) });
|
||||||
@ -554,6 +616,10 @@ export class SpeciesStatBoosterModifierType extends PokemonHeldItemModifierType
|
|||||||
|
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "SpeciesBooster:" + this.key
|
||||||
|
}
|
||||||
|
|
||||||
getPregenArgs(): any[] {
|
getPregenArgs(): any[] {
|
||||||
return [ this.key ];
|
return [ this.key ];
|
||||||
@ -565,6 +631,10 @@ export class PokemonLevelIncrementModifierType extends PokemonModifierType {
|
|||||||
super(localeKey, iconImage, (_type, args) => new Modifiers.PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id), (_pokemon: PlayerPokemon) => null);
|
super(localeKey, iconImage, (_type, args) => new Modifiers.PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id), (_pokemon: PlayerPokemon) => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "RareCandy:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonLevelIncrementModifierType.description");
|
return i18next.t("modifierType:ModifierType.PokemonLevelIncrementModifierType.description");
|
||||||
}
|
}
|
||||||
@ -575,6 +645,10 @@ export class AllPokemonLevelIncrementModifierType extends ModifierType {
|
|||||||
super(localeKey, iconImage, (_type, _args) => new Modifiers.PokemonLevelIncrementModifier(this, -1));
|
super(localeKey, iconImage, (_type, _args) => new Modifiers.PokemonLevelIncrementModifier(this, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "RareCandy:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.AllPokemonLevelIncrementModifierType.description");
|
return i18next.t("modifierType:ModifierType.AllPokemonLevelIncrementModifierType.description");
|
||||||
}
|
}
|
||||||
@ -612,6 +686,10 @@ export class PokemonBaseStatBoosterModifierType extends PokemonHeldItemModifierT
|
|||||||
return i18next.t(`modifierType:BaseStatBoosterItem.${this.localeName.replace(/[ \-]/g, "_").toLowerCase()}`);
|
return i18next.t(`modifierType:BaseStatBoosterItem.${this.localeName.replace(/[ \-]/g, "_").toLowerCase()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "StatBooster:" + Utils.getEnumKeys(Stat)[this.stat]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonBaseStatBoosterModifierType.description", { statName: getStatName(this.stat) });
|
return i18next.t("modifierType:ModifierType.PokemonBaseStatBoosterModifierType.description", { statName: getStatName(this.stat) });
|
||||||
}
|
}
|
||||||
@ -630,6 +708,10 @@ class AllPokemonFullHpRestoreModifierType extends ModifierType {
|
|||||||
this.descriptionKey = descriptionKey;
|
this.descriptionKey = descriptionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "HealAll:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t(`${this.descriptionKey || "modifierType:ModifierType.AllPokemonFullHpRestoreModifierType"}.description` as any);
|
return i18next.t(`${this.descriptionKey || "modifierType:ModifierType.AllPokemonFullHpRestoreModifierType"}.description` as any);
|
||||||
}
|
}
|
||||||
@ -639,6 +721,10 @@ class AllPokemonFullReviveModifierType extends AllPokemonFullHpRestoreModifierTy
|
|||||||
constructor(localeKey: string, iconImage: string) {
|
constructor(localeKey: string, iconImage: string) {
|
||||||
super(localeKey, iconImage, "modifierType:ModifierType.AllPokemonFullReviveModifierType", (_type, _args) => new Modifiers.PokemonHpRestoreModifier(this, -1, 0, 100, false, true));
|
super(localeKey, iconImage, "modifierType:ModifierType.AllPokemonFullReviveModifierType", (_type, _args) => new Modifiers.PokemonHpRestoreModifier(this, -1, 0, 100, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "ReviveAll:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MoneyRewardModifierType extends ModifierType {
|
export class MoneyRewardModifierType extends ModifierType {
|
||||||
@ -652,6 +738,10 @@ export class MoneyRewardModifierType extends ModifierType {
|
|||||||
this.moneyMultiplierDescriptorKey = moneyMultiplierDescriptorKey;
|
this.moneyMultiplierDescriptorKey = moneyMultiplierDescriptorKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Money:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
const moneyAmount = new Utils.IntegerHolder(scene.getWaveMoneyAmount(this.moneyMultiplier));
|
const moneyAmount = new Utils.IntegerHolder(scene.getWaveMoneyAmount(this.moneyMultiplier));
|
||||||
scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
|
scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
|
||||||
@ -673,6 +763,10 @@ export class ExpBoosterModifierType extends ModifierType {
|
|||||||
this.boostPercent = boostPercent;
|
this.boostPercent = boostPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "ExpBooster:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.ExpBoosterModifierType.description", { boostPercent: this.boostPercent });
|
return i18next.t("modifierType:ModifierType.ExpBoosterModifierType.description", { boostPercent: this.boostPercent });
|
||||||
}
|
}
|
||||||
@ -687,6 +781,10 @@ export class PokemonExpBoosterModifierType extends PokemonHeldItemModifierType {
|
|||||||
this.boostPercent = boostPercent;
|
this.boostPercent = boostPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "PokemonExpBooster:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonExpBoosterModifierType.description", { boostPercent: this.boostPercent });
|
return i18next.t("modifierType:ModifierType.PokemonExpBoosterModifierType.description", { boostPercent: this.boostPercent });
|
||||||
}
|
}
|
||||||
@ -697,6 +795,10 @@ export class PokemonFriendshipBoosterModifierType extends PokemonHeldItemModifie
|
|||||||
super(localeKey, iconImage, (_type, args) => new Modifiers.PokemonFriendshipBoosterModifier(this, (args[0] as Pokemon).id));
|
super(localeKey, iconImage, (_type, args) => new Modifiers.PokemonFriendshipBoosterModifier(this, (args[0] as Pokemon).id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "FriendshipBooster:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonFriendshipBoosterModifierType.description");
|
return i18next.t("modifierType:ModifierType.PokemonFriendshipBoosterModifierType.description");
|
||||||
}
|
}
|
||||||
@ -711,6 +813,10 @@ export class PokemonMoveAccuracyBoosterModifierType extends PokemonHeldItemModif
|
|||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "AccuracyBooster:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonMoveAccuracyBoosterModifierType.description", { accuracyAmount: this.amount });
|
return i18next.t("modifierType:ModifierType.PokemonMoveAccuracyBoosterModifierType.description", { accuracyAmount: this.amount });
|
||||||
}
|
}
|
||||||
@ -721,6 +827,10 @@ export class PokemonMultiHitModifierType extends PokemonHeldItemModifierType {
|
|||||||
super(localeKey, iconImage, (type, args) => new Modifiers.PokemonMultiHitModifier(type as PokemonMultiHitModifierType, (args[0] as Pokemon).id));
|
super(localeKey, iconImage, (type, args) => new Modifiers.PokemonMultiHitModifier(type as PokemonMultiHitModifierType, (args[0] as Pokemon).id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "MultiHit:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.PokemonMultiHitModifierType.description");
|
return i18next.t("modifierType:ModifierType.PokemonMultiHitModifierType.description");
|
||||||
}
|
}
|
||||||
@ -728,8 +838,9 @@ export class PokemonMultiHitModifierType extends PokemonHeldItemModifierType {
|
|||||||
|
|
||||||
export class TmModifierType extends PokemonModifierType {
|
export class TmModifierType extends PokemonModifierType {
|
||||||
public moveId: Moves;
|
public moveId: Moves;
|
||||||
|
public rarity: string;
|
||||||
|
|
||||||
constructor(moveId: Moves) {
|
constructor(moveId: Moves, rarity: ModifierTier) {
|
||||||
super("", `tm_${Type[allMoves[moveId].type].toLowerCase()}`, (_type, args) => new Modifiers.TmModifier(this, (args[0] as PlayerPokemon).id),
|
super("", `tm_${Type[allMoves[moveId].type].toLowerCase()}`, (_type, args) => new Modifiers.TmModifier(this, (args[0] as PlayerPokemon).id),
|
||||||
(pokemon: PlayerPokemon) => {
|
(pokemon: PlayerPokemon) => {
|
||||||
if (pokemon.compatibleTms.indexOf(moveId) === -1 || pokemon.getMoveset().filter(m => m?.moveId === moveId).length) {
|
if (pokemon.compatibleTms.indexOf(moveId) === -1 || pokemon.getMoveset().filter(m => m?.moveId === moveId).length) {
|
||||||
@ -739,6 +850,26 @@ export class TmModifierType extends PokemonModifierType {
|
|||||||
}, "tm");
|
}, "tm");
|
||||||
|
|
||||||
this.moveId = moveId;
|
this.moveId = moveId;
|
||||||
|
switch (rarity) {
|
||||||
|
case ModifierTier.COMMON:
|
||||||
|
this.rarity = "Common"
|
||||||
|
break;
|
||||||
|
case ModifierTier.GREAT:
|
||||||
|
this.rarity = "Great"
|
||||||
|
break;
|
||||||
|
case ModifierTier.ULTRA:
|
||||||
|
this.rarity = "Ultra"
|
||||||
|
break;
|
||||||
|
case ModifierTier.ROGUE:
|
||||||
|
this.rarity = "Rogue"
|
||||||
|
break;
|
||||||
|
case ModifierTier.MASTER:
|
||||||
|
this.rarity = "Master"
|
||||||
|
break;
|
||||||
|
case ModifierTier.LUXURY:
|
||||||
|
this.rarity = "Luxury"
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string {
|
get name(): string {
|
||||||
@ -748,6 +879,10 @@ export class TmModifierType extends PokemonModifierType {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Tm" + this.rarity + ":" + Utils.getEnumKeys(Moves)[this.moveId]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t(scene.enableMoveInfo ? "modifierType:ModifierType.TmModifierTypeWithInfo.description" : "modifierType:ModifierType.TmModifierType.description", { moveName: allMoves[this.moveId].name });
|
return i18next.t(scene.enableMoveInfo ? "modifierType:ModifierType.TmModifierTypeWithInfo.description" : "modifierType:ModifierType.TmModifierType.description", { moveName: allMoves[this.moveId].name });
|
||||||
}
|
}
|
||||||
@ -777,6 +912,10 @@ export class EvolutionItemModifierType extends PokemonModifierType implements Ge
|
|||||||
return i18next.t(`modifierType:EvolutionItem.${EvolutionItem[this.evolutionItem]}`);
|
return i18next.t(`modifierType:EvolutionItem.${EvolutionItem[this.evolutionItem]}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Evolution:" + Utils.getEnumKeys(EvolutionItem)[this.evolutionItem]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.EvolutionItemModifierType.description");
|
return i18next.t("modifierType:ModifierType.EvolutionItemModifierType.description");
|
||||||
}
|
}
|
||||||
@ -815,6 +954,9 @@ export class FormChangeItemModifierType extends PokemonModifierType implements G
|
|||||||
get name(): string {
|
get name(): string {
|
||||||
return i18next.t(`modifierType:FormChangeItem.${FormChangeItem[this.formChangeItem]}`);
|
return i18next.t(`modifierType:FormChangeItem.${FormChangeItem[this.formChangeItem]}`);
|
||||||
}
|
}
|
||||||
|
get identifier(): string {
|
||||||
|
return "FormChange:" + Utils.getEnumKeys(FormChangeItem)[this.formChangeItem]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.FormChangeItemModifierType.description");
|
return i18next.t("modifierType:ModifierType.FormChangeItemModifierType.description");
|
||||||
@ -836,6 +978,10 @@ export class FusePokemonModifierType extends PokemonModifierType {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "Fusion:" + this.localeKey.split(".")[1]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.FusePokemonModifierType.description");
|
return i18next.t("modifierType:ModifierType.FusePokemonModifierType.description");
|
||||||
}
|
}
|
||||||
@ -975,7 +1121,7 @@ class TmModifierTypeGenerator extends ModifierTypeGenerator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const randTmIndex = Utils.randSeedInt(tierUniqueCompatibleTms.length);
|
const randTmIndex = Utils.randSeedInt(tierUniqueCompatibleTms.length);
|
||||||
return new TmModifierType(tierUniqueCompatibleTms[randTmIndex]);
|
return new TmModifierType(tierUniqueCompatibleTms[randTmIndex], tier);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1044,6 +1190,10 @@ export class TerastallizeModifierType extends PokemonHeldItemModifierType implem
|
|||||||
return i18next.t("modifierType:ModifierType.TerastallizeModifierType.name", { teraType: i18next.t(`pokemonInfo:Type.${Type[this.teraType]}`) });
|
return i18next.t("modifierType:ModifierType.TerastallizeModifierType.name", { teraType: i18next.t(`pokemonInfo:Type.${Type[this.teraType]}`) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return "TeraShard:" + Utils.getEnumKeys(Type)[this.teraType]
|
||||||
|
}
|
||||||
|
|
||||||
getDescription(scene: BattleScene): string {
|
getDescription(scene: BattleScene): string {
|
||||||
return i18next.t("modifierType:ModifierType.TerastallizeModifierType.description", { teraType: i18next.t(`pokemonInfo:Type.${Type[this.teraType]}`) });
|
return i18next.t("modifierType:ModifierType.TerastallizeModifierType.description", { teraType: i18next.t(`pokemonInfo:Type.${Type[this.teraType]}`) });
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,10 @@ export abstract class Modifier {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get identifier(): string {
|
||||||
|
return this.type.identifier;
|
||||||
|
}
|
||||||
|
|
||||||
abstract apply(args: any[]): boolean | Promise<boolean>;
|
abstract apply(args: any[]): boolean | Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1333,6 +1333,7 @@ export class EncounterPhase extends BattlePhase {
|
|||||||
if (this.scene.currentBattle.waveIndex == 1) {
|
if (this.scene.currentBattle.waveIndex == 1) {
|
||||||
LoggerTools.logPlayerTeam(this.scene)
|
LoggerTools.logPlayerTeam(this.scene)
|
||||||
}
|
}
|
||||||
|
LoggerTools.resetWaveActions(this.scene)
|
||||||
|
|
||||||
if (this.scene.currentBattle.battleType === BattleType.WILD) {
|
if (this.scene.currentBattle.battleType === BattleType.WILD) {
|
||||||
enemyField.forEach(enemyPokemon => {
|
enemyField.forEach(enemyPokemon => {
|
||||||
@ -2167,6 +2168,7 @@ export class CheckSwitchPhase extends BattlePhase {
|
|||||||
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? pokemon.name : i18next.t("battle:pokemon") }), null, () => {
|
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? pokemon.name : i18next.t("battle:pokemon") }), null, () => {
|
||||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
|
LoggerTools.isPreSwitch.value = true
|
||||||
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
|
this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex);
|
||||||
this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, false, true));
|
this.scene.unshiftPhase(new SwitchPhase(this.scene, this.fieldIndex, false, true));
|
||||||
for (var i = 0; i < this.scene.getEnemyField().length; i++) {
|
for (var i = 0; i < this.scene.getEnemyField().length; i++) {
|
||||||
@ -4968,11 +4970,13 @@ export class SwitchPhase extends BattlePhase {
|
|||||||
|
|
||||||
// Skip modal switch if impossible
|
// Skip modal switch if impossible
|
||||||
if (this.isModal && !this.scene.getParty().filter(p => p.isAllowedInBattle() && !p.isActive(true)).length) {
|
if (this.isModal && !this.scene.getParty().filter(p => p.isAllowedInBattle() && !p.isActive(true)).length) {
|
||||||
|
LoggerTools.isPreSwitch.value = false;
|
||||||
return super.end();
|
return super.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is any space still in field
|
// Check if there is any space still in field
|
||||||
if (this.isModal && this.scene.getPlayerField().filter(p => p.isAllowedInBattle() && p.isActive(true)).length >= this.scene.currentBattle.getBattlerCount()) {
|
if (this.isModal && this.scene.getPlayerField().filter(p => p.isAllowedInBattle() && p.isActive(true)).length >= this.scene.currentBattle.getBattlerCount()) {
|
||||||
|
LoggerTools.isPreSwitch.value = false;
|
||||||
return super.end();
|
return super.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4981,8 +4985,12 @@ export class SwitchPhase extends BattlePhase {
|
|||||||
|
|
||||||
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
|
this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => {
|
||||||
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
||||||
|
if (LoggerTools.isPreSwitch.value) {
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Pre-switch " + LoggerTools.playerPokeName(this.scene, fieldIndex) + (option == PartyOption.PASS_BATON ? " → Baton" : "") + " → " + LoggerTools.playerPokeName(this.scene, slotIndex))
|
||||||
|
}
|
||||||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, fieldIndex, slotIndex, this.doReturn, option === PartyOption.PASS_BATON));
|
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, fieldIndex, slotIndex, this.doReturn, option === PartyOption.PASS_BATON));
|
||||||
}
|
}
|
||||||
|
LoggerTools.isPreSwitch.value = false;
|
||||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
||||||
}, PartyUiHandler.FilterNonFainted);
|
}, PartyUiHandler.FilterNonFainted);
|
||||||
}
|
}
|
||||||
@ -5179,6 +5187,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
|||||||
this.scene.ui.showText(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), null, () => {
|
this.scene.ui.showText(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), null, () => {
|
||||||
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, () => {
|
||||||
this.scene.ui.setMode(messageMode);
|
this.scene.ui.setMode(messageMode);
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, LoggerTools.playerPokeName(this.scene, pokemon) + " | Skip " + move.name)
|
||||||
this.scene.ui.showText(i18next.t("battle:learnMoveNotLearned", { pokemonName: pokemon.name, moveName: move.name }), null, () => this.end(), null, true);
|
this.scene.ui.showText(i18next.t("battle:learnMoveNotLearned", { pokemonName: pokemon.name, moveName: move.name }), null, () => this.end(), null, true);
|
||||||
}, () => {
|
}, () => {
|
||||||
this.scene.ui.setMode(messageMode);
|
this.scene.ui.setMode(messageMode);
|
||||||
@ -5200,6 +5209,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
|
|||||||
this.scene.ui.showText(i18next.t("battle:countdownPoof"), null, () => {
|
this.scene.ui.showText(i18next.t("battle:countdownPoof"), null, () => {
|
||||||
this.scene.ui.showText(i18next.t("battle:learnMoveForgetSuccess", { pokemonName: pokemon.name, moveName: pokemon.moveset[moveIndex].getName() }), null, () => {
|
this.scene.ui.showText(i18next.t("battle:learnMoveForgetSuccess", { pokemonName: pokemon.name, moveName: pokemon.moveset[moveIndex].getName() }), null, () => {
|
||||||
this.scene.ui.showText(i18next.t("battle:learnMoveAnd"), null, () => {
|
this.scene.ui.showText(i18next.t("battle:learnMoveAnd"), null, () => {
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, LoggerTools.playerPokeName(this.scene, pokemon) + " | Replace " + pokemon.moveset[moveIndex].getName() + " with " + new PokemonMove(this.moveId).getName())
|
||||||
pokemon.setMove(moveIndex, Moves.NONE);
|
pokemon.setMove(moveIndex, Moves.NONE);
|
||||||
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, this.moveId));
|
this.scene.unshiftPhase(new LearnMovePhase(this.scene, this.partyMemberIndex, this.moveId));
|
||||||
this.end();
|
this.end();
|
||||||
@ -5663,7 +5673,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
if (rowCursor < 0 || cursor < 0) {
|
if (rowCursor < 0 || cursor < 0) {
|
||||||
this.scene.ui.showText(i18next.t("battle:skipItemQuestion"), null, () => {
|
this.scene.ui.showText(i18next.t("battle:skipItemQuestion"), null, () => {
|
||||||
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
this.scene.ui.setOverlayMode(Mode.CONFIRM, () => {
|
||||||
LoggerTools.logShop(this.scene, this.scene.currentBattle.waveIndex, "")
|
LoggerTools.logShop(this.scene, this.scene.currentBattle.waveIndex, "Skip taking items")
|
||||||
this.scene.ui.revertMode();
|
this.scene.ui.revertMode();
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
super.end();
|
super.end();
|
||||||
@ -5773,6 +5783,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
if (modifierType instanceof FusePokemonModifierType) {
|
if (modifierType instanceof FusePokemonModifierType) {
|
||||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: integer, spliceSlotIndex: integer) => {
|
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: integer, spliceSlotIndex: integer) => {
|
||||||
if (spliceSlotIndex !== undefined && fromSlotIndex < 6 && spliceSlotIndex < 6 && fromSlotIndex !== spliceSlotIndex) {
|
if (spliceSlotIndex !== undefined && fromSlotIndex < 6 && spliceSlotIndex < 6 && fromSlotIndex !== spliceSlotIndex) {
|
||||||
|
LoggerTools.logShop(this.scene, this.scene.currentBattle.waveIndex, modifierType.name + " → " + this.scene.getParty()[fromSlotIndex].name + " + " + this.scene.getParty()[spliceSlotIndex].name)
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => {
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => {
|
||||||
const modifier = modifierType.newModifier(party[fromSlotIndex], party[spliceSlotIndex]);
|
const modifier = modifierType.newModifier(party[fromSlotIndex], party[spliceSlotIndex]);
|
||||||
applyModifier(modifier, true);
|
applyModifier(modifier, true);
|
||||||
@ -5802,6 +5813,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
? modifierType.newModifier(party[slotIndex])
|
? modifierType.newModifier(party[slotIndex])
|
||||||
: modifierType.newModifier(party[slotIndex], option as integer)
|
: modifierType.newModifier(party[slotIndex], option as integer)
|
||||||
: modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1);
|
: modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1);
|
||||||
|
LoggerTools.logShop(this.scene, this.scene.currentBattle.waveIndex, modifierType.name + " → " + this.scene.getParty()[slotIndex].name)
|
||||||
applyModifier(modifier, true);
|
applyModifier(modifier, true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -5810,6 +5822,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
}, pokemonModifierType.selectFilter, modifierType instanceof PokemonMoveModifierType ? (modifierType as PokemonMoveModifierType).moveSelectFilter : undefined, tmMoveId, isPpRestoreModifier);
|
}, pokemonModifierType.selectFilter, modifierType instanceof PokemonMoveModifierType ? (modifierType as PokemonMoveModifierType).moveSelectFilter : undefined, tmMoveId, isPpRestoreModifier);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
LoggerTools.logShop(this.scene, this.scene.currentBattle.waveIndex, modifierType.name)
|
||||||
applyModifier(modifierType.newModifier());
|
applyModifier(modifierType.newModifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6015,6 +6028,7 @@ export class ScanIvsPhase extends PokemonPhase {
|
|||||||
|
|
||||||
this.scene.ui.showText(i18next.t("battle:ivScannerUseQuestion", { pokemonName: pokemon.name }), null, () => {
|
this.scene.ui.showText(i18next.t("battle:ivScannerUseQuestion", { pokemonName: pokemon.name }), null, () => {
|
||||||
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
this.scene.ui.setMode(Mode.CONFIRM, () => {
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "IV Scanner → " + LoggerTools.enemyPokeName(this.scene, pokemon))
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
new CommonBattleAnim(CommonAnim.LOCK_ON, pokemon, pokemon).play(this.scene, () => {
|
new CommonBattleAnim(CommonAnim.LOCK_ON, pokemon, pokemon).play(this.scene, () => {
|
||||||
|
@ -258,7 +258,7 @@ export const Setting: Array<Setting> = [
|
|||||||
value: "Percent"
|
value: "Percent"
|
||||||
}],
|
}],
|
||||||
default: 0,
|
default: 0,
|
||||||
type: SettingType.GENERAL
|
type: SettingType.GENERAL,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: SettingKeys.Tutorials,
|
key: SettingKeys.Tutorials,
|
||||||
|
@ -698,9 +698,9 @@ export default class FightUiHandler extends UiHandler {
|
|||||||
this.ppText.setText(`${Utils.padInt(pp, 2, " ")}/${Utils.padInt(maxPP, 2, " ")}`);
|
this.ppText.setText(`${Utils.padInt(pp, 2, " ")}/${Utils.padInt(maxPP, 2, " ")}`);
|
||||||
this.powerText.setText(`${power >= 0 ? power : "---"}`);
|
this.powerText.setText(`${power >= 0 ? power : "---"}`);
|
||||||
this.accuracyText.setText(`${accuracy >= 0 ? accuracy : "---"}`);
|
this.accuracyText.setText(`${accuracy >= 0 ? accuracy : "---"}`);
|
||||||
this.accuracyText.setText(`${accuracy1 >= 0 ? accuracy1 : "---"}`);
|
this.accuracyText.setText(`${accuracy1 >= 0 ? Math.round(accuracy1) : "---"}`);
|
||||||
if (this.scene.getEnemyField()[1] != undefined)
|
if (this.scene.getEnemyField()[1] != undefined)
|
||||||
this.accuracyText.setText(`${accuracy1 >= 0 ? accuracy1 : "---"}/${accuracy2 >= 0 ? accuracy2 : "---"}`);
|
this.accuracyText.setText(`${accuracy1 >= 0 ? Math.round(accuracy1) : "---"}/${accuracy2 >= 0 ? Math.round(accuracy2) : "---"}`);
|
||||||
|
|
||||||
const ppPercentLeft = pp / maxPP;
|
const ppPercentLeft = pp / maxPP;
|
||||||
|
|
||||||
|
86
src/ui/log-name-form-ui-handler.ts
Normal file
86
src/ui/log-name-form-ui-handler.ts
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import { FormModalUiHandler } from "./form-modal-ui-handler";
|
||||||
|
import { ModalConfig } from "./modal-ui-handler";
|
||||||
|
import * as Utils from "../utils";
|
||||||
|
import { Mode } from "./ui";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
export default class LogNameFormUiHandler extends FormModalUiHandler {
|
||||||
|
getModalTitle(config?: ModalConfig): string {
|
||||||
|
return "Create game log";
|
||||||
|
}
|
||||||
|
|
||||||
|
getFields(config?: ModalConfig): string[] {
|
||||||
|
return [ i18next.t("menu:username"), i18next.t("menu:password") ];
|
||||||
|
}
|
||||||
|
|
||||||
|
getWidth(config?: ModalConfig): number {
|
||||||
|
return 160;
|
||||||
|
}
|
||||||
|
|
||||||
|
getMargin(config?: ModalConfig): [number, number, number, number] {
|
||||||
|
return [ 0, 0, 48, 0 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
getButtonLabels(config?: ModalConfig): string[] {
|
||||||
|
return [ i18next.t("menu:login"), i18next.t("menu:register") ];
|
||||||
|
}
|
||||||
|
|
||||||
|
getReadableErrorMessage(error: string): string {
|
||||||
|
const colonIndex = error?.indexOf(":");
|
||||||
|
if (colonIndex > 0) {
|
||||||
|
error = error.slice(0, colonIndex);
|
||||||
|
}
|
||||||
|
switch (error) {
|
||||||
|
case "invalid username":
|
||||||
|
return i18next.t("menu:invalidLoginUsername");
|
||||||
|
case "invalid password":
|
||||||
|
return i18next.t("menu:invalidLoginPassword");
|
||||||
|
case "account doesn't exist":
|
||||||
|
return i18next.t("menu:accountNonExistent");
|
||||||
|
case "password doesn't match":
|
||||||
|
return i18next.t("menu:unmatchingPassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getReadableErrorMessage(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
show(args: any[]): boolean {
|
||||||
|
if (super.show(args)) {
|
||||||
|
const config = args[0] as ModalConfig;
|
||||||
|
|
||||||
|
const originalLoginAction = this.submitAction;
|
||||||
|
this.submitAction = (_) => {
|
||||||
|
// Prevent overlapping overrides on action modification
|
||||||
|
this.submitAction = originalLoginAction;
|
||||||
|
this.sanitizeInputs();
|
||||||
|
this.scene.ui.setMode(Mode.LOADING, { buttonActions: [] });
|
||||||
|
const onFail = error => {
|
||||||
|
this.scene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||||
|
this.scene.ui.playError();
|
||||||
|
};
|
||||||
|
if (!this.inputs[0].text) {
|
||||||
|
return onFail(i18next.t("menu:emptyUsername"));
|
||||||
|
}
|
||||||
|
Utils.apiPost("account/login", `username=${encodeURIComponent(this.inputs[0].text)}&password=${encodeURIComponent(this.inputs[1].text)}`, "application/x-www-form-urlencoded")
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
return response.text();
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.hasOwnProperty("token")) {
|
||||||
|
Utils.setCookie(Utils.sessionIdKey, response.token);
|
||||||
|
originalLoginAction();
|
||||||
|
} else {
|
||||||
|
onFail(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -83,7 +83,8 @@ export enum Mode {
|
|||||||
SESSION_RELOAD,
|
SESSION_RELOAD,
|
||||||
UNAVAILABLE,
|
UNAVAILABLE,
|
||||||
OUTDATED,
|
OUTDATED,
|
||||||
CHALLENGE_SELECT
|
CHALLENGE_SELECT,
|
||||||
|
NAME_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
const transitionModes = [
|
const transitionModes = [
|
||||||
@ -119,7 +120,8 @@ const noTransitionModes = [
|
|||||||
Mode.LOADING,
|
Mode.LOADING,
|
||||||
Mode.SESSION_RELOAD,
|
Mode.SESSION_RELOAD,
|
||||||
Mode.UNAVAILABLE,
|
Mode.UNAVAILABLE,
|
||||||
Mode.OUTDATED
|
Mode.OUTDATED,
|
||||||
|
Mode.NAME_LOG
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class UI extends Phaser.GameObjects.Container {
|
export default class UI extends Phaser.GameObjects.Container {
|
||||||
|
Loading…
Reference in New Issue
Block a user