mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +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]: [
|
[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 ],
|
||||||
|
@ -1004,7 +1004,7 @@ const modifierPool: ModifierPool = {
|
|||||||
new WeightedModifierType(modifierTypes.REVIVE, (party: Pokemon[]) => {
|
new WeightedModifierType(modifierTypes.REVIVE, (party: Pokemon[]) => {
|
||||||
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
||||||
return faintedPartyMemberCount * 9;
|
return faintedPartyMemberCount * 9;
|
||||||
}, 3),
|
}, 27),
|
||||||
new WeightedModifierType(modifierTypes.MAX_REVIVE, (party: Pokemon[]) => {
|
new WeightedModifierType(modifierTypes.MAX_REVIVE, (party: Pokemon[]) => {
|
||||||
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3);
|
||||||
return faintedPartyMemberCount * 3;
|
return faintedPartyMemberCount * 3;
|
||||||
|
@ -3575,10 +3575,11 @@ export class GameOverPhase extends BattlePhase {
|
|||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
this.handleUnlocks();
|
this.handleUnlocks();
|
||||||
if (this.victory && !firstClear && success[1]) {
|
if (this.victory && success[1]) {
|
||||||
for (let species of this.firstRibbons)
|
for (let species of this.firstRibbons)
|
||||||
this.scene.unshiftPhase(new RibbonModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PLUS, species));
|
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.reset();
|
||||||
this.scene.unshiftPhase(new TitlePhase(this.scene));
|
this.scene.unshiftPhase(new TitlePhase(this.scene));
|
||||||
|
@ -250,58 +250,52 @@ export class GameData {
|
|||||||
public saveSystem(): Promise<boolean> {
|
public saveSystem(): Promise<boolean> {
|
||||||
return new Promise<boolean>(resolve => {
|
return new Promise<boolean>(resolve => {
|
||||||
this.scene.ui.savingIcon.show();
|
this.scene.ui.savingIcon.show();
|
||||||
updateUserInfo().then(response => {
|
const data: SystemSaveData = {
|
||||||
if (!response[0]) {
|
trainerId: this.trainerId,
|
||||||
this.scene.ui.savingIcon.hide();
|
secretId: this.secretId,
|
||||||
return resolve(false);
|
gender: this.gender,
|
||||||
}
|
dexData: this.dexData,
|
||||||
const data: SystemSaveData = {
|
starterData: this.starterData,
|
||||||
trainerId: this.trainerId,
|
gameStats: this.gameStats,
|
||||||
secretId: this.secretId,
|
unlocks: this.unlocks,
|
||||||
gender: this.gender,
|
achvUnlocks: this.achvUnlocks,
|
||||||
dexData: this.dexData,
|
voucherUnlocks: this.voucherUnlocks,
|
||||||
starterData: this.starterData,
|
voucherCounts: this.voucherCounts,
|
||||||
gameStats: this.gameStats,
|
eggs: this.eggs.map(e => new EggData(e)),
|
||||||
unlocks: this.unlocks,
|
gameVersion: this.scene.game.config.gameVersion,
|
||||||
achvUnlocks: this.achvUnlocks,
|
timestamp: new Date().getTime()
|
||||||
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 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 systemData = JSON.stringify(data, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v);
|
||||||
|
|
||||||
if (!bypassLogin) {
|
if (!bypassLogin) {
|
||||||
Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true)
|
Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(error => {
|
.then(error => {
|
||||||
this.scene.ui.savingIcon.hide();
|
this.scene.ui.savingIcon.hide();
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.startsWith('client version out of date')) {
|
if (error.startsWith('client version out of date')) {
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
|
this.scene.unshiftPhase(new OutdatedPhase(this.scene));
|
||||||
} else if (error.startsWith('session out of date')) {
|
} else if (error.startsWith('session out of date')) {
|
||||||
this.scene.clearPhaseQueue();
|
this.scene.clearPhaseQueue();
|
||||||
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene));
|
||||||
}
|
|
||||||
console.error(error);
|
|
||||||
return resolve(false);
|
|
||||||
}
|
}
|
||||||
resolve(true);
|
console.error(error);
|
||||||
});
|
return resolve(false);
|
||||||
} else {
|
}
|
||||||
localStorage.setItem('data_bak', localStorage.getItem('data'));
|
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.legendaryPokemonHatched = source?.legendaryPokemonHatched || 0;
|
||||||
this.mythicalPokemonSeen = source?.mythicalPokemonSeen || 0;
|
this.mythicalPokemonSeen = source?.mythicalPokemonSeen || 0;
|
||||||
this.mythicalPokemonCaught = source?.mythicalPokemonCaught || 0;
|
this.mythicalPokemonCaught = source?.mythicalPokemonCaught || 0;
|
||||||
this.mythicalPokemonHatched = source?.mythicalPokemonCaught || 0;
|
this.mythicalPokemonHatched = source?.mythicalPokemonHatched || 0;
|
||||||
this.shinyPokemonSeen = source?.shinyPokemonSeen || 0;
|
this.shinyPokemonSeen = source?.shinyPokemonSeen || 0;
|
||||||
this.shinyPokemonCaught = source?.shinyPokemonCaught || 0;
|
this.shinyPokemonCaught = source?.shinyPokemonCaught || 0;
|
||||||
this.shinyPokemonHatched = source?.shinyPokemonHatched || 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 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));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user