From 382f1a8d7861e76a22bf592804778ad2ec9ed4a4 Mon Sep 17 00:00:00 2001 From: maru Date: Thu, 25 Apr 2024 04:01:00 -0400 Subject: [PATCH 01/10] Styling changes --- src/data/splash-messages.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/splash-messages.ts b/src/data/splash-messages.ts index 198ff07cec9..11629cf05d7 100644 --- a/src/data/splash-messages.ts +++ b/src/data/splash-messages.ts @@ -33,5 +33,6 @@ splashMessages.push(...[ 'Also Try Emerald Rogue!', 'Also Try Radical Red!', 'Eevee Expo!', - 'YNOproject!' + 'YNOproject!', + 'Shh, don\'t tell Sam!' ]); \ No newline at end of file From 1d25935aa0b22b893910b12e44dfc307d2273a34 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 25 Apr 2024 09:17:48 -0400 Subject: [PATCH 02/10] Enforce trainer IDs on write requests for data integrity --- src/system/game-data.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 5e572f25760..de9406aef84 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -222,8 +222,8 @@ export class GameData { constructor(scene: BattleScene) { this.scene = scene; this.loadSettings(); - this.trainerId = Utils.randSeedInt(65536); - this.secretId = Utils.randSeedInt(65536); + this.trainerId = Utils.randInt(65536); + this.secretId = Utils.randInt(65536); this.starterData = {}; this.gameStats = new GameStats(); this.unlocks = { @@ -551,7 +551,7 @@ export class GameData { const sessionData = this.getSessionSaveData(scene); if (!bypassLogin) { - Utils.apiPost(`savedata/update?datatype=${GameDataType.SESSION}&slot=${scene.sessionSlotId}`, JSON.stringify(sessionData), undefined, true) + Utils.apiPost(`savedata/update?datatype=${GameDataType.SESSION}&slot=${scene.sessionSlotId}&trainerId=${this.trainerId}&secretId=${this.secretId}`, JSON.stringify(sessionData), undefined, true) .then(response => response.text()) .then(error => { if (error) { @@ -752,7 +752,7 @@ export class GameData { if (success !== null && !success) return resolve([false, false]); const sessionData = this.getSessionSaveData(scene); - Utils.apiPost(`savedata/clear?slot=${slotId}`, JSON.stringify(sessionData), undefined, true).then(response => { + Utils.apiPost(`savedata/clear?slot=${slotId}&trainerId=${this.trainerId}&secretId=${this.secretId}`, JSON.stringify(sessionData), undefined, true).then(response => { if (response.ok) loggedInUser.lastSessionSlot = -1; return response.json(); @@ -912,7 +912,7 @@ export class GameData { updateUserInfo().then(success => { if (!success) return displayError(`Could not contact the server. Your ${dataName} data could not be imported.`); - Utils.apiPost(`savedata/update?datatype=${dataType}${dataType === GameDataType.SESSION ? `&slot=${slotId}` : ''}`, dataStr, undefined, true) + Utils.apiPost(`savedata/update?datatype=${dataType}${dataType === GameDataType.SESSION ? `&slot=${slotId}` : ''}&trainerId=${this.trainerId}&secretId=${this.secretId}`, dataStr, undefined, true) .then(response => response.text()) .then(error => { if (error) { From dcded952d57c07c77f5c147f8f874adbdff99999 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 25 Apr 2024 09:57:52 -0400 Subject: [PATCH 03/10] Bump client version for forced update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16f5a316307..47408b13730 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pokemon-rogue-battle", "private": true, - "version": "1.0.2", + "version": "1.0.3", "type": "module", "scripts": { "start": "vite", From daba4e94820fd91a43a623ec2f88b43236459f91 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 25 Apr 2024 13:20:32 -0400 Subject: [PATCH 04/10] Fix not updating legendary and mythical Pokemon seen stats --- src/system/game-data.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index de9406aef84..cd8f38d9a99 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -1000,6 +1000,10 @@ export class GameData { if (incrementCount) { dexEntry.seenCount++; this.gameStats.pokemonSeen++; + if (!trainer && pokemon.species.pseudoLegendary || pokemon.species.legendary) + this.gameStats.legendaryPokemonSeen++; + else if (!trainer && pokemon.species.mythical) + this.gameStats.mythicalPokemonSeen++; if (!trainer && pokemon.isShiny()) this.gameStats.shinyPokemonSeen++; } From 4cfae4703c97e435947ef23bac60c9e38e2506ba Mon Sep 17 00:00:00 2001 From: Edralo Date: Thu, 25 Apr 2024 19:38:33 +0200 Subject: [PATCH 05/10] Implement localisation for main menu options (menu-ui-handler) & add french locale --- src/locales/en/menu-ui-handler.ts | 23 +++++++++++++++++++++++ src/locales/es/menu-ui-handler.ts | 23 +++++++++++++++++++++++ src/locales/fr/menu-ui-handler.ts | 23 +++++++++++++++++++++++ src/locales/it/menu-ui-handler.ts | 23 +++++++++++++++++++++++ src/plugins/i18n.ts | 10 ++++++++++ src/ui/menu-ui-handler.ts | 27 ++++++++++++++------------- 6 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 src/locales/en/menu-ui-handler.ts create mode 100644 src/locales/es/menu-ui-handler.ts create mode 100644 src/locales/fr/menu-ui-handler.ts create mode 100644 src/locales/it/menu-ui-handler.ts diff --git a/src/locales/en/menu-ui-handler.ts b/src/locales/en/menu-ui-handler.ts new file mode 100644 index 00000000000..5fde37ae360 --- /dev/null +++ b/src/locales/en/menu-ui-handler.ts @@ -0,0 +1,23 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const menuUiHandler: SimpleTranslationEntries = { + "GAME_SETTINGS": 'Game Settings', + "ACHIEVEMENTS": "Achievements", + "STATS": "Stats", + "VOUCHERS": "Vouchers", + "EGG_LIST": "Egg List", + "EGG_GACHA": "Egg Gacha", + "MANAGE_DATA": "Manage Data", + "COMMUNITY": "Community", + "RETURN_TO_TITLE": "Return To Title", + "LOG_OUT": "Log Out", + "slot": "Slot {{slotNumber}}", + "importSession": "Import Session", + "importSlotSelect": "Select a slot to import to.", + "exportSession": "Export Session", + "exportSlotSelect": "Select a slot to export from.", + "importData": "Import Data", + "exportData": "Export Data", + "cancel": "Cancel", + "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?" +} as const; \ No newline at end of file diff --git a/src/locales/es/menu-ui-handler.ts b/src/locales/es/menu-ui-handler.ts new file mode 100644 index 00000000000..5fde37ae360 --- /dev/null +++ b/src/locales/es/menu-ui-handler.ts @@ -0,0 +1,23 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const menuUiHandler: SimpleTranslationEntries = { + "GAME_SETTINGS": 'Game Settings', + "ACHIEVEMENTS": "Achievements", + "STATS": "Stats", + "VOUCHERS": "Vouchers", + "EGG_LIST": "Egg List", + "EGG_GACHA": "Egg Gacha", + "MANAGE_DATA": "Manage Data", + "COMMUNITY": "Community", + "RETURN_TO_TITLE": "Return To Title", + "LOG_OUT": "Log Out", + "slot": "Slot {{slotNumber}}", + "importSession": "Import Session", + "importSlotSelect": "Select a slot to import to.", + "exportSession": "Export Session", + "exportSlotSelect": "Select a slot to export from.", + "importData": "Import Data", + "exportData": "Export Data", + "cancel": "Cancel", + "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?" +} as const; \ No newline at end of file diff --git a/src/locales/fr/menu-ui-handler.ts b/src/locales/fr/menu-ui-handler.ts new file mode 100644 index 00000000000..6822c7fabfd --- /dev/null +++ b/src/locales/fr/menu-ui-handler.ts @@ -0,0 +1,23 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const menuUiHandler: SimpleTranslationEntries = { + "GAME_SETTINGS": 'Options', + "ACHIEVEMENTS": "Succès", + "STATS": "Statistiques", + "VOUCHERS": "Coupons", + "EGG_LIST": "Liste des œufs", + "EGG_GACHA": "Gacha-œufs", + "MANAGE_DATA": "Gestion données", + "COMMUNITY": "Communauté", + "RETURN_TO_TITLE": "Écran titre", + "LOG_OUT": "Se déconnecter", + "slot": "Emplacement {{slotNumber}}", + "importSession": "Importer session", + "importSlotSelect": "Sélectionnez l'emplacement depuis lequel importer.", + "exportSession": "Exporter session", + "exportSlotSelect": "Sélectionnez l'emplacement vers lequel exporter.", + "importData": "Importer données", + "exportData": "Exporter données", + "cancel": "Retour", + "losingProgressionWarning": "Vous allez perdre votre progression depuis le début du combat. Continuer?" +} as const; \ No newline at end of file diff --git a/src/locales/it/menu-ui-handler.ts b/src/locales/it/menu-ui-handler.ts new file mode 100644 index 00000000000..5fde37ae360 --- /dev/null +++ b/src/locales/it/menu-ui-handler.ts @@ -0,0 +1,23 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const menuUiHandler: SimpleTranslationEntries = { + "GAME_SETTINGS": 'Game Settings', + "ACHIEVEMENTS": "Achievements", + "STATS": "Stats", + "VOUCHERS": "Vouchers", + "EGG_LIST": "Egg List", + "EGG_GACHA": "Egg Gacha", + "MANAGE_DATA": "Manage Data", + "COMMUNITY": "Community", + "RETURN_TO_TITLE": "Return To Title", + "LOG_OUT": "Log Out", + "slot": "Slot {{slotNumber}}", + "importSession": "Import Session", + "importSlotSelect": "Select a slot to import to.", + "exportSession": "Export Session", + "exportSlotSelect": "Select a slot to export from.", + "importData": "Import Data", + "exportData": "Export Data", + "cancel": "Cancel", + "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?" +} as const; \ No newline at end of file diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index a69f441d895..521e3df7c00 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -4,6 +4,11 @@ import { menu as esMenu } from '../locales/es/menu'; import { menu as itMenu } from '../locales/it/menu'; import { menu as frMenu } from '../locales/fr/menu'; +import { menuUiHandler as enMenuUiHandler } from '../locales/en/menu-ui-handler.js'; +import { menuUiHandler as esMenuUiHandler } from '../locales/es/menu-ui-handler.js'; +import { menuUiHandler as frMenuUiHandler } from '../locales/fr/menu-ui-handler.js'; +import { menuUiHandler as itMenuUiHandler } from '../locales/it/menu-ui-handler.js'; + import { move as enMove } from '../locales/en/move'; import { move as esMove } from '../locales/es/move'; import { move as frMove } from '../locales/fr/move'; @@ -86,6 +91,7 @@ export function initI18n(): void { resources: { en: { menu: enMenu, + menuUiHandler: enMenuUiHandler, move: enMove, ability: enAbility, pokeball: enPokeball, @@ -95,6 +101,7 @@ export function initI18n(): void { }, es: { menu: esMenu, + menuUiHandler: esMenuUiHandler, move: esMove, ability: esAbility, pokeball: esPokeball, @@ -104,6 +111,7 @@ export function initI18n(): void { }, fr: { menu: frMenu, + menuUiHandler: frMenuUiHandler, move: frMove, ability: frAbility, pokeball: frPokeball, @@ -113,6 +121,7 @@ export function initI18n(): void { }, it: { menu: itMenu, + menuUiHandler: itMenuUiHandler, pokemonStat: itPokemonStat, }, }, @@ -124,6 +133,7 @@ declare module 'i18next' { interface CustomTypeOptions { resources: { menu: typeof enMenu; + menuUiHandler: typeof enMenuUiHandler; move: typeof enMove; ability: typeof enAbility; pokeball: typeof enPokeball; diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 16af6b15d96..8063b600c6c 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -8,6 +8,7 @@ import { GameDataType } from "../system/game-data"; import { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler"; import { Tutorial, handleTutorial } from "../tutorial"; import { updateUserInfo } from "../account"; +import i18next from '../plugins/i18n'; export enum MenuOptions { GAME_SETTINGS, @@ -62,7 +63,7 @@ export default class MenuUiHandler extends MessageUiHandler { this.menuContainer.add(this.menuBg); - this.optionSelectText = addTextObject(this.scene, 0, 0, this.menuOptions.map(o => Utils.toReadableString(MenuOptions[o])).join('\n'), TextStyle.WINDOW, { maxLines: this.menuOptions.length }); + this.optionSelectText = addTextObject(this.scene, 0, 0, this.menuOptions.map(o => `${i18next.t(`menuUiHandler:${MenuOptions[o]}`)}`).join('\n'), TextStyle.WINDOW, { maxLines: this.menuOptions.length }); this.optionSelectText.setPositionRelative(this.menuBg, 14, 6); this.optionSelectText.setLineSpacing(12); this.menuContainer.add(this.optionSelectText); @@ -94,7 +95,7 @@ export default class MenuUiHandler extends MessageUiHandler { const config: OptionSelectConfig = { options: new Array(3).fill(null).map((_, i) => i).filter(slotFilter).map(i => { return { - label: `Slot ${i + 1}`, + label: i18next.t('menuUiHandler:slot', {slotNumber: i+1}), handler: () => { callback(i); ui.revertMode(); @@ -103,7 +104,7 @@ export default class MenuUiHandler extends MessageUiHandler { } }; }).concat([{ - label: 'Cancel', + label: i18next.t('menuUiHandler:cancel'), handler: () => { ui.revertMode(); ui.showText(null, 0); @@ -118,16 +119,16 @@ export default class MenuUiHandler extends MessageUiHandler { if (Utils.isLocal) { manageDataOptions.push({ - label: 'Import Session', + label: i18next.t("menuUiHandler:importSession"), handler: () => { - confirmSlot('Select a slot to import to.', () => true, slotId => this.scene.gameData.importData(GameDataType.SESSION, slotId)); + confirmSlot(i18next.t("menuUiHandler:importSlotSelect"), () => true, slotId => this.scene.gameData.importData(GameDataType.SESSION, slotId)); return true; }, keepOpen: true }); } manageDataOptions.push({ - label: 'Export Session', + label: i18next.t("menuUiHandler:exportSession"), handler: () => { const dataSlots: integer[] = []; Promise.all( @@ -138,7 +139,7 @@ export default class MenuUiHandler extends MessageUiHandler { dataSlots.push(slotId); }) })).then(() => { - confirmSlot('Select a slot to export from.', + confirmSlot(i18next.t("menuUiHandler:exportSlotSelect"), i => dataSlots.indexOf(i) > -1, slotId => this.scene.gameData.tryExportData(GameDataType.SESSION, slotId)); }); @@ -148,7 +149,7 @@ export default class MenuUiHandler extends MessageUiHandler { }); if (Utils.isLocal) { manageDataOptions.push({ - label: 'Import Data', + label: i18next.t("menuUiHandler:importData"), handler: () => { this.scene.gameData.importData(GameDataType.SYSTEM); return true; @@ -158,7 +159,7 @@ export default class MenuUiHandler extends MessageUiHandler { } manageDataOptions.push( { - label: 'Export Data', + label: i18next.t("menuUiHandler:exportData"), handler: () => { this.scene.gameData.tryExportData(GameDataType.SYSTEM); return true; @@ -166,7 +167,7 @@ export default class MenuUiHandler extends MessageUiHandler { keepOpen: true }, { - label: 'Cancel', + label: i18next.t('menuUiHandler:cancel'), handler: () => { this.scene.ui.revertMode(); return true; @@ -205,7 +206,7 @@ export default class MenuUiHandler extends MessageUiHandler { keepOpen: true }, { - label: 'Cancel', + label: i18next.t('menuUiHandler:cancel'), handler: () => { this.scene.ui.revertMode(); return true; @@ -295,7 +296,7 @@ export default class MenuUiHandler extends MessageUiHandler { case MenuOptions.RETURN_TO_TITLE: if (this.scene.currentBattle) { success = true; - ui.showText('You will lose any progress since the beginning of the battle. Proceed?', null, () => { + ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => { ui.setOverlayMode(Mode.CONFIRM, () => this.scene.reset(true), () => { ui.revertMode(); ui.showText(null, 0); @@ -315,7 +316,7 @@ export default class MenuUiHandler extends MessageUiHandler { }); }; if (this.scene.currentBattle) { - ui.showText('You will lose any progress since the beginning of the battle. Proceed?', null, () => { + ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => { ui.setOverlayMode(Mode.CONFIRM, doLogout, () => { ui.revertMode(); ui.showText(null, 0); From fa463b77db8c4e83186e0174e7cc6643854b06c3 Mon Sep 17 00:00:00 2001 From: lucfd <83493765+lucfd@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:29:05 -0400 Subject: [PATCH 06/10] Implements Stakeout & Analytic (#292) * implemented stakeout * implemented analytic --- src/data/ability.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index e129bf8ec2e..681fff65199 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -19,6 +19,7 @@ import { TerrainType } from "./terrain"; import { SpeciesFormChangeManualTrigger } from "./pokemon-forms"; import { Abilities } from "./enums/abilities"; import i18next, { Localizable } from "#app/plugins/i18n.js"; +import { Command } from "../ui/command-ui-handler"; export class Ability implements Localizable { public id: Abilities; @@ -2858,7 +2859,7 @@ export function initAbilities() { .ignorable() .unimplemented(), new Ability(Abilities.ANALYTIC, 5) - .unimplemented(), + .attr(MovePowerBoostAbAttr, (user, target, move) => !!target.getLastXMoves(1).find(m => m.turn === target.scene.currentBattle.turn) || user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command !== Command.FIGHT, 1.3), new Ability(Abilities.ILLUSION, 5) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) @@ -3004,7 +3005,7 @@ export function initAbilities() { .attr(NoFusionAbilityAbAttr) .partial(), new Ability(Abilities.STAKEOUT, 7) - .unimplemented(), + .attr(MovePowerBoostAbAttr, (user, target, move) => user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command === Command.POKEMON, 2), new Ability(Abilities.WATER_BUBBLE, 7) .attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5) .attr(MoveTypePowerBoostAbAttr, Type.WATER, 1) From 4a703c938de955e95ae76a5812b38f14ebb18581 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 25 Apr 2024 14:47:32 -0400 Subject: [PATCH 07/10] Add load message handler for too many connections --- src/system/game-data.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index cd8f38d9a99..23c3f24affb 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -421,6 +421,9 @@ export class GameData { if (response.startsWith('failed to open save file')) { this.scene.queueMessage('Save data could not be found. If this is a new account, you can safely ignore this message.', null, true); return resolve(true); + } else if (response.indexOf('Too many connections') > -1) { + this.scene.queueMessage('Too many people are trying to connect and the server is overloaded. Please try again later.', null, true); + return resolve(false); } console.error(response); return resolve(false); From b8ce1da3bc593b527ff76bc770e2ca7c02f76897 Mon Sep 17 00:00:00 2001 From: Dakurei Date: Thu, 25 Apr 2024 21:13:11 +0200 Subject: [PATCH 08/10] Modification of the fr translation for menu-ui-handler - Reduction of "MANAGE_DATA" and "LOG_OUT" strings to avoid overflowing the window border - Added missing space for "losingProgressionWarning". - Inversion of words in "importSlotSelect" and "exportSlotSelect" strings + sentence completion to make it clearer --- src/locales/fr/menu-ui-handler.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/locales/fr/menu-ui-handler.ts b/src/locales/fr/menu-ui-handler.ts index 6822c7fabfd..c632e6f7306 100644 --- a/src/locales/fr/menu-ui-handler.ts +++ b/src/locales/fr/menu-ui-handler.ts @@ -7,17 +7,17 @@ export const menuUiHandler: SimpleTranslationEntries = { "VOUCHERS": "Coupons", "EGG_LIST": "Liste des œufs", "EGG_GACHA": "Gacha-œufs", - "MANAGE_DATA": "Gestion données", + "MANAGE_DATA": "Mes données", "COMMUNITY": "Communauté", "RETURN_TO_TITLE": "Écran titre", - "LOG_OUT": "Se déconnecter", + "LOG_OUT": "Déconnexion", "slot": "Emplacement {{slotNumber}}", "importSession": "Importer session", - "importSlotSelect": "Sélectionnez l'emplacement depuis lequel importer.", + "importSlotSelect": "Sélectionnez l'emplacement vers lequel importer les données.", "exportSession": "Exporter session", - "exportSlotSelect": "Sélectionnez l'emplacement vers lequel exporter.", + "exportSlotSelect": "Sélectionnez l'emplacement depuis lequel exporter les données.", "importData": "Importer données", "exportData": "Exporter données", "cancel": "Retour", - "losingProgressionWarning": "Vous allez perdre votre progression depuis le début du combat. Continuer?" + "losingProgressionWarning": "Vous allez perdre votre progression depuis le début du combat. Continuer ?" } as const; \ No newline at end of file From 3bdd354b5e57ee270700ca3ca46dbbf8c49047a7 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 25 Apr 2024 16:15:58 -0400 Subject: [PATCH 09/10] Update title stats interval --- src/ui/title-ui-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index fde27788bd1..6c96e475929 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -80,7 +80,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { this.updateTitleStats(); - this.titleStatsTimer = setInterval(() => this.updateTitleStats(), 10000); + this.titleStatsTimer = setInterval(() => this.updateTitleStats(), 30000); this.scene.tweens.add({ targets: [ this.titleContainer, ui.getMessageHandler().bg ], From 4ef670733320ba23e1fa44e7abe28515a17f5f35 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 25 Apr 2024 16:56:41 -0400 Subject: [PATCH 10/10] Revert API URL change --- src/utils.ts | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index c90633ca371..577e35c748e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -212,8 +212,7 @@ export function executeIf(condition: boolean, promiseFunc: () => Promise): export const sessionIdKey = 'pokerogue_sessionId'; export const isLocal = window.location.hostname === 'localhost'; export const serverUrl = isLocal ? 'http://localhost:8001' : ''; -export const apiUrl = isLocal ? serverUrl : 'https://api.pokerogue.net'; -export const fallbackApiUrl = isLocal ? serverUrl : 'api'; +export const apiUrl = isLocal ? serverUrl : 'api'; export function setCookie(cName: string, cValue: string): void { const expiration = new Date(); @@ -234,7 +233,7 @@ export function getCookie(cName: string): string { return ''; } -export function apiFetch(path: string, authed: boolean = false, fallback: boolean = false): Promise { +export function apiFetch(path: string, authed: boolean = false): Promise { return new Promise((resolve, reject) => { const request = {}; if (authed) { @@ -242,22 +241,13 @@ export function apiFetch(path: string, authed: boolean = false, fallback: boolea if (sId) request['headers'] = { 'Authorization': sId }; } - fetch(`${!fallback ? apiUrl : fallbackApiUrl}/${path}`, request) - .then(response => { - if (!response.ok && response.status === 404 && !fallback) - return apiFetch(path, authed, true).then(res => resolve(res)); - resolve(response); - }) - .catch(err => { - if (fallback) - reject(err); - else - apiFetch(path, authed, true).then(res => resolve(res)); - }); + fetch(`${apiUrl}/${path}`, request) + .then(response => resolve(response)) + .catch(err => reject(err)); }); } -export function apiPost(path: string, data?: any, contentType: string = 'application/json', authed: boolean = false, fallback: boolean = false): Promise { +export function apiPost(path: string, data?: any, contentType: string = 'application/json', authed: boolean = false): Promise { return new Promise((resolve, reject) => { const headers = { 'Accept': contentType, @@ -268,14 +258,9 @@ export function apiPost(path: string, data?: any, contentType: string = 'applica if (sId) headers['Authorization'] = sId; } - fetch(`${!fallback ? apiUrl : fallbackApiUrl}/${path}`, { method: 'POST', headers: headers, body: data }) + fetch(`${apiUrl}/${path}`, { method: 'POST', headers: headers, body: data }) .then(response => resolve(response)) - .catch(err => { - if (fallback) - reject(err); - else - apiPost(path, data, contentType, authed, true).then(res => resolve(res)); - }); + .catch(err => reject(err)); }); }