From 75a50be3cef405236634af187f02fc4af98fcb00 Mon Sep 17 00:00:00 2001 From: Riley JM Young <84201457+Ventuswill@users.noreply.github.com> Date: Sat, 30 Nov 2024 04:51:23 -0500 Subject: [PATCH 1/5] [UI/UX] Added the (+) icon for newly non-shiny pokemon (#4920) Will only show the (+) icon if you catch a non-shiny, have caught a shiny of that species before, and have not caught a non-shiny before. Removed magic numbers from new non-shiny check Co-authored-by: Riley Young Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/ui/pokemon-info-container.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index ead24e6d92f..e0d432265a3 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -313,6 +313,11 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonShinyNewIcon.setShadowColor(getTextColor(TextStyle.SUMMARY_BLUE, true, this.scene.uiTheme)); const newShinyOrVariant = ((newShiny & caughtAttr) === BigInt(0)) || ((newVariant & caughtAttr) === BigInt(0)); this.pokemonShinyNewIcon.setVisible(!!newShinyOrVariant); + } else if ((caughtAttr & DexAttr.NON_SHINY) === BigInt(0) && ((caughtAttr & DexAttr.SHINY) === DexAttr.SHINY)) { //If the player has *only* caught any shiny variant of this species, not a non-shiny + this.pokemonShinyNewIcon.setVisible(true); + this.pokemonShinyNewIcon.setText("(+)"); + this.pokemonShinyNewIcon.setColor(getTextColor(TextStyle.SUMMARY_BLUE, false, this.scene.uiTheme)); + this.pokemonShinyNewIcon.setShadowColor(getTextColor(TextStyle.SUMMARY_BLUE, true, this.scene.uiTheme)); } else { this.pokemonShinyNewIcon.setVisible(false); } From 4d75d902d8364fe87e88943adb999a878cdd5e0e Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Sat, 30 Nov 2024 04:05:07 -0600 Subject: [PATCH 2/5] [Fix] Replace hardcoded party size limit with constant `PLAYER_PARTY_MAX_SIZE` (#4943) --- src/ui/starter-select-ui-handler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index a08b7ceaec6..be78e7e1b44 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -51,6 +51,7 @@ import { Abilities } from "#enums/abilities"; import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters"; import { BooleanHolder, capitalizeString, fixedInt, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, randIntRange, rgbHexToRgba, toReadableString } from "#app/utils"; import type { Nature } from "#enums/nature"; +import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; export type StarterSelectCallback = (starters: Starter[]) => void; @@ -1462,7 +1463,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); const newCost = this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId); - if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < 6) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party + if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < PLAYER_PARTY_MAX_SIZE) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party options = [ { label: i18next.t("starterSelectUiHandler:addToParty"), From b70bf0f4aaed679bd1ae0f1e42b5a1ed2586a381 Mon Sep 17 00:00:00 2001 From: PrabbyDD <147005742+PrabbyDD@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:06:09 -0800 Subject: [PATCH 3/5] [Bug] Fix for Octolock bypasses Ghost Invulnerability to lower Stats (#4923) Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> --- src/data/battler-tags.ts | 4 -- src/data/move.ts | 6 +++ src/test/battlerTags/octolock.test.ts | 29 +------------ src/test/moves/octolock.test.ts | 62 +++++++++++++++++++++------ 4 files changed, 55 insertions(+), 46 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ce25b56157c..75b7cddb904 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -1085,10 +1085,6 @@ export class OctolockTag extends TrappedTag { super(BattlerTagType.OCTOLOCK, BattlerTagLapseType.TURN_END, 1, Moves.OCTOLOCK, sourceId); } - canAdd(pokemon: Pokemon): boolean { - return !pokemon.getTag(BattlerTagType.OCTOLOCK); - } - lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { const shouldLapse = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); diff --git a/src/data/move.ts b/src/data/move.ts index 64f8e43cb7b..091301990f3 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -7541,6 +7541,8 @@ const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Po return party.some(pokemon => pokemon.isActive() && !pokemon.isOnField()); }; +const failIfGhostTypeCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => !target.isOfType(Type.GHOST); + export type MoveAttrFilter = (attr: MoveAttr) => boolean; function applyMoveAttrsInternal(attrFilter: MoveAttrFilter, user: Pokemon | null, target: Pokemon | null, move: Move, args: any[]): Promise { @@ -8287,6 +8289,7 @@ export function initMoves() { new AttackMove(Moves.THIEF, Type.DARK, MoveCategory.PHYSICAL, 60, 100, 25, -1, 0, 2) .attr(StealHeldItemChanceAttr, 0.3), new StatusMove(Moves.SPIDER_WEB, Type.BUG, -1, 10, -1, 0, 2) + .condition(failIfGhostTypeCondition) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1), new StatusMove(Moves.MIND_READER, Type.NORMAL, -1, 5, -1, 0, 2) .attr(IgnoreAccuracyAttr), @@ -8423,6 +8426,7 @@ export function initMoves() { new AttackMove(Moves.STEEL_WING, Type.STEEL, MoveCategory.PHYSICAL, 70, 90, 25, 10, 0, 2) .attr(StatStageChangeAttr, [ Stat.DEF ], 1, true), new StatusMove(Moves.MEAN_LOOK, Type.NORMAL, -1, 5, -1, 0, 2) + .condition(failIfGhostTypeCondition) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1), new StatusMove(Moves.ATTRACT, Type.NORMAL, 100, 15, -1, 0, 2) .attr(AddBattlerTagAttr, BattlerTagType.INFATUATED) @@ -8802,6 +8806,7 @@ export function initMoves() { new SelfStatusMove(Moves.IRON_DEFENSE, Type.STEEL, -1, 15, -1, 0, 3) .attr(StatStageChangeAttr, [ Stat.DEF ], 2, true), new StatusMove(Moves.BLOCK, Type.NORMAL, -1, 5, -1, 0, 3) + .condition(failIfGhostTypeCondition) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1), new StatusMove(Moves.HOWL, Type.NORMAL, -1, 40, -1, 0, 3) .attr(StatStageChangeAttr, [ Stat.ATK ], 1) @@ -10096,6 +10101,7 @@ export function initMoves() { .attr(EatBerryAttr) .target(MoveTarget.ALL), new StatusMove(Moves.OCTOLOCK, Type.FIGHTING, 100, 15, -1, 0, 8) + .condition(failIfGhostTypeCondition) .attr(AddBattlerTagAttr, BattlerTagType.OCTOLOCK, false, true, 1), new AttackMove(Moves.BOLT_BEAK, Type.ELECTRIC, MoveCategory.PHYSICAL, 85, 100, 10, -1, 0, 8) .attr(FirstAttackDoublePowerAttr), diff --git a/src/test/battlerTags/octolock.test.ts b/src/test/battlerTags/octolock.test.ts index ebd92dc6401..9efce220fe8 100644 --- a/src/test/battlerTags/octolock.test.ts +++ b/src/test/battlerTags/octolock.test.ts @@ -1,9 +1,8 @@ import BattleScene from "#app/battle-scene"; import { describe, expect, it, vi } from "vitest"; import Pokemon from "#app/field/pokemon"; -import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags"; +import { BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; import { Stat } from "#enums/stat"; vi.mock("#app/battle-scene.js"); @@ -33,30 +32,4 @@ describe("BattlerTag - OctolockTag", () => { it ("traps its target (extends TrappedTag)", async () => { expect(new OctolockTag(1)).toBeInstanceOf(TrappedTag); }); - - it("can be added to pokemon who are not octolocked", async => { - const mockPokemon = { - getTag: vi.fn().mockReturnValue(undefined) as Pokemon["getTag"], - } as Pokemon; - - const subject = new OctolockTag(1); - - expect(subject.canAdd(mockPokemon)).toBeTruthy(); - - expect(mockPokemon.getTag).toHaveBeenCalledTimes(1); - expect(mockPokemon.getTag).toHaveBeenCalledWith(BattlerTagType.OCTOLOCK); - }); - - it("cannot be added to pokemon who are octolocked", async => { - const mockPokemon = { - getTag: vi.fn().mockReturnValue(new BattlerTag(null!, null!, null!, null!)) as Pokemon["getTag"], - } as Pokemon; - - const subject = new OctolockTag(1); - - expect(subject.canAdd(mockPokemon)).toBeFalsy(); - - expect(mockPokemon.getTag).toHaveBeenCalledTimes(1); - expect(mockPokemon.getTag).toHaveBeenCalledWith(BattlerTagType.OCTOLOCK); - }); }); diff --git a/src/test/moves/octolock.test.ts b/src/test/moves/octolock.test.ts index d80b71a51e1..6ca96eeb464 100644 --- a/src/test/moves/octolock.test.ts +++ b/src/test/moves/octolock.test.ts @@ -1,11 +1,8 @@ -import { Stat } from "#enums/stat"; import { TrappedTag } from "#app/data/battler-tags"; -import { CommandPhase } from "#app/phases/command-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; +import { Stat } from "#enums/stat"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -27,12 +24,13 @@ describe("Moves - Octolock", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") - .enemySpecies(Species.RATTATA) + game.override + .battleType("single") + .enemySpecies(Species.MAGIKARP) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) .startingLevel(2000) - .moveset([ Moves.OCTOLOCK, Moves.SPLASH ]) + .moveset([ Moves.OCTOLOCK, Moves.SPLASH, Moves.TRICK_OR_TREAT ]) .ability(Abilities.BALL_FETCH); }); @@ -43,16 +41,15 @@ describe("Moves - Octolock", () => { // use Octolock and advance to init phase of next turn to check for stat changes game.move.select(Moves.OCTOLOCK); - await game.phaseInterceptor.to(TurnInitPhase); + await game.toNextTurn(); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1); // take a second turn to make sure stat changes occur again - await game.phaseInterceptor.to(CommandPhase); game.move.select(Moves.SPLASH); + await game.toNextTurn(); - await game.phaseInterceptor.to(TurnInitPhase); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-2); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-2); }); @@ -65,7 +62,7 @@ describe("Moves - Octolock", () => { // use Octolock and advance to init phase of next turn to check for stat changes game.move.select(Moves.OCTOLOCK); - await game.phaseInterceptor.to(TurnInitPhase); + await game.toNextTurn(); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1); @@ -79,7 +76,7 @@ describe("Moves - Octolock", () => { // use Octolock and advance to init phase of next turn to check for stat changes game.move.select(Moves.OCTOLOCK); - await game.phaseInterceptor.to(TurnInitPhase); + await game.toNextTurn(); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0); @@ -93,7 +90,7 @@ describe("Moves - Octolock", () => { // use Octolock and advance to init phase of next turn to check for stat changes game.move.select(Moves.OCTOLOCK); - await game.phaseInterceptor.to(TurnInitPhase); + await game.toNextTurn(); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0); @@ -110,7 +107,44 @@ describe("Moves - Octolock", () => { game.move.select(Moves.OCTOLOCK); // after Octolock - enemy should be trapped - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeDefined(); }); + + it("does not work on ghost type pokemon", async () => { + game.override.enemyMoveset(Moves.OCTOLOCK); + await game.classicMode.startBattle([ Species.GASTLY ]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + + // before Octolock - player should not be trapped + expect(playerPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + + // after Octolock - player should still not be trapped, and no stat loss + expect(playerPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0); + expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(0); + }); + + it("does not work on pokemon with added ghost type via Trick-or-Treat", async () => { + await game.classicMode.startBattle([ Species.FEEBAS ]); + + const enemy = game.scene.getEnemyPokemon()!; + + // before Octolock - pokemon should not be trapped + expect(enemy.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + + game.move.select(Moves.TRICK_OR_TREAT); + await game.toNextTurn(); + game.move.select(Moves.OCTOLOCK); + await game.toNextTurn(); + + // after Octolock - pokemon should still not be trapped, and no stat loss + expect(enemy.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + expect(enemy.getStatStage(Stat.DEF)).toBe(0); + expect(enemy.getStatStage(Stat.SPDEF)).toBe(0); + }); }); From cd6cee860a84f627748eda4d127de9f06d4d486e Mon Sep 17 00:00:00 2001 From: "Amani H." <109637146+xsn34kzx@users.noreply.github.com> Date: Sat, 30 Nov 2024 05:07:19 -0500 Subject: [PATCH 4/5] [Bug] Fix Eviolite Weight Condition (#3681) * [Bug] Fix Eviolite Weight Condition * Break Up Conditions for Legibility --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/modifier/modifier-type.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 4986c1feab1..901aa422c61 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1730,8 +1730,14 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => { const { gameMode, gameData } = party[0].scene; if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) { - return party.some(p => ((p.getSpeciesForm(true).speciesId in pokemonEvolutions) || (p.isFusion() && (p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions))) - && !p.getHeldItems().some(i => i instanceof EvolutionStatBoosterModifier) && !p.isMax()) ? 10 : 0; + return party.some(p => { + // Check if Pokemon's species (or fusion species, if applicable) can evolve or if they're G-Max'd + if (!p.isMax() && ((p.getSpeciesForm(true).speciesId in pokemonEvolutions) || (p.isFusion() && (p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions)))) { + // Check if Pokemon is already holding an Eviolite + return !p.getHeldItems().some(i => i.type.id === "EVIOLITE"); + } + return false; + }) ? 10 : 0; } return 0; }), From eef01837614d97e3d861ba63a230af5a19b5bbbb Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:28:31 -0800 Subject: [PATCH 5/5] [Bug] Stakeout should trigger if the enemy switches with U-Turn/etc (#4918) --- src/data/ability.ts | 2 +- src/test/abilities/stakeout.test.ts | 85 +++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/test/abilities/stakeout.test.ts diff --git a/src/data/ability.ts b/src/data/ability.ts index 8ff4cfea59b..66624f03436 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -5953,7 +5953,7 @@ export function initAbilities() { .bypassFaint() .partial(), // Meteor form should protect against status effects and yawn new Ability(Abilities.STAKEOUT, 7) - .attr(MovePowerBoostAbAttr, (user, target, move) => user?.scene.currentBattle.turnCommands[target?.getBattlerIndex() ?? BattlerIndex.ATTACKER]?.command === Command.POKEMON, 2), + .attr(MovePowerBoostAbAttr, (user, target, move) => !!target?.turnData.switchedInThisTurn, 2), new Ability(Abilities.WATER_BUBBLE, 7) .attr(ReceivedTypeDamageMultiplierAbAttr, Type.FIRE, 0.5) .attr(MoveTypePowerBoostAbAttr, Type.WATER, 2) diff --git a/src/test/abilities/stakeout.test.ts b/src/test/abilities/stakeout.test.ts new file mode 100644 index 00000000000..885169b284e --- /dev/null +++ b/src/test/abilities/stakeout.test.ts @@ -0,0 +1,85 @@ +import { BattlerIndex } from "#app/battle"; +import { isBetween } from "#app/utils"; +import { Abilities } from "#enums/abilities"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +describe("Abilities - Stakeout", () => { + 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, Moves.SURF ]) + .ability(Abilities.STAKEOUT) + .battleType("single") + .disableCrits() + .startingLevel(100) + .enemyLevel(100) + .enemySpecies(Species.SNORLAX) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset([ Moves.SPLASH, Moves.FLIP_TURN ]) + .startingWave(5); + }); + + it("should do double damage to a pokemon that switched out", async () => { + await game.classicMode.startBattle([ Species.MILOTIC ]); + + const [ enemy1, ] = game.scene.getEnemyParty(); + + game.move.select(Moves.SURF); + await game.forceEnemyMove(Moves.SPLASH); + await game.toNextTurn(); + const damage1 = enemy1.getInverseHp(); + enemy1.hp = enemy1.getMaxHp(); + + game.move.select(Moves.SPLASH); + game.forceEnemyToSwitch(); + await game.toNextTurn(); + + game.move.select(Moves.SURF); + game.forceEnemyToSwitch(); + await game.toNextTurn(); + + expect(enemy1.isFainted()).toBe(false); + expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true); + }); + + it("should do double damage to a pokemon that switched out via U-Turn/etc", async () => { + await game.classicMode.startBattle([ Species.MILOTIC ]); + + const [ enemy1, ] = game.scene.getEnemyParty(); + + game.move.select(Moves.SURF); + await game.forceEnemyMove(Moves.SPLASH); + await game.toNextTurn(); + const damage1 = enemy1.getInverseHp(); + enemy1.hp = enemy1.getMaxHp(); + + game.move.select(Moves.SPLASH); + await game.forceEnemyMove(Moves.FLIP_TURN); + await game.toNextTurn(); + + game.move.select(Moves.SURF); + await game.forceEnemyMove(Moves.FLIP_TURN); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.toNextTurn(); + + expect(enemy1.isFainted()).toBe(false); + expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true); + }); +});