From 1c56efc860d5531d754c07f8785aa9cf8d0603af Mon Sep 17 00:00:00 2001 From: Benjamin Odom Date: Mon, 13 May 2024 18:12:28 -0500 Subject: [PATCH 1/9] Added Ability Triggers Localization (#811) Adds the base files needed to start translating Ability trigger messages. Provides one as an example. --- src/data/ability.ts | 4 ++-- src/locales/de/ability-trigger.ts | 5 +++++ src/locales/de/config.ts | 2 ++ src/locales/en/ability-trigger.ts | 5 +++++ src/locales/en/config.ts | 4 +++- src/locales/es/ability-trigger.ts | 5 +++++ src/locales/es/config.ts | 2 ++ src/locales/fr/ability-trigger.ts | 5 +++++ src/locales/fr/config.ts | 2 ++ src/locales/it/ability-trigger.ts | 5 +++++ src/locales/it/config.ts | 2 ++ src/locales/zh_CN/ability-trigger.ts | 5 +++++ src/locales/zh_CN/config.ts | 2 ++ src/plugins/i18n.ts | 3 ++- 14 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 src/locales/de/ability-trigger.ts create mode 100644 src/locales/en/ability-trigger.ts create mode 100644 src/locales/es/ability-trigger.ts create mode 100644 src/locales/fr/ability-trigger.ts create mode 100644 src/locales/it/ability-trigger.ts create mode 100644 src/locales/zh_CN/ability-trigger.ts diff --git a/src/data/ability.ts b/src/data/ability.ts index b2899a33ff2..5ef07c39f7b 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3,7 +3,7 @@ import { Type } from "./type"; import * as Utils from "../utils"; import { BattleStat, getBattleStatName } from "./battle-stat"; import { PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases"; -import { getPokemonMessage } from "../messages"; +import { getPokemonMessage, getPokemonPrefix } from "../messages"; import { Weather, WeatherType } from "./weather"; import { BattlerTag } from "./battler-tags"; import { BattlerTagType } from "./enums/battler-tag-type"; @@ -144,7 +144,7 @@ export class BlockRecoilDamageAttr extends AbAttr { } getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]) { - return getPokemonMessage(pokemon, `'s ${abilityName}\nprotected it from recoil!`); + return i18next.t('abilityTriggers:blockRecoilDamage', {pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, abilityName: abilityName}); } } diff --git a/src/locales/de/ability-trigger.ts b/src/locales/de/ability-trigger.ts new file mode 100644 index 00000000000..88900741218 --- /dev/null +++ b/src/locales/de/ability-trigger.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, +} as const; \ No newline at end of file diff --git a/src/locales/de/config.ts b/src/locales/de/config.ts index 2cc7a52c8f1..a9f4cd68297 100644 --- a/src/locales/de/config.ts +++ b/src/locales/de/config.ts @@ -1,4 +1,5 @@ import { ability } from "./ability"; +import { abilityTriggers } from "./ability-trigger"; import { battle } from "./battle"; import { commandUiHandler } from "./command-ui-handler"; import { fightUiHandler } from "./fight-ui-handler"; @@ -16,6 +17,7 @@ import { tutorial } from "./tutorial"; export const deConfig = { ability: ability, + abilityTriggers: abilityTriggers, battle: battle, commandUiHandler: commandUiHandler, fightUiHandler: fightUiHandler, diff --git a/src/locales/en/ability-trigger.ts b/src/locales/en/ability-trigger.ts new file mode 100644 index 00000000000..88900741218 --- /dev/null +++ b/src/locales/en/ability-trigger.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, +} as const; \ No newline at end of file diff --git a/src/locales/en/config.ts b/src/locales/en/config.ts index 029791a701c..f5e8a68b09c 100644 --- a/src/locales/en/config.ts +++ b/src/locales/en/config.ts @@ -1,4 +1,5 @@ import { ability } from "./ability"; +import { abilityTriggers } from "./ability-trigger"; import { battle } from "./battle"; import { commandUiHandler } from "./command-ui-handler"; import { fightUiHandler } from "./fight-ui-handler"; @@ -14,8 +15,9 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { tutorial } from "./tutorial"; -export const enConfig = { +export const enConfig = { ability: ability, + abilityTriggers: abilityTriggers, battle: battle, commandUiHandler: commandUiHandler, fightUiHandler: fightUiHandler, diff --git a/src/locales/es/ability-trigger.ts b/src/locales/es/ability-trigger.ts new file mode 100644 index 00000000000..88900741218 --- /dev/null +++ b/src/locales/es/ability-trigger.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, +} as const; \ No newline at end of file diff --git a/src/locales/es/config.ts b/src/locales/es/config.ts index 564b8dd320d..c56a8d384c2 100644 --- a/src/locales/es/config.ts +++ b/src/locales/es/config.ts @@ -1,4 +1,5 @@ import { ability } from "./ability"; +import { abilityTriggers } from "./ability-trigger"; import { battle } from "./battle"; import { commandUiHandler } from "./command-ui-handler"; import { fightUiHandler } from "./fight-ui-handler"; @@ -16,6 +17,7 @@ import { tutorial } from "./tutorial"; export const esConfig = { ability: ability, + abilityTriggers: abilityTriggers, battle: battle, commandUiHandler: commandUiHandler, fightUiHandler: fightUiHandler, diff --git a/src/locales/fr/ability-trigger.ts b/src/locales/fr/ability-trigger.ts new file mode 100644 index 00000000000..88900741218 --- /dev/null +++ b/src/locales/fr/ability-trigger.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, +} as const; \ No newline at end of file diff --git a/src/locales/fr/config.ts b/src/locales/fr/config.ts index 90f9fb83c53..89669aceb73 100644 --- a/src/locales/fr/config.ts +++ b/src/locales/fr/config.ts @@ -1,4 +1,5 @@ import { ability } from "./ability"; +import { abilityTriggers } from "./ability-trigger"; import { battle } from "./battle"; import { commandUiHandler } from "./command-ui-handler"; import { fightUiHandler } from "./fight-ui-handler"; @@ -16,6 +17,7 @@ import { tutorial } from "./tutorial"; export const frConfig = { ability: ability, + abilityTriggers: abilityTriggers, battle: battle, commandUiHandler: commandUiHandler, fightUiHandler: fightUiHandler, diff --git a/src/locales/it/ability-trigger.ts b/src/locales/it/ability-trigger.ts new file mode 100644 index 00000000000..88900741218 --- /dev/null +++ b/src/locales/it/ability-trigger.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, +} as const; \ No newline at end of file diff --git a/src/locales/it/config.ts b/src/locales/it/config.ts index bbfd452dc39..6ba9aa3affa 100644 --- a/src/locales/it/config.ts +++ b/src/locales/it/config.ts @@ -1,4 +1,5 @@ import { ability } from "./ability"; +import { abilityTriggers } from "./ability-trigger"; import { battle } from "./battle"; import { commandUiHandler } from "./command-ui-handler"; import { fightUiHandler } from "./fight-ui-handler"; @@ -16,6 +17,7 @@ import { tutorial } from "./tutorial"; export const itConfig = { ability: ability, + abilityTriggers: abilityTriggers, battle: battle, commandUiHandler: commandUiHandler, fightUiHandler: fightUiHandler, diff --git a/src/locales/zh_CN/ability-trigger.ts b/src/locales/zh_CN/ability-trigger.ts new file mode 100644 index 00000000000..88900741218 --- /dev/null +++ b/src/locales/zh_CN/ability-trigger.ts @@ -0,0 +1,5 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, +} as const; \ No newline at end of file diff --git a/src/locales/zh_CN/config.ts b/src/locales/zh_CN/config.ts index a8f5f878ba0..496fd983c06 100644 --- a/src/locales/zh_CN/config.ts +++ b/src/locales/zh_CN/config.ts @@ -1,4 +1,5 @@ import { ability } from "./ability"; +import { abilityTriggers } from "./ability-trigger"; import { battle } from "./battle"; import { commandUiHandler } from "./command-ui-handler"; import { fightUiHandler } from "./fight-ui-handler"; @@ -15,6 +16,7 @@ import { nature } from "./nature"; export const zhCnConfig = { ability: ability, + abilityTriggers: abilityTriggers, battle: battle, commandUiHandler: commandUiHandler, fightUiHandler: fightUiHandler, diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 676e691ee29..82a5a51ba12 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -98,7 +98,8 @@ declare module 'i18next' { menu: SimpleTranslationEntries; menuUiHandler: SimpleTranslationEntries; move: MoveTranslationEntries; - battle: SimpleTranslationEntries, + battle: SimpleTranslationEntries; + abilityTriggers: SimpleTranslationEntries; ability: AbilityTranslationEntries; pokeball: SimpleTranslationEntries; pokemon: SimpleTranslationEntries; From 19d244ee949ef071847dce2806b2a1ac9e367798 Mon Sep 17 00:00:00 2001 From: JackGilham <46994951+JackGilham@users.noreply.github.com> Date: Tue, 14 May 2024 00:38:27 +0100 Subject: [PATCH 2/9] Update modifier-type.ts (#636) Issue#613. Have added additional EvolutionItemModifierType condition that prevents none base form pokes from taking Evo Items. --- src/modifier/modifier-type.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 2457a705bce..6b336523014 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -554,10 +554,10 @@ export class EvolutionItemModifierType extends PokemonModifierType implements Ge super(Utils.toReadableString(EvolutionItem[evolutionItem]), `Causes certain Pokémon to evolve`, (_type, args) => new Modifiers.EvolutionItemModifier(this, (args[0] as PlayerPokemon).id), (pokemon: PlayerPokemon) => { if (pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) && pokemonEvolutions[pokemon.species.speciesId].filter(e => e.item === this.evolutionItem - && (!e.condition || e.condition.predicate(pokemon))).length) + && (!e.condition || e.condition.predicate(pokemon))).length && (pokemon.formIndex == 0)) return null; else if (pokemon.isFusion() && pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) && pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(e => e.item === this.evolutionItem - && (!e.condition || e.condition.predicate(pokemon))).length) + && (!e.condition || e.condition.predicate(pokemon))).length && (pokemon.fusionFormIndex == 0)) return null; return PartyUiHandler.NoEffectMessage; From 1d29ca797462ceeff3dbdbc9d005ec9c9ead113b Mon Sep 17 00:00:00 2001 From: LaukkaE <73663099+LaukkaE@users.noreply.github.com> Date: Tue, 14 May 2024 02:48:22 +0300 Subject: [PATCH 3/9] Fix Comeuppance (#781) --- src/data/move.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/move.ts b/src/data/move.ts index 652e832fdd6..2b61d30b82c 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -6841,7 +6841,7 @@ export function initMoves() { const turnMove = user.getLastXMoves(1); return !turnMove.length || turnMove[0].move !== move.id || turnMove[0].result !== MoveResult.SUCCESS; }), // TODO Add Instruct/Encore interaction - new AttackMove(Moves.COMEUPPANCE, Type.DARK, MoveCategory.PHYSICAL, 1, 100, 10, -1, 0, 9) + new AttackMove(Moves.COMEUPPANCE, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 9) .attr(CounterDamageAttr, (move: Move) => (move.category === MoveCategory.PHYSICAL || move.category === MoveCategory.SPECIAL), 1.5) .target(MoveTarget.ATTACKER), new AttackMove(Moves.AQUA_CUTTER, Type.WATER, MoveCategory.PHYSICAL, 70, 100, 20, -1, 0, 9) From af86bdeb068388c2aa8d835c8e1413a335d99563 Mon Sep 17 00:00:00 2001 From: LaukkaE <73663099+LaukkaE@users.noreply.github.com> Date: Tue, 14 May 2024 02:48:47 +0300 Subject: [PATCH 4/9] Prevent applying item boosts when power is <1 (#795) * Prevent applying item boosts when power is <1 * add comments --- src/modifier/modifier.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index ba009cb7a8d..8a5fba17d1c 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -635,6 +635,9 @@ export class PokemonBaseStatModifier extends PokemonHeldItemModifier { } } + /** + * Applies Specific Type item boosts (e.g., Magnet) + */ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { private moveType: Type; private boostMultiplier: number; @@ -667,8 +670,15 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { return super.shouldApply(args) && args.length === 3 && typeof args[1] === 'number' && args[2] instanceof Utils.NumberHolder; } + /** + * @param {Array} args Array + * - Index 0: {Pokemon} Pokemon + * - Index 1: {number} Move type + * - Index 2: {Utils.NumberHolder} Move power + * @returns {boolean} Returns true if boosts have been applied to the move. + */ apply(args: any[]): boolean { - if (args[1] === this.moveType) { + if (args[1] === this.moveType && (args[2] as Utils.NumberHolder).value >= 1) { (args[2] as Utils.NumberHolder).value = Math.floor((args[2] as Utils.NumberHolder).value * (1 + (this.getStackCount() * this.boostMultiplier))); return true; } From 9d90cc3e1060c70228da61d07488e819f3031815 Mon Sep 17 00:00:00 2001 From: YounesM Date: Tue, 14 May 2024 01:52:36 +0200 Subject: [PATCH 5/9] corrected uturn flip turn crash (#596) --- src/field/damage-number-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/field/damage-number-handler.ts b/src/field/damage-number-handler.ts index f4a3d570e19..262ff8863d0 100644 --- a/src/field/damage-number-handler.ts +++ b/src/field/damage-number-handler.ts @@ -13,7 +13,7 @@ export default class DamageNumberHandler { add(target: Pokemon, amount: integer, result: DamageResult | HitResult.HEAL = HitResult.EFFECTIVE, critical: boolean = false): void { const scene = target.scene; - if (!scene.damageNumbersMode) + if (!scene?.damageNumbersMode) return; const battlerIndex = target.getBattlerIndex(); From ab92bc61ba2babee9ab917f79177aea092b669a2 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 13 May 2024 20:56:19 -0400 Subject: [PATCH 6/9] Revert "Only show save icon on server sync" This reverts commit 5d0dbfff98c19284a6fc65f0f36666a0011b86a6. --- src/system/game-data.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index d0e296cc4c0..90722d1ce37 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -809,8 +809,7 @@ export class GameData { Utils.executeIf(!skipVerification, updateUserInfo).then(success => { if (success !== null && !success) return resolve(false); - if (sync) - this.scene.ui.savingIcon.show(); + this.scene.ui.savingIcon.show(); const sessionData = this.getSessionSaveData(scene); const maxIntAttrValue = Math.pow(2, 31); @@ -826,8 +825,7 @@ export class GameData { Utils.apiPost('savedata/updateall', JSON.stringify(request, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v), undefined, true) .then(response => response.text()) .then(error => { - if (sync) - this.scene.ui.savingIcon.hide(); + this.scene.ui.savingIcon.hide(); if (error) { if (error.startsWith('client version out of date')) { this.scene.clearPhaseQueue(); From 794363348199fd0df31dc0ba394b6c88a4da561c Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 13 May 2024 20:56:28 -0400 Subject: [PATCH 7/9] Revert "Implement hybrid saving for optimization" This reverts commit b45cd2f7e79fbe2ea65b8148ebbefccdf28bbb3f. --- src/phases.ts | 2 +- src/system/game-data.ts | 104 ++++++++++++++++++++++------------------ 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 6cc6af93ef9..271e5350c82 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -775,7 +775,7 @@ export class EncounterPhase extends BattlePhase { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (!this.loaded) { - this.scene.gameData.saveAll(this.scene, true, battle.waveIndex % 5 === 1).then(success => { + this.scene.gameData.saveAll(this.scene, true).then(success => { this.scene.disableMenu = false; if (!success) return this.scene.reset(true); diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 90722d1ce37..7f6e1475b4a 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -277,7 +277,7 @@ export class GameData { 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 && !localStorage.getItem('data')) { + if (!bypassLogin) { Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true) .then(response => response.text()) .then(error => { @@ -293,15 +293,12 @@ export class GameData { console.error(error); return resolve(false); } - localStorage.removeItem('data'); resolve(true); }); } else { - const encFunc = bypassLogin - ? (data: string) => btoa(data) - : (data: string) => AES.encrypt(data, saveKey); + localStorage.setItem('data_bak', localStorage.getItem('data')); - localStorage.setItem('data', encFunc(systemData)); + localStorage.setItem('data', btoa(systemData)); this.scene.ui.savingIcon.hide(); @@ -312,7 +309,7 @@ export class GameData { public loadSystem(): Promise { return new Promise(resolve => { - if (bypassLogin && !localStorage.getItem('data')) + if (bypassLogin && !localStorage.hasOwnProperty('data')) return resolve(false); const handleSystemData = (systemDataStr: string) => { @@ -424,7 +421,7 @@ export class GameData { } } - if (!bypassLogin && !localStorage.getItem('data')) { + if (!bypassLogin) { Utils.apiFetch(`savedata/get?datatype=${GameDataType.SYSTEM}`, true) .then(response => response.text()) .then(response => { @@ -442,12 +439,8 @@ export class GameData { handleSystemData(response); }); - } else { - const decFunc = bypassLogin - ? (data: string) => atob(data) - : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8); - handleSystemData(decFunc(localStorage.getItem('data'))); - } + } else + handleSystemData(atob(localStorage.getItem('data'))); }); } @@ -564,6 +557,40 @@ export class GameData { } as SessionSaveData; } + saveSession(scene: BattleScene, skipVerification?: boolean): Promise { + return new Promise(resolve => { + Utils.executeIf(!skipVerification, updateUserInfo).then(success => { + if (success !== null && !success) + return resolve(false); + + const sessionData = this.getSessionSaveData(scene); + + if (!bypassLogin) { + 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(error => { + if (error) { + if (error.startsWith('session out of date')) { + this.scene.clearPhaseQueue(); + this.scene.unshiftPhase(new ReloadSessionPhase(this.scene)); + } + console.error(error); + return resolve(false); + } + console.debug('Session data saved'); + resolve(true); + }); + } else { + localStorage.setItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ''}`, btoa(JSON.stringify(sessionData))); + + console.debug('Session data saved'); + + resolve(true); + } + }); + }); + } + getSession(slotId: integer): Promise { return new Promise(async (resolve, reject) => { if (slotId < 0) @@ -578,7 +605,7 @@ export class GameData { } }; - if (!bypassLogin && !localStorage.getItem(`sessionData${slotId ? slotId : ''}`)) { + if (!bypassLogin) { Utils.apiFetch(`savedata/get?datatype=${GameDataType.SESSION}&slot=${slotId}`, true) .then(response => response.text()) .then(async response => { @@ -591,12 +618,9 @@ export class GameData { }); } else { const sessionData = localStorage.getItem(`sessionData${slotId ? slotId : ''}`); - if (sessionData) { - const decFunc = bypassLogin - ? (data: string) => atob(data) - : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8); - await handleSessionData(decFunc(sessionData)); - } else + if (sessionData) + await handleSessionData(atob(sessionData)); + else return resolve(null); } }); @@ -707,7 +731,7 @@ export class GameData { deleteSession(slotId: integer): Promise { return new Promise(resolve => { if (bypassLogin) { - localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ''}`); + localStorage.removeItem('sessionData'); return resolve(true); } @@ -717,7 +741,6 @@ export class GameData { Utils.apiFetch(`savedata/delete?datatype=${GameDataType.SESSION}&slot=${slotId}`, true).then(response => { if (response.ok) { loggedInUser.lastSessionSlot = -1; - localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ''}`); resolve(true); } return response.text(); @@ -748,10 +771,8 @@ export class GameData { return resolve([false, false]); const sessionData = this.getSessionSaveData(scene); 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; - localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ''}`); - } return response.json(); }).then(jsonResponse => { if (!jsonResponse.error) @@ -804,12 +825,13 @@ export class GameData { }) as SessionSaveData; } - saveAll(scene: BattleScene, skipVerification: boolean = false, sync: boolean = false): Promise { + saveAll(scene: BattleScene, skipVerification?: boolean): Promise { return new Promise(resolve => { Utils.executeIf(!skipVerification, updateUserInfo).then(success => { if (success !== null && !success) return resolve(false); this.scene.ui.savingIcon.show(); + const data = this.getSystemSaveData(); const sessionData = this.getSessionSaveData(scene); const maxIntAttrValue = Math.pow(2, 31); @@ -821,7 +843,7 @@ export class GameData { sessionSlotId: scene.sessionSlotId }; - if (!bypassLogin && sync) { + if (!bypassLogin) { Utils.apiPost('savedata/updateall', JSON.stringify(request, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v), undefined, true) .then(response => response.text()) .then(error => { @@ -837,18 +859,14 @@ export class GameData { console.error(error); return resolve(false); } - localStorage.removeItem('data'); - localStorage.removeItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ''}`); resolve(true); }); } else { - const encFunc = bypassLogin - ? (data: string) => btoa(data) - : (data: string) => AES.encrypt(data, saveKey); + localStorage.setItem('data_bak', localStorage.getItem('data')); - localStorage.setItem('data', encFunc(JSON.stringify(systemData, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v))); + localStorage.setItem('data', btoa(JSON.stringify(systemData, (k: any, v: any) => typeof v === 'bigint' ? v <= maxIntAttrValue ? Number(v) : v.toString() : v))); - localStorage.setItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ''}`, encFunc(JSON.stringify(sessionData))); + localStorage.setItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ''}`, btoa(JSON.stringify(sessionData))); console.debug('Session data saved'); @@ -892,12 +910,8 @@ export class GameData { }); } else { const data = localStorage.getItem(dataKey); - if (data) { - const decFunc = bypassLogin - ? (data: string) => atob(data) - : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8); - handleData(decFunc(data)); - } + if (data) + handleData(atob(data)); resolve(!!data); } }); @@ -965,7 +979,7 @@ export class GameData { return this.scene.ui.showText(`Your ${dataName} data could not be loaded. It may be corrupted.`, null, () => this.scene.ui.showText(null, 0), Utils.fixedInt(1500)); this.scene.ui.showText(`Your ${dataName} data will be overridden and the page will reload. Proceed?`, null, () => { this.scene.ui.setOverlayMode(Mode.CONFIRM, () => { - if (!bypassLogin && dataType < GameDataType.SETTINGS && localStorage.getItem(dataKey)) { + if (!bypassLogin && dataType < GameDataType.SETTINGS) { updateUserInfo().then(success => { if (!success) return displayError(`Could not contact the server. Your ${dataName} data could not be imported.`); @@ -976,15 +990,11 @@ export class GameData { console.error(error); return displayError(`An error occurred while updating ${dataName} data. Please contact the administrator.`); } - localStorage.removeItem(dataKey); window.location = window.location; }); }); } else { - const encFunc = bypassLogin || dataType === GameDataType.SETTINGS - ? (data: string) => btoa(data) - : (data: string) => AES.encrypt(data, saveKey); - localStorage.setItem(dataKey, encFunc(dataStr)); + localStorage.setItem(dataKey, btoa(dataStr)); window.location = window.location; } }, () => { From de3ca08704da84d78fc314064276cc2892f9f553 Mon Sep 17 00:00:00 2001 From: Douglas Marchione de Souza <42784723+Tiduzz@users.noreply.github.com> Date: Mon, 13 May 2024 22:09:46 -0300 Subject: [PATCH 8/9] Fix Air_Lock ability to express when it is switched in (#765) * Airlock ability now properly announces when it is in field when the pokemon with it is switched in * Set message as in the original games, also created a new attribute for in switch messages to not have the pokemon name required to be on it. * Committing language changes (i18n function) * Revert "Committing language changes (i18n function)" This reverts commit 2a3152003b676d54d21c5b675796fd2220b55b1d. * Changed message variable name --- src/data/ability.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 5ef07c39f7b..22867ee131f 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1407,6 +1407,23 @@ export class PostSummonMessageAbAttr extends PostSummonAbAttr { } } +export class PostSummonUnnamedMessageAbAttr extends PostSummonAbAttr { + //Attr doesn't force pokemon name on the message + private message: string; + + constructor(message: string) { + super(true); + + this.message = message; + } + + applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + pokemon.scene.queueMessage(this.message); + + return true; + } +} + export class PostSummonAddBattlerTagAbAttr extends PostSummonAbAttr { private tagType: BattlerTagType; private turnCount: integer; @@ -3061,7 +3078,8 @@ export function initAbilities() { .attr(BlockCritAbAttr) .ignorable(), new Ability(Abilities.AIR_LOCK, 3) - .attr(SuppressWeatherEffectAbAttr, true), + .attr(SuppressWeatherEffectAbAttr, true) + .attr(PostSummonUnnamedMessageAbAttr, "The effects of the weather disappeared."), new Ability(Abilities.TANGLED_FEET, 4) .conditionalAttr(pokemon => !!pokemon.getTag(BattlerTagType.CONFUSED), BattleStatMultiplierAbAttr, BattleStat.EVA, 2) .ignorable(), From c42441294bf9d11afc0fbb018671e23bff0910d3 Mon Sep 17 00:00:00 2001 From: Lugiad Date: Tue, 14 May 2024 03:17:41 +0200 Subject: [PATCH 9/9] Update French ability-trigger.ts (#836) --- src/locales/fr/ability-trigger.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locales/fr/ability-trigger.ts b/src/locales/fr/ability-trigger.ts index 88900741218..f668ee5e8ab 100644 --- a/src/locales/fr/ability-trigger.ts +++ b/src/locales/fr/ability-trigger.ts @@ -1,5 +1,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { - 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, -} as const; \ No newline at end of file + 'blockRecoilDamage' : `{{abilityName}}\nde {{pokemonName}} le protège du contrecoup !`, +} as const;