From b6692e42b2dc6bec3b4a3f1b6dafef777e9873e6 Mon Sep 17 00:00:00 2001 From: Gray <78218921+Cargney@users.noreply.github.com> Date: Wed, 8 May 2024 17:25:47 +0200 Subject: [PATCH 01/12] Fix Flare Blitz in Gravity (#637) This condition is out of place since Flare Blitz is not supposed to fail if used in Gravity. --- src/data/move.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data/move.ts b/src/data/move.ts index 17c37df08..455c1bc29 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5132,7 +5132,6 @@ export function initMoves() { .attr(RecoilAttr, false, 0.33) .attr(HealStatusEffectAttr, true, StatusEffect.FREEZE) .attr(StatusEffectAttr, StatusEffect.BURN) - .condition(failOnGravityCondition) .recklessMove(), new AttackMove(Moves.FORCE_PALM, Type.FIGHTING, MoveCategory.PHYSICAL, 60, 100, 10, 30, 0, 4) .attr(StatusEffectAttr, StatusEffect.PARALYSIS), From 662319e9ac8cbd2e2e24a2cd70c671d69548d16b Mon Sep 17 00:00:00 2001 From: Akuma-Reiki <66755974+Akuma-Reiki@users.noreply.github.com> Date: Wed, 8 May 2024 12:01:05 -0500 Subject: [PATCH 02/12] Candy/Ribbon UI Improvement (#622) * Candy/Ribbon UI Update * Removes the overrides No level 2000000000000000 runs for you * checks for all root species --- src/ui/starter-select-ui-handler.ts | 5 ++--- src/ui/summary-ui-handler.ts | 34 ++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 0de2ba9ac..087f24362 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -414,7 +414,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.classicWinIcons = new Array(81).fill(null).map((_, i) => { const x = (i % 9) * 18; const y = Math.floor(i / 9) * 18; - const ret = this.scene.add.image(x + 152, y + 16, 'champion_ribbon'); + const ret = this.scene.add.image(x + 153, y + 21, 'champion_ribbon'); ret.setOrigin(0, 0); ret.setScale(0.5); ret.setVisible(false); @@ -462,7 +462,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonCandyDarknessOverlay.setScale(0.5); this.pokemonCandyDarknessOverlay.setOrigin(0, 0); this.pokemonCandyDarknessOverlay.setTint(0x000000); - this.pokemonCandyDarknessOverlay.setAlpha(0.5); + this.pokemonCandyDarknessOverlay.setAlpha(0.50); this.pokemonCandyDarknessOverlay.setInteractive(new Phaser.Geom.Rectangle(0, 0, 16, 16), Phaser.Geom.Rectangle.Contains); this.starterSelectContainer.add(this.pokemonCandyDarknessOverlay); @@ -1332,7 +1332,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } this.pokemonCandyDarknessOverlay.setCrop(0,0,16, candyCropY); - this.pokemonCandyDarknessOverlay.setCrop(0,0,16, candyCropY); } this.iconAnimHandler.addOrUpdate(this.starterSelectGenIconContainers[species.generation - 1].getAt(this.genSpecies[species.generation - 1].indexOf(species)) as Phaser.GameObjects.Sprite, PokemonIconAnimMode.PASSIVE); diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index ac04d41be..0865cba48 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -50,6 +50,8 @@ export default class SummaryUiHandler extends UiHandler { private candyShadow: Phaser.GameObjects.Sprite; private candyIcon: Phaser.GameObjects.Sprite; private candyOverlay: Phaser.GameObjects.Sprite; + private candyCountText: Phaser.GameObjects.Text; + private championRibbon: Phaser.GameObjects.Image; private statusContainer: Phaser.GameObjects.Container; private status: Phaser.GameObjects.Image; private summaryPageContainer: Phaser.GameObjects.Container; @@ -142,12 +144,6 @@ export default class SummaryUiHandler extends UiHandler { this.pokeball.setOrigin(0, 1); this.summaryContainer.add(this.pokeball); - this.candyShadow = this.scene.add.sprite(13, -140, 'candy'); - this.candyShadow.setTint(0x141414) - this.candyShadow.setScale(0.8); - this.candyShadow.setInteractive(new Phaser.Geom.Rectangle(0, 0, 16, 16), Phaser.Geom.Rectangle.Contains); - this.summaryContainer.add(this.candyShadow); - this.candyIcon = this.scene.add.sprite(13, -140, 'candy'); this.candyIcon.setScale(0.8); this.summaryContainer.add(this.candyIcon); @@ -156,6 +152,24 @@ export default class SummaryUiHandler extends UiHandler { this.candyOverlay.setScale(0.8); this.summaryContainer.add(this.candyOverlay); + this.candyShadow = this.scene.add.sprite(13, -140, 'candy'); + this.candyShadow.setTint(0x000000); + this.candyShadow.setAlpha(0.50); + this.candyShadow.setScale(0.8); + this.candyShadow.setInteractive(new Phaser.Geom.Rectangle(0, 0, 16, 16), Phaser.Geom.Rectangle.Contains); + this.summaryContainer.add(this.candyShadow); + + this.candyCountText = addTextObject(this.scene, 20, -146, 'x0', TextStyle.WINDOW_ALT, { fontSize: '76px' }); + this.candyCountText.setOrigin(0, 0); + this.summaryContainer.add(this.candyCountText); + + this.championRibbon = this.scene.add.image(88, -146, 'champion_ribbon'); + this.championRibbon.setOrigin(0, 0); + //this.championRibbon.setScale(0.8); + this.championRibbon.setScale(1.25); + this.summaryContainer.add(this.championRibbon); + this.championRibbon.setVisible(false); + this.levelText = addTextObject(this.scene, 36, -17, '', TextStyle.SUMMARY_ALT); this.levelText.setOrigin(0, 1); this.summaryContainer.add(this.levelText); @@ -275,6 +289,9 @@ export default class SummaryUiHandler extends UiHandler { this.splicedIcon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip()); } + if(this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) + this.championRibbon.setVisible(true); + var currentFriendship = this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].friendship; if (!currentFriendship || currentFriendship === undefined) currentFriendship = 0; @@ -287,8 +304,9 @@ export default class SummaryUiHandler extends UiHandler { this.candyShadow.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip()); } - this.candyIcon.setCrop(0,candyCropY,16, 16); - this.candyOverlay.setCrop(0,candyCropY,16, 16); + this.candyCountText.setText(`x${this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].candyCount}`); + + this.candyShadow.setCrop(0,0,16, candyCropY); const doubleShiny = isFusion && this.pokemon.shiny && this.pokemon.fusionShiny; const baseVariant = !doubleShiny ? this.pokemon.getVariant() : this.pokemon.variant; From e93777e52a9d4c53dd0bbd7d966593e40d24b363 Mon Sep 17 00:00:00 2001 From: Lugiad Date: Wed, 8 May 2024 19:08:34 +0200 Subject: [PATCH 03/12] Names of the languages in their respectives languages (#635) * Names of the languages in their respectives languages in settings * Names of the languages in their respectives languages --- src/system/settings.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/system/settings.ts b/src/system/settings.ts index 3805a35bb..054bdc9fc 100644 --- a/src/system/settings.ts +++ b/src/system/settings.ts @@ -183,19 +183,19 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer) handler: () => changeLocaleHandler('en') }, { - label: 'Spanish', + label: 'Español', handler: () => changeLocaleHandler('es') }, { - label: 'Italian', + label: 'Italiano', handler: () => changeLocaleHandler('it') }, { - label: 'French', + label: 'Français', handler: () => changeLocaleHandler('fr') }, { - label: 'German', + label: 'Deutsch', handler: () => changeLocaleHandler('de') }, { From ea1ed1352c5a47cb6b74a139e22187b2e5f25860 Mon Sep 17 00:00:00 2001 From: Akuma-Reiki <66755974+Akuma-Reiki@users.noreply.github.com> Date: Wed, 8 May 2024 12:35:27 -0500 Subject: [PATCH 04/12] Hide Ribbons When Not Owned (#649) * Candy/Ribbon UI Update * Removes the overrides No level 2000000000000000 runs for you * checks for all root species * Hide ribbon when not owned --- src/ui/summary-ui-handler.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 0865cba48..e6c90887b 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -291,6 +291,8 @@ export default class SummaryUiHandler extends UiHandler { if(this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) this.championRibbon.setVisible(true); + else + this.championRibbon.setVisible(false); var currentFriendship = this.scene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].friendship; if (!currentFriendship || currentFriendship === undefined) From 0af02210ee7eaa1c4e61bef0487d5cba68f63e48 Mon Sep 17 00:00:00 2001 From: Lugiad Date: Wed, 8 May 2024 19:36:09 +0200 Subject: [PATCH 05/12] Overflowing fix in French menu.ts (#648) --- src/locales/fr/menu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/fr/menu.ts b/src/locales/fr/menu.ts index b073bbbfb..2723de587 100644 --- a/src/locales/fr/menu.ts +++ b/src/locales/fr/menu.ts @@ -24,7 +24,7 @@ export const menu: SimpleTranslationEntries = { "confirmPassword": "Confirmer le MDP", "registrationAgeWarning": "Vous confirmez en vous inscrivant que vous avez 13 ans ou plus.", "backToLogin": "Retour", - "failedToLoadSaveData": "Échec du chargement des données. Veuillez recharger la page.\nSi cela continue, veuillez contacter l’administrateur.", + "failedToLoadSaveData": "Échec du chargement des données. Veuillez recharger\nla page. Si cela persiste, contactez l’administrateur.", "sessionSuccess": "Session chargée avec succès.", "failedToLoadSession": "Vos données de session n’ont pas pu être chargées.\nElles pourraient être corrompues.", "boyOrGirl": "Es-tu un garçon ou une fille ?", From 8a35166988bcfde7ee5baa9e90186d6b1f8643ec Mon Sep 17 00:00:00 2001 From: Madmadness65 Date: Wed, 8 May 2024 12:38:31 -0500 Subject: [PATCH 06/12] Slightly adjust Recovery Tokens Each individual token heals 1 percent less, but now stacks to 15 instead of 10, to maintain the current maximum of 30% recovered per turn. The purpose of this change is to make the healing more gradual, and just generally less painful if you get multiple early on. --- src/modifier/modifier-type.ts | 2 +- src/modifier/modifier.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 249ad52dd..2457a705b 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -955,7 +955,7 @@ export const modifierTypes = { ENEMY_DAMAGE_BOOSTER: () => new ModifierType('Damage Token', 'Increases damage by 5%', (type, _args) => new Modifiers.EnemyDamageBoosterModifier(type, 5), 'wl_item_drop'), ENEMY_DAMAGE_REDUCTION: () => new ModifierType('Protection Token', 'Reduces incoming damage by 2.5%', (type, _args) => new Modifiers.EnemyDamageReducerModifier(type, 2.5), 'wl_guard_spec'), //ENEMY_SUPER_EFFECT_BOOSTER: () => new ModifierType('Type Advantage Token', 'Increases damage of super effective attacks by 30%', (type, _args) => new Modifiers.EnemySuperEffectiveDamageBoosterModifier(type, 30), 'wl_custom_super_effective'), - ENEMY_HEAL: () => new ModifierType('Recovery Token', 'Heals 3% of max HP every turn', (type, _args) => new Modifiers.EnemyTurnHealModifier(type, 3), 'wl_potion'), + ENEMY_HEAL: () => new ModifierType('Recovery Token', 'Heals 2% of max HP every turn', (type, _args) => new Modifiers.EnemyTurnHealModifier(type, 2), 'wl_potion'), ENEMY_ATTACK_POISON_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType('Poison Token', 10, StatusEffect.POISON, 'wl_antidote'), ENEMY_ATTACK_PARALYZE_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType('Paralyze Token', 10, StatusEffect.PARALYSIS, 'wl_paralyze_heal'), ENEMY_ATTACK_SLEEP_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType('Sleep Token', 10, StatusEffect.SLEEP, 'wl_awakening'), diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 2d76bec34..c119ba9c4 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -2004,7 +2004,7 @@ export class EnemyTurnHealModifier extends EnemyPersistentModifier { super(type, stackCount); // Hardcode temporarily - this.healPercent = 3; + this.healPercent = 2; } match(modifier: Modifier): boolean { @@ -2033,7 +2033,7 @@ export class EnemyTurnHealModifier extends EnemyPersistentModifier { } getMaxStackCount(scene: BattleScene): integer { - return 10; + return 15; } } From cb24faa12e76f0cabe49fdad0361f652211ee17a Mon Sep 17 00:00:00 2001 From: Elliott Simmonds <33560264+ElliottSimmonds@users.noreply.github.com> Date: Wed, 8 May 2024 19:39:22 +0100 Subject: [PATCH 07/12] Small fixes to burning bulwark and alluring voice (#651) --- src/data/move.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/move.ts b/src/data/move.ts index 455c1bc29..fd55bc920 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -6668,7 +6668,7 @@ export function initMoves() { new AttackMove(Moves.FICKLE_BEAM, Type.DRAGON, MoveCategory.SPECIAL, 80, 100, 5, 30, 0, 9) .attr(PreMoveMessageAttr, doublePowerChanceMessageFunc) .attr(DoublePowerChanceAttr), - new StatusMove(Moves.BURNING_BULWARK, Type.FIRE, -1, 10, 100, 4, 9) + new SelfStatusMove(Moves.BURNING_BULWARK, Type.FIRE, -1, 10, 100, 4, 9) .attr(ProtectAttr, BattlerTagType.BURNING_BULWARK), new AttackMove(Moves.THUNDERCLAP, Type.ELECTRIC, MoveCategory.SPECIAL, 70, 100, 5, -1, 1, 9) .condition((user, target, move) => user.scene.currentBattle.turnCommands[target.getBattlerIndex()].command === Command.FIGHT && !target.turnData.acted && allMoves[user.scene.currentBattle.turnCommands[target.getBattlerIndex()].move.move].category !== MoveCategory.STATUS), @@ -6685,6 +6685,7 @@ export function initMoves() { .target(MoveTarget.NEAR_ALLY) .partial(), new AttackMove(Moves.ALLURING_VOICE, Type.FAIRY, MoveCategory.SPECIAL, 80, 100, 10, -1, 0, 9) + .soundBased() .partial(), new AttackMove(Moves.TEMPER_FLARE, Type.FIRE, MoveCategory.PHYSICAL, 75, 100, 10, -1, 0, 9) .attr(MovePowerMultiplierAttr, (user, target, move) => user.getLastXMoves(2)[1]?.result == MoveResult.MISS || user.getLastXMoves(2)[1]?.result == MoveResult.FAIL ? 2 : 1), From 3ec9081a7799de57fe9258281ddbf22397b3bff2 Mon Sep 17 00:00:00 2001 From: maru Date: Wed, 8 May 2024 15:47:03 -0400 Subject: [PATCH 08/12] Change titlestats update interval to 60 seconds --- src/ui/title-ui-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index 6f873c6b0..c808611b0 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -84,7 +84,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { this.updateTitleStats(); - this.titleStatsTimer = setInterval(() => this.updateTitleStats(), 30000); + this.titleStatsTimer = setInterval(() => this.updateTitleStats(), 60000); this.scene.tweens.add({ targets: [ this.titleContainer, ui.getMessageHandler().bg ], From e993bf994545b19a2f28f710b2c700968b0af695 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 8 May 2024 16:36:44 -0400 Subject: [PATCH 09/12] Fix session slot always saving to first slot in offline mode --- src/system/game-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 60fe7ac8e..30cc7c96d 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -569,7 +569,7 @@ export class GameData { resolve(true); }); } else { - localStorage.setItem('sessionData', btoa(JSON.stringify(sessionData))); + localStorage.setItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ''}`, btoa(JSON.stringify(sessionData))); console.debug('Session data saved'); From 4509e08dc693d0da11f7fb1cccc4f84d8af3b266 Mon Sep 17 00:00:00 2001 From: Benjamin Odom Date: Wed, 8 May 2024 15:50:31 -0500 Subject: [PATCH 10/12] Renamed the Python Script File (#657) Accidentally left out the 'c' in 'comments' --- public/{update-source-omments.py => update-source-comments.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename public/{update-source-omments.py => update-source-comments.py} (100%) diff --git a/public/update-source-omments.py b/public/update-source-comments.py similarity index 100% rename from public/update-source-omments.py rename to public/update-source-comments.py From ea5e535f9f22055f08aed68ed1bacc1615b21d03 Mon Sep 17 00:00:00 2001 From: Benjamin Odom Date: Wed, 8 May 2024 15:51:56 -0500 Subject: [PATCH 11/12] Fixed Failed Moves Not Using PP (#634) Fixed an issue where if a move failed, it would not use power points. --- src/field/pokemon.ts | 8 ++++++++ src/phases.ts | 40 +++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 8110bf96b..f12fc14b1 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3206,6 +3206,14 @@ export class PokemonMove { return allMoves[this.moveId]; } + /** + * Sets {@link ppUsed} for this move and ensures the value does not exceed {@link getMovePp} + * @param {number} count Amount of PP to use + */ + usePp(count: number = 1) { + this.ppUsed = Math.min(this.ppUsed + count, this.getMovePp()); + } + getMovePp(): integer { return this.getMove().pp + this.ppUp * Math.max(Math.floor(this.getMove().pp / 5), 1); } diff --git a/src/phases.ts b/src/phases.ts index e5d67de28..9595ab9c3 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2158,6 +2158,7 @@ export class MovePhase extends BattlePhase { public targets: BattlerIndex[]; protected followUp: boolean; protected ignorePp: boolean; + protected failed: boolean; protected cancelled: boolean; constructor(scene: BattleScene, pokemon: Pokemon, targets: BattlerIndex[], move: PokemonMove, followUp?: boolean, ignorePp?: boolean) { @@ -2168,6 +2169,7 @@ export class MovePhase extends BattlePhase { this.move = move; this.followUp = !!followUp; this.ignorePp = !!ignorePp; + this.failed = false; this.cancelled = false; } @@ -2175,6 +2177,12 @@ export class MovePhase extends BattlePhase { return this.pokemon.isActive(true) && this.move.isUsable(this.pokemon, this.ignorePp) && !!this.targets.length; } + /**Signifies the current move should fail but still use PP */ + fail(): void { + this.failed = true; + } + + /**Signifies the current move should cancel and retain PP */ cancel(): void { this.cancelled = true; } @@ -2214,7 +2222,7 @@ export class MovePhase extends BattlePhase { this.targets[0] = attacker.getBattlerIndex(); } if (this.targets[0] === BattlerIndex.ATTACKER) { - this.cancel(); + this.fail(); // Marks the move as failed for later in doMove this.showMoveText(); this.showFailedText(); } @@ -2234,11 +2242,24 @@ export class MovePhase extends BattlePhase { this.pokemon.turnData.acted = true; // Record that the move was attempted, even if it fails this.pokemon.lapseTags(BattlerTagLapseType.PRE_MOVE); + + let ppUsed = 1; + // Filter all opponents to include only those this move is targeting + const targetedOpponents = this.pokemon.getOpponents().filter(o => this.targets.includes(o.getBattlerIndex())); + for (let opponent of targetedOpponents) { + if (this.move.ppUsed + ppUsed >= this.move.getMovePp()) // If we're already at max PP usage, stop checking + break; + if (opponent.hasAbilityWithAttr(IncreasePpAbAttr)) // Accounting for abilities like Pressure + ppUsed++; + } if (!this.followUp && this.canMove() && !this.cancelled) { this.pokemon.lapseTags(BattlerTagLapseType.MOVE); } - if (this.cancelled) { + if (this.cancelled || this.failed) { + if (this.failed) + this.move.usePp(ppUsed); // Only use PP if the move failed + this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL }); return this.end(); } @@ -2253,23 +2274,12 @@ export class MovePhase extends BattlePhase { if ((moveQueue.length && moveQueue[0].move === Moves.NONE) || !targets.length) { moveQueue.shift(); this.cancel(); - } - - if (this.cancelled) { this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL }); return this.end(); } - if (!moveQueue.length || !moveQueue.shift().ignorePP) { - this.move.ppUsed++; - const targetedOpponents = this.pokemon.getOpponents().filter(o => this.targets.includes(o.getBattlerIndex())); - for (let opponent of targetedOpponents) { - if (this.move.ppUsed === this.move.getMove().pp) - break; - if (opponent.hasAbilityWithAttr(IncreasePpAbAttr)) - this.move.ppUsed = Math.min(this.move.ppUsed + 1, this.move.getMovePp()); - } - } + if (!moveQueue.length || !moveQueue.shift().ignorePP) // using .shift here clears out two turn moves once they've been used + this.move.usePp(ppUsed); if (!allMoves[this.move.moveId].getAttrs(CopyMoveAttr).length) this.scene.currentBattle.lastMove = this.move.moveId; From 45e40f66ce7bc822d416c95a204633b77f0c44e6 Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Wed, 8 May 2024 23:07:17 +0200 Subject: [PATCH 12/12] fix "lost focus behaviour" when disabling gamepad and thus repeating RIGHT key --- src/battle-scene.ts | 1 - src/inputs-controller.ts | 47 ++++++++++++++++++++++++++++++---------- src/system/settings.ts | 2 +- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index f117615e5..14fddfd36 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -103,7 +103,6 @@ export default class BattleScene extends SceneBase { public expGainsSpeed: integer = 0; public hpBarSpeed: integer = 0; public fusionPaletteSwaps: boolean = true; - public gamepadSupport: boolean = true; public enableTouchControls: boolean = false; public enableVibration: boolean = false; public abSwapped: boolean = false; diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 5f5615358..6b3e6182a 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -36,6 +36,8 @@ export class InputsController { private time: Time; private player: Map = new Map(); + private gamepadSupport: boolean = true; + constructor(scene: Phaser.Scene) { this.scene = scene; this.time = this.scene.time; @@ -45,6 +47,7 @@ export class InputsController { this.interactions[b] = { pressTime: false, isPressed: false, + source: null, } } // We don't want the menu key to be repeated @@ -87,16 +90,32 @@ export class InputsController { this.deactivatePressedKey(); } + setGamepadSupport(value: boolean): void { + if (value) { + this.gamepadSupport = true; + } else { + this.gamepadSupport = false; + this.deactivatePressedKey(); + } + } + update(): void { // reversed to let the cancel button have a kinda priority on the action button for (const b of Utils.getEnumValues(Button).reverse()) { - if (!this.interactions.hasOwnProperty(b)) continue; - if (this.repeatInputDurationJustPassed(b) && this.interactions[b].isPressed) { + if ( + this.interactions.hasOwnProperty(b) && + this.repeatInputDurationJustPassed(b) && + this.interactions[b].isPressed + ) { + if (!this.gamepadSupport && this.interactions[b].source === 'gamepad') { + this.delLastProcessedMovementTime(b); + return; + } this.events.emit('input_down', { - controller_type: 'repeated', + controller_type: this.interactions[b].source, button: b, }); - this.setLastProcessedMovementTime(b); + this.setLastProcessedMovementTime(b, this.interactions[b].source); } } } @@ -143,7 +162,7 @@ export class InputsController { } gamepadButtonDown(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { - if (!this.scene.gamepadSupport) return; + if (!this.gamepadSupport) return; const actionMapping = this.getActionGamepadMapping(); const buttonDown = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; if (buttonDown !== undefined) { @@ -151,12 +170,12 @@ export class InputsController { controller_type: 'gamepad', button: buttonDown, }); - this.setLastProcessedMovementTime(buttonDown); + this.setLastProcessedMovementTime(buttonDown, 'gamepad'); } } gamepadButtonUp(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { - if (!this.scene.gamepadSupport) return; + if (!this.gamepadSupport) return; const actionMapping = this.getActionGamepadMapping(); const buttonUp = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; if (buttonUp !== undefined) { @@ -212,7 +231,7 @@ export class InputsController { controller_type: 'keyboard', button: index, }); - this.setLastProcessedMovementTime(index); + this.setLastProcessedMovementTime(index, 'keyboard'); }); key.on('up', () => { this.events.emit('input_up', { @@ -251,11 +270,12 @@ export class InputsController { } } - setLastProcessedMovementTime(button: Button): void { + setLastProcessedMovementTime(button: Button, source: String = 'keyboard'): void { if (!this.interactions.hasOwnProperty(button)) return; this.setButtonLock(button); this.interactions[button].pressTime = this.time.now; this.interactions[button].isPressed = true; + this.interactions[button].source = source; } delLastProcessedMovementTime(button: Button): void { @@ -263,15 +283,18 @@ export class InputsController { this.releaseButtonLock(button); this.interactions[button].pressTime = null; this.interactions[button].isPressed = false; + this.interactions[button].source = null; } deactivatePressedKey(): void { this.releaseButtonLock(this.buttonLock); this.releaseButtonLock(this.buttonLock2); for (const b of Utils.getEnumValues(Button)) { - if (!this.interactions.hasOwnProperty(b)) return; - this.interactions[b].pressTime = null; - this.interactions[b].isPressed = false; + if (this.interactions.hasOwnProperty(b)) { + this.interactions[b].pressTime = null; + this.interactions[b].isPressed = false; + this.interactions[b].source = null; + } } } diff --git a/src/system/settings.ts b/src/system/settings.ts index 054bdc9fc..b0c61fabf 100644 --- a/src/system/settings.ts +++ b/src/system/settings.ts @@ -149,7 +149,7 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer) return false; break; case Setting.Gamepad_Support: - scene.gamepadSupport = settingOptions[setting][value] !== 'Disabled'; + scene.inputController.setGamepadSupport(settingOptions[setting][value] !== 'Disabled'); break; case Setting.Swap_A_and_B: scene.abSwapped = settingOptions[setting][value] !== 'Disabled';