Merge branch 'pagefaultgames:main' into main

This commit is contained in:
NxKarim 2024-04-25 15:43:14 -06:00 committed by GitHub
commit 1838e50248
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 143 additions and 46 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "pokemon-rogue-battle", "name": "pokemon-rogue-battle",
"private": true, "private": true,
"version": "1.0.2", "version": "1.0.3",
"type": "module", "type": "module",
"scripts": { "scripts": {
"start": "vite", "start": "vite",

View File

@ -19,6 +19,7 @@ import { TerrainType } from "./terrain";
import { SpeciesFormChangeManualTrigger } from "./pokemon-forms"; import { SpeciesFormChangeManualTrigger } from "./pokemon-forms";
import { Abilities } from "./enums/abilities"; import { Abilities } from "./enums/abilities";
import i18next, { Localizable } from "#app/plugins/i18n.js"; import i18next, { Localizable } from "#app/plugins/i18n.js";
import { Command } from "../ui/command-ui-handler";
export class Ability implements Localizable { export class Ability implements Localizable {
public id: Abilities; public id: Abilities;
@ -2900,7 +2901,7 @@ export function initAbilities() {
.ignorable() .ignorable()
.unimplemented(), .unimplemented(),
new Ability(Abilities.ANALYTIC, 5) 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) new Ability(Abilities.ILLUSION, 5)
.attr(UncopiableAbilityAbAttr) .attr(UncopiableAbilityAbAttr)
.attr(UnswappableAbilityAbAttr) .attr(UnswappableAbilityAbAttr)
@ -3046,7 +3047,7 @@ export function initAbilities() {
.attr(NoFusionAbilityAbAttr) .attr(NoFusionAbilityAbAttr)
.partial(), .partial(),
new Ability(Abilities.STAKEOUT, 7) 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) new Ability(Abilities.WATER_BUBBLE, 7)
.attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5) .attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5)
.attr(MoveTypePowerBoostAbAttr, Type.WATER, 1) .attr(MoveTypePowerBoostAbAttr, Type.WATER, 1)

View File

@ -33,5 +33,6 @@ splashMessages.push(...[
'Also Try Emerald Rogue!', 'Also Try Emerald Rogue!',
'Also Try Radical Red!', 'Also Try Radical Red!',
'Eevee Expo!', 'Eevee Expo!',
'YNOproject!' 'YNOproject!',
'Shh, don\'t tell Sam!'
]); ]);

View File

@ -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;

View File

@ -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;

View File

@ -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": "Mes données",
"COMMUNITY": "Communauté",
"RETURN_TO_TITLE": "Écran titre",
"LOG_OUT": "Déconnexion",
"slot": "Emplacement {{slotNumber}}",
"importSession": "Importer session",
"importSlotSelect": "Sélectionnez l'emplacement vers lequel importer les données.",
"exportSession": "Exporter session",
"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 ?"
} as const;

View File

@ -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;

View File

@ -4,6 +4,11 @@ import { menu as esMenu } from '../locales/es/menu';
import { menu as itMenu } from '../locales/it/menu'; import { menu as itMenu } from '../locales/it/menu';
import { menu as frMenu } from '../locales/fr/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 enMove } from '../locales/en/move';
import { move as esMove } from '../locales/es/move'; import { move as esMove } from '../locales/es/move';
import { move as frMove } from '../locales/fr/move'; import { move as frMove } from '../locales/fr/move';
@ -86,6 +91,7 @@ export function initI18n(): void {
resources: { resources: {
en: { en: {
menu: enMenu, menu: enMenu,
menuUiHandler: enMenuUiHandler,
move: enMove, move: enMove,
ability: enAbility, ability: enAbility,
pokeball: enPokeball, pokeball: enPokeball,
@ -95,6 +101,7 @@ export function initI18n(): void {
}, },
es: { es: {
menu: esMenu, menu: esMenu,
menuUiHandler: esMenuUiHandler,
move: esMove, move: esMove,
ability: esAbility, ability: esAbility,
pokeball: esPokeball, pokeball: esPokeball,
@ -104,6 +111,7 @@ export function initI18n(): void {
}, },
fr: { fr: {
menu: frMenu, menu: frMenu,
menuUiHandler: frMenuUiHandler,
move: frMove, move: frMove,
ability: frAbility, ability: frAbility,
pokeball: frPokeball, pokeball: frPokeball,
@ -113,6 +121,7 @@ export function initI18n(): void {
}, },
it: { it: {
menu: itMenu, menu: itMenu,
menuUiHandler: itMenuUiHandler,
pokemonStat: itPokemonStat, pokemonStat: itPokemonStat,
}, },
}, },
@ -124,6 +133,7 @@ declare module 'i18next' {
interface CustomTypeOptions { interface CustomTypeOptions {
resources: { resources: {
menu: typeof enMenu; menu: typeof enMenu;
menuUiHandler: typeof enMenuUiHandler;
move: typeof enMove; move: typeof enMove;
ability: typeof enAbility; ability: typeof enAbility;
pokeball: typeof enPokeball; pokeball: typeof enPokeball;

View File

@ -222,8 +222,8 @@ export class GameData {
constructor(scene: BattleScene) { constructor(scene: BattleScene) {
this.scene = scene; this.scene = scene;
this.loadSettings(); this.loadSettings();
this.trainerId = Utils.randSeedInt(65536); this.trainerId = Utils.randInt(65536);
this.secretId = Utils.randSeedInt(65536); this.secretId = Utils.randInt(65536);
this.starterData = {}; this.starterData = {};
this.gameStats = new GameStats(); this.gameStats = new GameStats();
this.unlocks = { this.unlocks = {
@ -421,6 +421,9 @@ export class GameData {
if (response.startsWith('failed to open save file')) { 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); 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); 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); console.error(response);
return resolve(false); return resolve(false);
@ -551,7 +554,7 @@ export class GameData {
const sessionData = this.getSessionSaveData(scene); const sessionData = this.getSessionSaveData(scene);
if (!bypassLogin) { 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(response => response.text())
.then(error => { .then(error => {
if (error) { if (error) {
@ -752,7 +755,7 @@ export class GameData {
if (success !== null && !success) if (success !== null && !success)
return resolve([false, false]); return resolve([false, false]);
const sessionData = this.getSessionSaveData(scene); 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) if (response.ok)
loggedInUser.lastSessionSlot = -1; loggedInUser.lastSessionSlot = -1;
return response.json(); return response.json();
@ -912,7 +915,7 @@ export class GameData {
updateUserInfo().then(success => { updateUserInfo().then(success => {
if (!success) if (!success)
return displayError(`Could not contact the server. Your ${dataName} data could not be imported.`); 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(response => response.text())
.then(error => { .then(error => {
if (error) { if (error) {
@ -1000,6 +1003,10 @@ export class GameData {
if (incrementCount) { if (incrementCount) {
dexEntry.seenCount++; dexEntry.seenCount++;
this.gameStats.pokemonSeen++; 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()) if (!trainer && pokemon.isShiny())
this.gameStats.shinyPokemonSeen++; this.gameStats.shinyPokemonSeen++;
} }

View File

@ -8,6 +8,7 @@ import { GameDataType } from "../system/game-data";
import { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler"; import { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler";
import { Tutorial, handleTutorial } from "../tutorial"; import { Tutorial, handleTutorial } from "../tutorial";
import { updateUserInfo } from "../account"; import { updateUserInfo } from "../account";
import i18next from '../plugins/i18n';
export enum MenuOptions { export enum MenuOptions {
GAME_SETTINGS, GAME_SETTINGS,
@ -62,7 +63,7 @@ export default class MenuUiHandler extends MessageUiHandler {
this.menuContainer.add(this.menuBg); 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.setPositionRelative(this.menuBg, 14, 6);
this.optionSelectText.setLineSpacing(12); this.optionSelectText.setLineSpacing(12);
this.menuContainer.add(this.optionSelectText); this.menuContainer.add(this.optionSelectText);
@ -94,7 +95,7 @@ export default class MenuUiHandler extends MessageUiHandler {
const config: OptionSelectConfig = { const config: OptionSelectConfig = {
options: new Array(3).fill(null).map((_, i) => i).filter(slotFilter).map(i => { options: new Array(3).fill(null).map((_, i) => i).filter(slotFilter).map(i => {
return { return {
label: `Slot ${i + 1}`, label: i18next.t('menuUiHandler:slot', {slotNumber: i+1}),
handler: () => { handler: () => {
callback(i); callback(i);
ui.revertMode(); ui.revertMode();
@ -103,7 +104,7 @@ export default class MenuUiHandler extends MessageUiHandler {
} }
}; };
}).concat([{ }).concat([{
label: 'Cancel', label: i18next.t('menuUiHandler:cancel'),
handler: () => { handler: () => {
ui.revertMode(); ui.revertMode();
ui.showText(null, 0); ui.showText(null, 0);
@ -118,16 +119,16 @@ export default class MenuUiHandler extends MessageUiHandler {
if (Utils.isLocal) { if (Utils.isLocal) {
manageDataOptions.push({ manageDataOptions.push({
label: 'Import Session', label: i18next.t("menuUiHandler:importSession"),
handler: () => { 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; return true;
}, },
keepOpen: true keepOpen: true
}); });
} }
manageDataOptions.push({ manageDataOptions.push({
label: 'Export Session', label: i18next.t("menuUiHandler:exportSession"),
handler: () => { handler: () => {
const dataSlots: integer[] = []; const dataSlots: integer[] = [];
Promise.all( Promise.all(
@ -138,7 +139,7 @@ export default class MenuUiHandler extends MessageUiHandler {
dataSlots.push(slotId); dataSlots.push(slotId);
}) })
})).then(() => { })).then(() => {
confirmSlot('Select a slot to export from.', confirmSlot(i18next.t("menuUiHandler:exportSlotSelect"),
i => dataSlots.indexOf(i) > -1, i => dataSlots.indexOf(i) > -1,
slotId => this.scene.gameData.tryExportData(GameDataType.SESSION, slotId)); slotId => this.scene.gameData.tryExportData(GameDataType.SESSION, slotId));
}); });
@ -148,7 +149,7 @@ export default class MenuUiHandler extends MessageUiHandler {
}); });
if (Utils.isLocal) { if (Utils.isLocal) {
manageDataOptions.push({ manageDataOptions.push({
label: 'Import Data', label: i18next.t("menuUiHandler:importData"),
handler: () => { handler: () => {
this.scene.gameData.importData(GameDataType.SYSTEM); this.scene.gameData.importData(GameDataType.SYSTEM);
return true; return true;
@ -158,7 +159,7 @@ export default class MenuUiHandler extends MessageUiHandler {
} }
manageDataOptions.push( manageDataOptions.push(
{ {
label: 'Export Data', label: i18next.t("menuUiHandler:exportData"),
handler: () => { handler: () => {
this.scene.gameData.tryExportData(GameDataType.SYSTEM); this.scene.gameData.tryExportData(GameDataType.SYSTEM);
return true; return true;
@ -166,7 +167,7 @@ export default class MenuUiHandler extends MessageUiHandler {
keepOpen: true keepOpen: true
}, },
{ {
label: 'Cancel', label: i18next.t('menuUiHandler:cancel'),
handler: () => { handler: () => {
this.scene.ui.revertMode(); this.scene.ui.revertMode();
return true; return true;
@ -205,7 +206,7 @@ export default class MenuUiHandler extends MessageUiHandler {
keepOpen: true keepOpen: true
}, },
{ {
label: 'Cancel', label: i18next.t('menuUiHandler:cancel'),
handler: () => { handler: () => {
this.scene.ui.revertMode(); this.scene.ui.revertMode();
return true; return true;
@ -295,7 +296,7 @@ export default class MenuUiHandler extends MessageUiHandler {
case MenuOptions.RETURN_TO_TITLE: case MenuOptions.RETURN_TO_TITLE:
if (this.scene.currentBattle) { if (this.scene.currentBattle) {
success = true; 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.setOverlayMode(Mode.CONFIRM, () => this.scene.reset(true), () => {
ui.revertMode(); ui.revertMode();
ui.showText(null, 0); ui.showText(null, 0);
@ -315,7 +316,7 @@ export default class MenuUiHandler extends MessageUiHandler {
}); });
}; };
if (this.scene.currentBattle) { 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.setOverlayMode(Mode.CONFIRM, doLogout, () => {
ui.revertMode(); ui.revertMode();
ui.showText(null, 0); ui.showText(null, 0);

View File

@ -80,7 +80,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
this.updateTitleStats(); this.updateTitleStats();
this.titleStatsTimer = setInterval(() => this.updateTitleStats(), 10000); this.titleStatsTimer = setInterval(() => this.updateTitleStats(), 30000);
this.scene.tweens.add({ this.scene.tweens.add({
targets: [ this.titleContainer, ui.getMessageHandler().bg ], targets: [ this.titleContainer, ui.getMessageHandler().bg ],

View File

@ -212,8 +212,7 @@ export function executeIf<T>(condition: boolean, promiseFunc: () => Promise<T>):
export const sessionIdKey = 'pokerogue_sessionId'; export const sessionIdKey = 'pokerogue_sessionId';
export const isLocal = window.location.hostname === 'localhost'; export const isLocal = window.location.hostname === 'localhost';
export const serverUrl = isLocal ? 'http://localhost:8001' : ''; export const serverUrl = isLocal ? 'http://localhost:8001' : '';
export const apiUrl = isLocal ? serverUrl : 'https://api.pokerogue.net'; export const apiUrl = isLocal ? serverUrl : 'api';
export const fallbackApiUrl = isLocal ? serverUrl : 'api';
export function setCookie(cName: string, cValue: string): void { export function setCookie(cName: string, cValue: string): void {
const expiration = new Date(); const expiration = new Date();
@ -234,7 +233,7 @@ export function getCookie(cName: string): string {
return ''; return '';
} }
export function apiFetch(path: string, authed: boolean = false, fallback: boolean = false): Promise<Response> { export function apiFetch(path: string, authed: boolean = false): Promise<Response> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const request = {}; const request = {};
if (authed) { if (authed) {
@ -242,22 +241,13 @@ export function apiFetch(path: string, authed: boolean = false, fallback: boolea
if (sId) if (sId)
request['headers'] = { 'Authorization': sId }; request['headers'] = { 'Authorization': sId };
} }
fetch(`${!fallback ? apiUrl : fallbackApiUrl}/${path}`, request) fetch(`${apiUrl}/${path}`, request)
.then(response => { .then(response => resolve(response))
if (!response.ok && response.status === 404 && !fallback) .catch(err => reject(err));
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));
});
}); });
} }
export function apiPost(path: string, data?: any, contentType: string = 'application/json', authed: boolean = false, fallback: boolean = false): Promise<Response> { export function apiPost(path: string, data?: any, contentType: string = 'application/json', authed: boolean = false): Promise<Response> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const headers = { const headers = {
'Accept': contentType, 'Accept': contentType,
@ -268,14 +258,9 @@ export function apiPost(path: string, data?: any, contentType: string = 'applica
if (sId) if (sId)
headers['Authorization'] = 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)) .then(response => resolve(response))
.catch(err => { .catch(err => reject(err));
if (fallback)
reject(err);
else
apiPost(path, data, contentType, authed, true).then(res => resolve(res));
});
}); });
} }