Merge branch 'pagefaultgames:main' into Fix_Sturdy

This commit is contained in:
Douglas Marchione de Souza 2024-05-08 01:00:35 -03:00 committed by GitHub
commit 10d42e14c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 27 deletions

View File

@ -4305,12 +4305,12 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[Species.GROVYLE]: [ [Species.GROVYLE]: [
[ 1, Moves.POUND ], [ 1, Moves.POUND ],
[ 1, Moves.LEER ], [ 1, Moves.LEER ],
[ 1, Moves.LEAFAGE ],
[ 1, Moves.QUICK_ATTACK ], [ 1, Moves.QUICK_ATTACK ],
[ 1, Moves.FALSE_SWIPE ], [ 1, Moves.FALSE_SWIPE ],
[ 1, Moves.FURY_CUTTER ], [ 1, Moves.FURY_CUTTER ],
[ 1, Moves.X_SCISSOR ], [ 1, Moves.X_SCISSOR ],
[ 1, Moves.ENERGY_BALL ], [ 1, Moves.ENERGY_BALL ],
[ 1, Moves.LEAFAGE ],
[ 9, Moves.MEGA_DRAIN ], [ 9, Moves.MEGA_DRAIN ],
[ 12, Moves.DETECT ], [ 12, Moves.DETECT ],
[ 15, Moves.QUICK_GUARD ], [ 15, Moves.QUICK_GUARD ],
@ -4324,15 +4324,16 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 55, Moves.LEAF_STORM ], [ 55, Moves.LEAF_STORM ],
], ],
[Species.SCEPTILE]: [ [Species.SCEPTILE]: [
[ 0, Moves.DUAL_CHOP ], [ 0, Moves.LEAF_BLADE ],
[ 1, Moves.POUND ], [ 1, Moves.POUND ],
[ 1, Moves.LEER ], [ 1, Moves.LEER ],
[ 1, Moves.LEAFAGE ],
[ 1, Moves.QUICK_ATTACK ], [ 1, Moves.QUICK_ATTACK ],
[ 1, Moves.FALSE_SWIPE ], [ 1, Moves.FALSE_SWIPE ],
[ 1, Moves.FURY_CUTTER ], [ 1, Moves.FURY_CUTTER ],
[ 1, Moves.X_SCISSOR ], [ 1, Moves.X_SCISSOR ],
[ 1, Moves.ENERGY_BALL ], [ 1, Moves.ENERGY_BALL ],
[ 1, Moves.LEAFAGE ], [ 1, Moves.SHED_TAIL ],
[ 5, Moves.MEGA_DRAIN ], [ 5, Moves.MEGA_DRAIN ],
[ 12, Moves.DETECT ], [ 12, Moves.DETECT ],
[ 15, Moves.QUICK_GUARD ], [ 15, Moves.QUICK_GUARD ],
@ -4340,10 +4341,9 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 25, Moves.GIGA_DRAIN ], [ 25, Moves.GIGA_DRAIN ],
[ 30, Moves.SLAM ], [ 30, Moves.SLAM ],
[ 35, Moves.DOUBLE_TEAM ], [ 35, Moves.DOUBLE_TEAM ],
[ 42, Moves.LEAF_BLADE ], [ 42, Moves.SCREECH ],
[ 49, Moves.SCREECH ], [ 49, Moves.ENDEAVOR ],
[ 56, Moves.ENDEAVOR ], [ 56, Moves.LEAF_STORM ],
[ 63, Moves.LEAF_STORM ],
], ],
[Species.TORCHIC]: [ [Species.TORCHIC]: [
[ 1, Moves.SCRATCH ], [ 1, Moves.SCRATCH ],
@ -4367,9 +4367,9 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 1, Moves.SCRATCH ], [ 1, Moves.SCRATCH ],
[ 1, Moves.GROWL ], [ 1, Moves.GROWL ],
[ 1, Moves.EMBER ], [ 1, Moves.EMBER ],
[ 1, Moves.QUICK_ATTACK ],
[ 1, Moves.FLAMETHROWER ], [ 1, Moves.FLAMETHROWER ],
[ 1, Moves.QUICK_ATTACK ], [ 1, Moves.FEATHER_DANCE ],
[ 1, Moves.FEATHER_DANCE ],
[ 9, Moves.FLAME_CHARGE ], [ 9, Moves.FLAME_CHARGE ],
[ 12, Moves.DETECT ], [ 12, Moves.DETECT ],
[ 15, Moves.SAND_ATTACK ], [ 15, Moves.SAND_ATTACK ],
@ -4399,10 +4399,10 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 25, Moves.SLASH ], [ 25, Moves.SLASH ],
[ 30, Moves.BOUNCE ], [ 30, Moves.BOUNCE ],
[ 35, Moves.FOCUS_ENERGY ], [ 35, Moves.FOCUS_ENERGY ],
[ 42, Moves.BLAZE_KICK ], [ 42, Moves.BULK_UP ],
[ 49, Moves.BULK_UP ], [ 49, Moves.REVERSAL ],
[ 56, Moves.REVERSAL ], [ 56, Moves.FLARE_BLITZ ],
[ 63, Moves.FLARE_BLITZ ], [ 63, Moves.BRAVE_BIRD ],
], ],
[Species.MUDKIP]: [ [Species.MUDKIP]: [
[ 1, Moves.TACKLE ], [ 1, Moves.TACKLE ],
@ -4426,8 +4426,6 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 1, Moves.TACKLE ], [ 1, Moves.TACKLE ],
[ 1, Moves.GROWL ], [ 1, Moves.GROWL ],
[ 1, Moves.WATER_GUN ], [ 1, Moves.WATER_GUN ],
[ 1, Moves.SURF ],
[ 1, Moves.EARTHQUAKE ],
[ 1, Moves.ROCK_SMASH ], [ 1, Moves.ROCK_SMASH ],
[ 9, Moves.ROCK_THROW ], [ 9, Moves.ROCK_THROW ],
[ 12, Moves.PROTECT ], [ 12, Moves.PROTECT ],
@ -4442,13 +4440,13 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 55, Moves.HYDRO_PUMP ], [ 55, Moves.HYDRO_PUMP ],
], ],
[Species.SWAMPERT]: [ [Species.SWAMPERT]: [
[ 1, Moves.MUD_SHOT ],
[ 1, Moves.TACKLE ], [ 1, Moves.TACKLE ],
[ 1, Moves.GROWL ], [ 1, Moves.GROWL ],
[ 1, Moves.WATER_GUN ], [ 1, Moves.WATER_GUN ],
[ 1, Moves.SURF ], [ 1, Moves.SURF ],
[ 1, Moves.EARTHQUAKE ], [ 1, Moves.EARTHQUAKE ],
[ 1, Moves.ROCK_SMASH ], [ 1, Moves.ROCK_SMASH ],
[ 1, Moves.MUD_SHOT ],
[ 1, Moves.HAMMER_ARM ], [ 1, Moves.HAMMER_ARM ],
[ 9, Moves.ROCK_THROW ], [ 9, Moves.ROCK_THROW ],
[ 12, Moves.PROTECT ], [ 12, Moves.PROTECT ],

View File

@ -222,7 +222,8 @@ 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 : 'api'; export const apiUrl = isLocal ? serverUrl : 'https://api.pokerogue.net';
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();
@ -243,7 +244,7 @@ export function getCookie(cName: string): string {
return ''; return '';
} }
export function apiFetch(path: string, authed: boolean = false): Promise<Response> { export function apiFetch(path: string, authed: boolean = false, fallback: boolean = false): Promise<Response> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const request = {}; const request = {};
if (authed) { if (authed) {
@ -251,13 +252,22 @@ export function apiFetch(path: string, authed: boolean = false): Promise<Respons
if (sId) if (sId)
request['headers'] = { 'Authorization': sId }; request['headers'] = { 'Authorization': sId };
} }
fetch(`${apiUrl}/${path}`, request) fetch(`${!fallback ? apiUrl : fallbackApiUrl}/${path}`, request)
.then(response => resolve(response)) .then(response => {
.catch(err => reject(err)); 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));
});
}); });
} }
export function apiPost(path: string, data?: any, contentType: string = 'application/json', authed: boolean = false): Promise<Response> { export function apiPost(path: string, data?: any, contentType: string = 'application/json', authed: boolean = false, fallback: boolean = false): Promise<Response> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const headers = { const headers = {
'Accept': contentType, 'Accept': contentType,
@ -268,9 +278,14 @@ export function apiPost(path: string, data?: any, contentType: string = 'applica
if (sId) if (sId)
headers['Authorization'] = sId; headers['Authorization'] = sId;
} }
fetch(`${apiUrl}/${path}`, { method: 'POST', headers: headers, body: data }) fetch(`${!fallback ? apiUrl : fallbackApiUrl}/${path}`, { method: 'POST', headers: headers, body: data })
.then(response => resolve(response)) .then(response => resolve(response))
.catch(err => reject(err)); .catch(err => {
if (fallback)
reject(err);
else
apiPost(path, data, contentType, authed, true).then(res => resolve(res));
});
}); });
} }