Compare commits

...

6 Commits

Author SHA1 Message Date
Flashfyre
08067d9937 Revert "Revert API URL change"
This reverts commit 4ef6707333.
2024-05-07 16:16:22 -04:00
Benjamin Odom
bd839a1ffb
FIx Sceptile and Blaziken Learnsets (#606)
These got missed in the transition from looking at Serebii and Bulbapedia for data.
2024-05-07 13:42:07 -05:00
Flashfyre
72b4552b01 Don't update user info on save for optimization 2024-05-07 13:36:52 -04:00
Tempoanon
4fcea107ab
Fix wrong stat displayed for mythicals hatched (#601) 2024-05-07 12:10:48 -05:00
Xavion3
cc3113ff43 Fix revive weight cap 2024-05-07 11:26:28 -04:00
Flashfyre
02b2c2d55b Ribbons are also awarded for first clear 2024-05-07 10:15:40 -04:00
6 changed files with 85 additions and 77 deletions

View File

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

View File

@ -1004,7 +1004,7 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.REVIVE, (party: Pokemon[]) => {
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
return faintedPartyMemberCount * 9;
}, 3),
}, 27),
new WeightedModifierType(modifierTypes.MAX_REVIVE, (party: Pokemon[]) => {
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
return faintedPartyMemberCount * 3;

View File

@ -3575,10 +3575,11 @@ export class GameOverPhase extends BattlePhase {
this.scene.clearPhaseQueue();
this.scene.ui.clearText();
this.handleUnlocks();
if (this.victory && !firstClear && success[1]) {
if (this.victory && success[1]) {
for (let species of this.firstRibbons)
this.scene.unshiftPhase(new RibbonModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PLUS, species));
this.scene.unshiftPhase(new GameOverModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PREMIUM));
if (!firstClear)
this.scene.unshiftPhase(new GameOverModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PREMIUM));
}
this.scene.reset();
this.scene.unshiftPhase(new TitlePhase(this.scene));

View File

@ -250,58 +250,52 @@ export class GameData {
public saveSystem(): Promise<boolean> {
return new Promise<boolean>(resolve => {
this.scene.ui.savingIcon.show();
updateUserInfo().then(response => {
if (!response[0]) {
this.scene.ui.savingIcon.hide();
return resolve(false);
}
const data: SystemSaveData = {
trainerId: this.trainerId,
secretId: this.secretId,
gender: this.gender,
dexData: this.dexData,
starterData: this.starterData,
gameStats: this.gameStats,
unlocks: this.unlocks,
achvUnlocks: this.achvUnlocks,
voucherUnlocks: this.voucherUnlocks,
voucherCounts: this.voucherCounts,
eggs: this.eggs.map(e => new EggData(e)),
gameVersion: this.scene.game.config.gameVersion,
timestamp: new Date().getTime()
};
const data: SystemSaveData = {
trainerId: this.trainerId,
secretId: this.secretId,
gender: this.gender,
dexData: this.dexData,
starterData: this.starterData,
gameStats: this.gameStats,
unlocks: this.unlocks,
achvUnlocks: this.achvUnlocks,
voucherUnlocks: this.voucherUnlocks,
voucherCounts: this.voucherCounts,
eggs: this.eggs.map(e => new EggData(e)),
gameVersion: this.scene.game.config.gameVersion,
timestamp: new Date().getTime()
};
const maxIntAttrValue = Math.pow(2, 31);
const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
const maxIntAttrValue = Math.pow(2, 31);
const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
if (!bypassLogin) {
Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true)
.then(response => response.text())
.then(error => {
this.scene.ui.savingIcon.hide();
if (error) {
if (error.startsWith('client version out of date')) {
this.scene.clearPhaseQueue();
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
} else if (error.startsWith('session out of date')) {
this.scene.clearPhaseQueue();
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
}
console.error(error);
return resolve(false);
if (!bypassLogin) {
Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true)
.then(response => response.text())
.then(error => {
this.scene.ui.savingIcon.hide();
if (error) {
if (error.startsWith('client version out of date')) {
this.scene.clearPhaseQueue();
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
} else if (error.startsWith('session out of date')) {
this.scene.clearPhaseQueue();
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
}
resolve(true);
});
} else {
localStorage.setItem('data_bak', localStorage.getItem('data'));
console.error(error);
return resolve(false);
}
resolve(true);
});
} else {
localStorage.setItem('data_bak', localStorage.getItem('data'));
localStorage.setItem('data', btoa(systemData));
localStorage.setItem('data', btoa(systemData));
this.scene.ui.savingIcon.hide();
this.scene.ui.savingIcon.hide();
resolve(true);
}
});
resolve(true);
}
});
}

View File

@ -66,7 +66,7 @@ export class GameStats {
this.legendaryPokemonHatched = source?.legendaryPokemonHatched || 0;
this.mythicalPokemonSeen = source?.mythicalPokemonSeen || 0;
this.mythicalPokemonCaught = source?.mythicalPokemonCaught || 0;
this.mythicalPokemonHatched = source?.mythicalPokemonCaught || 0;
this.mythicalPokemonHatched = source?.mythicalPokemonHatched || 0;
this.shinyPokemonSeen = source?.shinyPokemonSeen || 0;
this.shinyPokemonCaught = source?.shinyPokemonCaught || 0;
this.shinyPokemonHatched = source?.shinyPokemonHatched || 0;

View File

@ -222,7 +222,8 @@ export function executeIf<T>(condition: boolean, promiseFunc: () => Promise<T>):
export const sessionIdKey = 'pokerogue_sessionId';
export const isLocal = window.location.hostname === 'localhost';
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 {
const expiration = new Date();
@ -243,7 +244,7 @@ export function getCookie(cName: string): string {
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) => {
const request = {};
if (authed) {
@ -251,13 +252,22 @@ export function apiFetch(path: string, authed: boolean = false): Promise<Respons
if (sId)
request['headers'] = { 'Authorization': sId };
}
fetch(`${apiUrl}/${path}`, request)
.then(response => resolve(response))
.catch(err => reject(err));
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));
});
});
}
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) => {
const headers = {
'Accept': contentType,
@ -268,9 +278,14 @@ export function apiPost(path: string, data?: any, contentType: string = 'applica
if (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))
.catch(err => reject(err));
.catch(err => {
if (fallback)
reject(err);
else
apiPost(path, data, contentType, authed, true).then(res => resolve(res));
});
});
}