From 1813009443e1632c0b5d5c9e9573b1bec7d2b42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ricardo?= Date: Fri, 23 Aug 2024 22:28:47 -0300 Subject: [PATCH 1/3] candy upgrade (#3720) --- src/ui/starter-select-ui-handler.ts | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 97064cd9061..250f097c2fc 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -131,6 +131,8 @@ const starterCandyCosts: { passive: integer, costReduction: [integer, integer], { passive: 10, costReduction: [5, 15], egg: 10 }, // 10 Cost ]; +const valueReductionMax = 2; + // Position of UI elements const filterBarHeight = 17; const speciesContainerX = 109; // if team on the RIGHT: 109 / if on the LEFT: 143 @@ -1009,11 +1011,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const starterData = this.scene.gameData.starterData[speciesId]; return starterData.candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[starterData.valueReduction] - && starterData.valueReduction < 2; + && starterData.valueReduction < valueReductionMax; } /** - * Determines if an same species egg can be baught for the given species ID + * Determines if an same species egg can be bought for the given species ID * @param speciesId The ID of the species to check the value reduction of * @returns true if the user has enough candies */ @@ -1062,15 +1064,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } ],}; - const passiveAvailable = this.isPassiveAvailable(species.speciesId); - // 'Only Passives' mode + const isPassiveAvailable = this.isPassiveAvailable(species.speciesId); + const isValueReductionAvailable = this.isValueReductionAvailable(species.speciesId); + const isSameSpeciesEggAvailable = this.isSameSpeciesEggAvailable(species.speciesId); + + // 'Passives Only' mode if (this.scene.candyUpgradeNotification === 1) { - if (passiveAvailable) { + if (isPassiveAvailable) { this.scene.tweens.chain(tweenChain).paused = startPaused; } // 'On' mode } else if (this.scene.candyUpgradeNotification === 2) { - if (passiveAvailable || this.isValueReductionAvailable(species.speciesId)) { + if (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable) { this.scene.tweens.chain(tweenChain).paused = startPaused; } } @@ -1089,16 +1094,19 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return; } - const passiveAvailable = this.isPassiveAvailable(species.speciesId); - // 'Only Passive Unlocks' mode + const isPassiveAvailable = this.isPassiveAvailable(species.speciesId); + const isValueReductionAvailable = this.isValueReductionAvailable(species.speciesId); + const isSameSpeciesEggAvailable = this.isSameSpeciesEggAvailable(species.speciesId); + + // 'Passive Only' mode if (this.scene.candyUpgradeNotification === 1) { - starter.candyUpgradeIcon.setVisible(slotVisible && passiveAvailable); + starter.candyUpgradeIcon.setVisible(slotVisible && isPassiveAvailable); starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible); // 'On' mode } else if (this.scene.candyUpgradeNotification === 2) { starter.candyUpgradeIcon.setVisible( - slotVisible && ( passiveAvailable || this.isValueReductionAvailable(species.speciesId))); + slotVisible && ( isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable )); starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible); } } @@ -1630,7 +1638,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }); } const valueReduction = starterData.valueReduction; - if (valueReduction < 2) { + if (valueReduction < valueReductionMax) { const reductionCost = getValueReductionCandyCounts(speciesStarters[this.lastSpecies.speciesId])[valueReduction]; options.push({ label: `x${reductionCost} ${i18next.t("starterSelectUiHandler:reduceCost")}`, From 41a0dfe192f410e9dbc9fadab672ebf2f1135216 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Fri, 23 Aug 2024 22:04:49 -0700 Subject: [PATCH 2/3] [Bug] Fix duplicate `FaintPhase` if Mimikyu faints to Disguise damage (#3686) * Fix duplicate `FaintPhase` if Mimikyu faints to Disguise damage * Add regression test --- src/data/ability.ts | 2 +- src/test/abilities/disguise.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 75b828ca0db..022e2df0502 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -4243,7 +4243,7 @@ export class FormBlockDamageAbAttr extends ReceivedMoveDamageMultiplierAbAttr { (args[0] as Utils.NumberHolder).value = this.multiplier; pokemon.removeTag(this.tagType); if (this.recoilDamageFunc) { - pokemon.damageAndUpdate(this.recoilDamageFunc(pokemon), HitResult.OTHER); + pokemon.damageAndUpdate(this.recoilDamageFunc(pokemon), HitResult.OTHER, false, false, true, true); } } return true; diff --git a/src/test/abilities/disguise.test.ts b/src/test/abilities/disguise.test.ts index 58087b408a5..1094dc71a2d 100644 --- a/src/test/abilities/disguise.test.ts +++ b/src/test/abilities/disguise.test.ts @@ -207,4 +207,18 @@ describe("Abilities - Disguise", () => { expect(mimikyu1.formIndex).toBe(disguisedForm); }, TIMEOUT); + + it("doesn't faint twice when fainting due to Disguise break damage, nor prevent faint from Disguise break damage if using Endure", async () => { + game.override.enemyMoveset(Array(4).fill(Moves.ENDURE)); + await game.startBattle(); + + const mimikyu = game.scene.getEnemyPokemon()!; + mimikyu.hp = 1; + + game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + await game.toNextWave(); + + expect(game.scene.getCurrentPhase()?.constructor.name).toBe("CommandPhase"); + expect(game.scene.currentBattle.waveIndex).toBe(2); + }, TIMEOUT); }); From 4867ffb2293991f707525b384b511050dca2bac0 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Fri, 23 Aug 2024 22:51:39 -0700 Subject: [PATCH 3/3] [Test] Update new Disguise test with test framework changes (#3724) --- src/test/abilities/disguise.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/abilities/disguise.test.ts b/src/test/abilities/disguise.test.ts index 1094dc71a2d..85141fdb491 100644 --- a/src/test/abilities/disguise.test.ts +++ b/src/test/abilities/disguise.test.ts @@ -215,7 +215,7 @@ describe("Abilities - Disguise", () => { const mimikyu = game.scene.getEnemyPokemon()!; mimikyu.hp = 1; - game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); + game.move.select(Moves.SHADOW_SNEAK); await game.toNextWave(); expect(game.scene.getCurrentPhase()?.constructor.name).toBe("CommandPhase");