From f551c51413f948a74db28cf90e4a702a5b1a46cd Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:01:42 +0100 Subject: [PATCH 1/3] [UI/UX] Adding options to see mons with only one or only two cost reductions (#5045) --- src/ui/dropdown.ts | 12 +++++++++++- src/ui/starter-select-ui-handler.ts | 13 ++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/ui/dropdown.ts b/src/ui/dropdown.ts index ec124312e14..d8ba88d3484 100644 --- a/src/ui/dropdown.ts +++ b/src/ui/dropdown.ts @@ -7,7 +7,9 @@ export enum DropDownState { ON = 0, OFF = 1, EXCLUDE = 2, - UNLOCKABLE = 3 + UNLOCKABLE = 3, + ONE = 4, + TWO = 5 } export enum DropDownType { @@ -55,6 +57,8 @@ export class DropDownOption extends Phaser.GameObjects.Container { private offColor = 0x272727; private excludeColor = 0xff5555; private unlockableColor = 0xffff00; + private oneColor = 0x33bbff; + private twoColor = 0x33bbff; constructor(val: any, labels: DropDownLabel | DropDownLabel[]) { super(globalScene); @@ -126,6 +130,12 @@ export class DropDownOption extends Phaser.GameObjects.Container { case DropDownState.UNLOCKABLE: this.toggle.setTint(this.unlockableColor); break; + case DropDownState.ONE: + this.toggle.setTint(this.oneColor); + break; + case DropDownState.TWO: + this.toggle.setTint(this.twoColor); + break; } } diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 40325d24af7..d99eb35cf4c 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -450,6 +450,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const costReductionLabels = [ new DropDownLabel(i18next.t("filterBar:costReduction"), undefined, DropDownState.OFF), new DropDownLabel(i18next.t("filterBar:costReductionUnlocked"), undefined, DropDownState.ON), + new DropDownLabel(i18next.t("filterBar:costReductionUnlockedOne"), undefined, DropDownState.ONE), + new DropDownLabel(i18next.t("filterBar:costReductionUnlockedTwo"), undefined, DropDownState.TWO), new DropDownLabel(i18next.t("filterBar:costReductionUnlockable"), undefined, DropDownState.UNLOCKABLE), new DropDownLabel(i18next.t("filterBar:costReductionLocked"), undefined, DropDownState.EXCLUDE), ]; @@ -2585,13 +2587,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }); // Cost Reduction Filter - const isCostReduced = starterData.valueReduction > 0; + const isCostReducedByOne = starterData.valueReduction === 1; + const isCostReducedByTwo = starterData.valueReduction === 2; const isCostReductionUnlockable = this.isValueReductionAvailable(container.species.speciesId); const fitsCostReduction = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => { if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ON) { - return isCostReduced; + return isCostReducedByOne || isCostReducedByTwo; + } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ONE) { + return isCostReducedByOne; + } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.TWO) { + return isCostReducedByTwo; } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.EXCLUDE) { - return isStarterProgressable && !isCostReduced; + return isStarterProgressable && !(isCostReducedByOne || isCostReducedByTwo); } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.UNLOCKABLE) { return isCostReductionUnlockable; } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.OFF) { From d495c487163e8f1cce131ee950f29db836b06363 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:11:58 -0800 Subject: [PATCH 2/3] [i18n] Update locales submodule --- public/locales | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locales b/public/locales index 7bfcbccb9b8..e07ab625f20 160000 --- a/public/locales +++ b/public/locales @@ -1 +1 @@ -Subproject commit 7bfcbccb9b8192b1059ca7c4c7e7d24901cf579d +Subproject commit e07ab625f2080afe36b61fad291b0ec5eff4000c From d85aedbdfc87a59840f0cdad2f781761d212197a Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:12:58 -0800 Subject: [PATCH 3/3] [Bug] Prevent pokemon with 0 HP from being statused (#5137) * [Bug] Prevent pokemon with 0 HP from being statused * Update test * Move check to `trySetStatus()` and update test --- src/field/pokemon.ts | 3 ++ ...s-effect.test.ts => status_effect.test.ts} | 38 +++++++++++++++++++ src/utils.ts | 10 ++--- 3 files changed, 46 insertions(+), 5 deletions(-) rename src/test/data/{status-effect.test.ts => status_effect.test.ts} (92%) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index a833facd2f8..a4b8603cbb0 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3606,6 +3606,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) { return false; } + if (this.isFainted() && effect !== StatusEffect.FAINT) { + return false; + } /** * If this Pokemon falls asleep or freezes in the middle of a multi-hit attack, diff --git a/src/test/data/status-effect.test.ts b/src/test/data/status_effect.test.ts similarity index 92% rename from src/test/data/status-effect.test.ts rename to src/test/data/status_effect.test.ts index 4831e8de5de..7948549b8e8 100644 --- a/src/test/data/status-effect.test.ts +++ b/src/test/data/status_effect.test.ts @@ -400,4 +400,42 @@ describe("Status Effects", () => { expect(player.getLastXMoves(1)[0].result).toBe(MoveResult.SUCCESS); }); }); + + describe("Behavior", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .moveset([ Moves.SPLASH ]) + .ability(Abilities.BALL_FETCH) + .battleType("single") + .disableCrits() + .enemySpecies(Species.MAGIKARP) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.NUZZLE) + .enemyLevel(2000); + }); + + it("should not inflict a 0 HP mon with a status", async () => { + await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + + const player = game.scene.getPlayerPokemon()!; + player.hp = 0; + + expect(player.trySetStatus(StatusEffect.BURN)).toBe(false); + expect(player.status?.effect).not.toBe(StatusEffect.BURN); + }); + }); }); diff --git a/src/utils.ts b/src/utils.ts index be0aec84ecd..2235fb69633 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -349,14 +349,14 @@ export class IntegerHolder extends NumberHolder { } } -/** @deprecated Use {@linkcode NumberHolder}*/ -export class FixedInt extends IntegerHolder { - constructor(value: integer) { - super(value); +export class FixedInt { + public readonly value: number; + + constructor(value: number) { + this.value = value; } } -/** @deprecated */ export function fixedInt(value: integer): integer { return new FixedInt(value) as unknown as integer; }