mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 07:22:19 +02:00
Compare commits
6 Commits
b9ce5cfaaa
...
08067d9937
Author | SHA1 | Date | |
---|---|---|---|
|
08067d9937 | ||
|
bd839a1ffb | ||
|
72b4552b01 | ||
|
4fcea107ab | ||
|
cc3113ff43 | ||
|
02b2c2d55b |
@ -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 ],
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
31
src/utils.ts
31
src/utils.ts
@ -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));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user