From 2b64ef6fc92c268e21f36c197429cf1b612b17c4 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:17:18 -0800 Subject: [PATCH 1/4] Mark Rage Fist as partial in line with similar moves/abilities (#4894) --- src/data/move.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/move.ts b/src/data/move.ts index 2ac4d74b712..e41594a3189 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -10554,6 +10554,7 @@ export function initMoves() { new AttackMove(Moves.TWIN_BEAM, Type.PSYCHIC, MoveCategory.SPECIAL, 40, 100, 10, -1, 0, 9) .attr(MultiHitAttr, MultiHitType._2), new AttackMove(Moves.RAGE_FIST, Type.GHOST, MoveCategory.PHYSICAL, 50, 100, 10, -1, 0, 9) + .partial() // Counter resets every wave instead of on arena reset .attr(HitCountPowerAttr) .punchingMove(), new AttackMove(Moves.ARMOR_CANNON, Type.FIRE, MoveCategory.SPECIAL, 120, 100, 5, -1, 0, 9) From 03b073f21f00b125d51c9449c56aa0a6241669fe Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:20:54 -0800 Subject: [PATCH 2/4] [Bug] Analytic should only increase damage if the user moves last (#4917) * Analytic only increases damage if the user moves last * Return `isNullOrUndefined()` instead of `if` chain --------- Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> --- src/data/ability.ts | 7 +-- src/test/abilities/analytic.test.ts | 81 +++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/test/abilities/analytic.test.ts diff --git a/src/data/ability.ts b/src/data/ability.ts index 32522685980..7ffe016106e 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -5779,9 +5779,10 @@ export function initAbilities() { .attr(WonderSkinAbAttr) .ignorable(), new Ability(Abilities.ANALYTIC, 5) - .attr(MovePowerBoostAbAttr, (user, target, move) => - !!target?.getLastXMoves(1).find(m => m.turn === target?.scene.currentBattle.turn) - || user?.scene.currentBattle.turnCommands[target?.getBattlerIndex() ?? BattlerIndex.ATTACKER]?.command !== Command.FIGHT, 1.3), + .attr(MovePowerBoostAbAttr, (user, target, move) => { + const movePhase = user?.scene.findPhase((phase) => phase instanceof MovePhase && phase.pokemon.id !== user.id); + return Utils.isNullOrUndefined(movePhase); + }, 1.3), new Ability(Abilities.ILLUSION, 5) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) diff --git a/src/test/abilities/analytic.test.ts b/src/test/abilities/analytic.test.ts new file mode 100644 index 00000000000..12777c545f0 --- /dev/null +++ b/src/test/abilities/analytic.test.ts @@ -0,0 +1,81 @@ +import { BattlerIndex } from "#app/battle"; +import { isBetween, toDmgValue } 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 - Analytic", () => { + 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.TACKLE ]) + .ability(Abilities.ANALYTIC) + .battleType("single") + .disableCrits() + .startingLevel(200) + .enemyLevel(200) + .enemySpecies(Species.SNORLAX) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH); + }); + + it("should increase damage if the user moves last", async () => { + await game.classicMode.startBattle([ Species.ARCEUS ]); + + const enemy = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.TACKLE); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.toNextTurn(); + const damage1 = enemy.getInverseHp(); + enemy.hp = enemy.getMaxHp(); + + game.move.select(Moves.TACKLE); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.phaseInterceptor.to("BerryPhase"); + expect(isBetween(enemy.getInverseHp(), toDmgValue(damage1 * 1.3) - 3, toDmgValue(damage1 * 1.3) + 3)).toBe(true); + }); + + it("should increase damage only if the user moves last in doubles", async () => { + game.override.battleType("double"); + await game.classicMode.startBattle([ Species.GENGAR, Species.SHUCKLE ]); + + const [ enemy, ] = game.scene.getEnemyField(); + + game.move.select(Moves.TACKLE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.toNextTurn(); + const damage1 = enemy.getInverseHp(); + enemy.hp = enemy.getMaxHp(); + + game.move.select(Moves.TACKLE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER ]); + await game.toNextTurn(); + expect(isBetween(enemy.getInverseHp(), toDmgValue(damage1 * 1.3) - 3, toDmgValue(damage1 * 1.3) + 3)).toBe(true); + enemy.hp = enemy.getMaxHp(); + + game.move.select(Moves.TACKLE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.phaseInterceptor.to("BerryPhase"); + expect(enemy.getInverseHp()).toBe(damage1); + }); +}); From 48dc5d0ee745549d939125f9c83c0d9f7dc453e1 Mon Sep 17 00:00:00 2001 From: Moka <54149968+MokaStitcher@users.noreply.github.com> Date: Fri, 29 Nov 2024 02:21:25 +0100 Subject: [PATCH 3/4] [Balance] 'Breeders in Space' cheevo unlocks for normal and expert breeders (#4911) * 'Breeders in Space' cheevo unlocks for normal and expert breeders * Reduce breeder in space achievement points --- src/battle-scene.ts | 3 ++- .../encounters/the-expert-pokemon-breeder-encounter.ts | 9 --------- src/overrides.ts | 2 ++ src/phases/trainer-victory-phase.ts | 8 ++++++++ src/system/achv.ts | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 2f062667808..62e9d8ea717 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -3008,7 +3008,8 @@ export default class BattleScene extends SceneBase { } validateAchv(achv: Achv, args?: unknown[]): boolean { - if (!this.gameData.achvUnlocks.hasOwnProperty(achv.id) && achv.validate(this, args)) { + if ((!this.gameData.achvUnlocks.hasOwnProperty(achv.id) || Overrides.ACHIEVEMENTS_REUNLOCK_OVERRIDE) + && achv.validate(this, args)) { this.gameData.achvUnlocks[achv.id] = new Date().getTime(); this.ui.achvBar.showAchv(achv); if (vouchers.hasOwnProperty(achv.id)) { diff --git a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts index 6a4c6592fda..5ac9852f27a 100644 --- a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts @@ -21,7 +21,6 @@ import { EggSourceType } from "#enums/egg-source-types"; import { EggTier } from "#enums/egg-type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { achvs } from "#app/system/achv"; import { modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { Type } from "#enums/type"; import { getPokeballTintColor } from "#app/data/pokeball"; @@ -520,12 +519,6 @@ function removePokemonFromPartyAndStoreHeldItems(scene: BattleScene, encounter: ]; } -function checkAchievement(scene: BattleScene) { - if (scene.arena.biomeType === Biome.SPACE) { - scene.validateAchv(achvs.BREEDERS_IN_SPACE); - } -} - function restorePartyAndHeldItems(scene: BattleScene) { const encounter = scene.currentBattle.mysteryEncounter!; // Restore original party @@ -617,8 +610,6 @@ function onGameOver(scene: BattleScene) { function doPostEncounterCleanup(scene: BattleScene) { const encounter = scene.currentBattle.mysteryEncounter!; if (!encounter.misc.encounterFailed) { - // Give achievement if in Space biome - checkAchievement(scene); // Give 20 friendship to the chosen pokemon encounter.misc.chosenPokemon.addFriendship(FRIENDSHIP_ADDED); restorePartyAndHeldItems(scene); diff --git a/src/overrides.ts b/src/overrides.ts index 7b73cd47b03..dc166307314 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -86,6 +86,8 @@ class DefaultOverrides { readonly ITEM_UNLOCK_OVERRIDE: Unlockables[] = []; /** Set to `true` to show all tutorials */ readonly BYPASS_TUTORIAL_SKIP_OVERRIDE: boolean = false; + /** Set to `true` to be able to re-earn already unlocked achievements */ + readonly ACHIEVEMENTS_REUNLOCK_OVERRIDE: boolean = false; /** Set to `true` to force Paralysis and Freeze to always activate, or `false` to force them to not activate */ readonly STATUS_ACTIVATION_OVERRIDE: boolean | null = null; diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index dc1b962f47e..d797e4360ac 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -9,6 +9,8 @@ import { BattlePhase } from "./battle-phase"; import { ModifierRewardPhase } from "./modifier-reward-phase"; import { MoneyRewardPhase } from "./money-reward-phase"; import { TrainerSlot } from "#app/data/trainer-config"; +import { Biome } from "#app/enums/biome"; +import { achvs } from "#app/system/achv"; export class TrainerVictoryPhase extends BattlePhase { constructor(scene: BattleScene) { @@ -34,11 +36,17 @@ export class TrainerVictoryPhase extends BattlePhase { } const trainerType = this.scene.currentBattle.trainer?.config.trainerType!; // TODO: is this bang correct? + // Validate Voucher for boss trainers if (vouchers.hasOwnProperty(TrainerType[trainerType])) { if (!this.scene.validateVoucher(vouchers[TrainerType[trainerType]]) && this.scene.currentBattle.trainer?.config.isBoss) { this.scene.unshiftPhase(new ModifierRewardPhase(this.scene, [ modifierTypes.VOUCHER, modifierTypes.VOUCHER, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PREMIUM ][vouchers[TrainerType[trainerType]].voucherType])); } } + // Breeders in Space achievement + if (this.scene.arena.biomeType === Biome.SPACE + && (trainerType === TrainerType.BREEDER || trainerType === TrainerType.EXPERT_POKEMON_BREEDER)) { + this.scene.validateAchv(achvs.BREEDERS_IN_SPACE); + } this.scene.ui.showText(i18next.t("battle:trainerDefeated", { trainerName: this.scene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }), null, () => { const victoryMessages = this.scene.currentBattle.trainer?.getVictoryMessages()!; // TODO: is this bang correct? diff --git a/src/system/achv.ts b/src/system/achv.ts index d94fcba48f2..a98e396264d 100644 --- a/src/system/achv.ts +++ b/src/system/achv.ts @@ -358,7 +358,7 @@ export const achvs = { MONO_FAIRY: new ChallengeAchv("MONO_FAIRY", "", "MONO_FAIRY.description", "fairy_feather", 100, (c, scene) => c instanceof SingleTypeChallenge && c.value === 18 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), FRESH_START: new ChallengeAchv("FRESH_START", "", "FRESH_START.description", "reviver_seed", 100, (c, scene) => c instanceof FreshStartChallenge && c.value > 0 && !scene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), INVERSE_BATTLE: new ChallengeAchv("INVERSE_BATTLE", "", "INVERSE_BATTLE.description", "inverse", 100, c => c instanceof InverseBattleChallenge && c.value > 0), - BREEDERS_IN_SPACE: new Achv("BREEDERS_IN_SPACE", "", "BREEDERS_IN_SPACE.description", "moon_stone", 100).setSecret(), + BREEDERS_IN_SPACE: new Achv("BREEDERS_IN_SPACE", "", "BREEDERS_IN_SPACE.description", "moon_stone", 50).setSecret(), }; export function initAchievements() { From de0d97739eb8c42b6ada752201582e8ec668e674 Mon Sep 17 00:00:00 2001 From: Ethan <71776311+EvasiveAce@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:43:12 -0500 Subject: [PATCH 4/4] [Move] Implement True Force Switch (Roar, Whirlwind, Circle Throw, Dragon Tail) (#4881) * Force switch implemenation * Fix conditionals checking `SwitchType` Use `prependToPhase()` instead of `unshiftPhase()` * Update comments slightly, replace `||` chain with `.includes()` --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/data/move.ts | 100 ++++++++++++++++++++++++++++----------- src/enums/switch-type.ts | 4 +- 2 files changed, 75 insertions(+), 29 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index e41594a3189..76e4675d753 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5967,50 +5967,97 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { * Check if Wimp Out/Emergency Exit activates due to being hit by U-turn or Volt Switch * If it did, the user of U-turn or Volt Switch will not be switched out. */ - if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) && - (move.id === Moves.U_TURN || move.id === Moves.VOLT_SWITCH || move.id === Moves.FLIP_TURN) + if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) + && [ Moves.U_TURN, Moves.VOLT_SWITCH, Moves.FLIP_TURN ].includes(move.id) ) { if (this.hpDroppedBelowHalf(target)) { return false; } } - // Switch out logic for the player's Pokemon + if (switchOutTarget.scene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) { return false; } if (switchOutTarget.hp > 0) { - switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH); - user.scene.prependToPhase(new SwitchPhase(user.scene, this.switchType, switchOutTarget.getFieldIndex(), true, true), MoveEndPhase); - return true; + if (this.switchType === SwitchType.FORCE_SWITCH) { + switchOutTarget.leaveField(true); + const slotIndex = Utils.randIntRange(user.scene.currentBattle.getBattlerCount(), user.scene.getPlayerParty().length); + user.scene.prependToPhase( + new SwitchSummonPhase( + user.scene, + this.switchType, + switchOutTarget.getFieldIndex(), + slotIndex, + false, + true + ), + MoveEndPhase + ); + } else { + switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH); + user.scene.prependToPhase( + new SwitchPhase( + user.scene, + this.switchType, + switchOutTarget.getFieldIndex(), + true, + true + ), + MoveEndPhase + ); + return true; + } } return false; - } else if (user.scene.currentBattle.battleType !== BattleType.WILD) { - // Switch out logic for trainer battles + } else if (user.scene.currentBattle.battleType !== BattleType.WILD) { // Switch out logic for enemy trainers if (switchOutTarget.scene.getEnemyParty().filter((p) => p.isAllowedInBattle() && !p.isOnField()).length < 1) { return false; } if (switchOutTarget.hp > 0) { - // for opponent switching out - switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH); - user.scene.prependToPhase(new SwitchSummonPhase(user.scene, this.switchType, switchOutTarget.getFieldIndex(), - (user.scene.currentBattle.trainer ? user.scene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot) : 0), - false, false), MoveEndPhase); + if (this.switchType === SwitchType.FORCE_SWITCH) { + switchOutTarget.leaveField(true); + const slotIndex = Utils.randIntRange(user.scene.currentBattle.getBattlerCount(), user.scene.getEnemyParty().length); + user.scene.prependToPhase( + new SwitchSummonPhase( + user.scene, + this.switchType, + switchOutTarget.getFieldIndex(), + slotIndex, + false, + false + ), + MoveEndPhase + ); + } else { + switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH); + user.scene.prependToPhase( + new SwitchSummonPhase( + user.scene, + this.switchType, + switchOutTarget.getFieldIndex(), + (user.scene.currentBattle.trainer ? user.scene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot) : 0), + false, + false + ), + MoveEndPhase + ); + } } - } else { + } else { // Switch out logic for wild pokemon /** * Check if Wimp Out/Emergency Exit activates due to being hit by U-turn or Volt Switch * If it did, the user of U-turn or Volt Switch will not be switched out. */ - if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) && - (move.id === Moves.U_TURN || move.id === Moves.VOLT_SWITCH) || move.id === Moves.FLIP_TURN) { + if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) + && [ Moves.U_TURN, Moves.VOLT_SWITCH, Moves.FLIP_TURN ].includes(move.id) + ) { if (this.hpDroppedBelowHalf(target)) { return false; } } - // Switch out logic for everything else (eg: WILD battles) if (user.scene.currentBattle.waveIndex % 10 === 0) { return false; } @@ -7777,11 +7824,10 @@ export function initMoves() { .windMove(), new AttackMove(Moves.WING_ATTACK, Type.FLYING, MoveCategory.PHYSICAL, 60, 100, 35, -1, 0, 1), new StatusMove(Moves.WHIRLWIND, Type.NORMAL, -1, 20, -1, -6, 1) - .attr(ForceSwitchOutAttr) + .attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH) .ignoresSubstitute() .hidesTarget() - .windMove() - .partial(), // Should force random switches + .windMove(), new ChargingAttackMove(Moves.FLY, Type.FLYING, MoveCategory.PHYSICAL, 90, 95, 15, -1, 0, 1) .chargeText(i18next.t("moveTriggers:flewUpHigh", { pokemonName: "{USER}" })) .chargeAttr(SemiInvulnerableAttr, BattlerTagType.FLYING) @@ -7857,10 +7903,9 @@ export function initMoves() { .soundBased() .target(MoveTarget.ALL_NEAR_ENEMIES), new StatusMove(Moves.ROAR, Type.NORMAL, -1, 20, -1, -6, 1) - .attr(ForceSwitchOutAttr) + .attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH) .soundBased() - .hidesTarget() - .partial(), // Should force random switching + .hidesTarget(), new StatusMove(Moves.SING, Type.NORMAL, 55, 15, -1, 0, 1) .attr(StatusEffectAttr, StatusEffect.SLEEP) .soundBased(), @@ -9222,8 +9267,8 @@ export function initMoves() { .attr(StatStageChangeAttr, [ Stat.ATK ], 1, true) .attr(StatStageChangeAttr, [ Stat.SPD ], 2, true), new AttackMove(Moves.CIRCLE_THROW, Type.FIGHTING, MoveCategory.PHYSICAL, 60, 90, 10, -1, -6, 5) - .attr(ForceSwitchOutAttr) - .partial(), // Should force random switches + .attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH) + .hidesTarget(), new AttackMove(Moves.INCINERATE, Type.FIRE, MoveCategory.SPECIAL, 60, 100, 15, -1, 0, 5) .target(MoveTarget.ALL_NEAR_ENEMIES) .attr(RemoveHeldItemAttr, true), @@ -9291,9 +9336,8 @@ export function initMoves() { new AttackMove(Moves.FROST_BREATH, Type.ICE, MoveCategory.SPECIAL, 60, 90, 10, 100, 0, 5) .attr(CritOnlyAttr), new AttackMove(Moves.DRAGON_TAIL, Type.DRAGON, MoveCategory.PHYSICAL, 60, 90, 10, -1, -6, 5) - .attr(ForceSwitchOutAttr) - .hidesTarget() - .partial(), // Should force random switches + .attr(ForceSwitchOutAttr, false, SwitchType.FORCE_SWITCH) + .hidesTarget(), new SelfStatusMove(Moves.WORK_UP, Type.NORMAL, -1, 30, -1, 0, 5) .attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, true), new AttackMove(Moves.ELECTROWEB, Type.ELECTRIC, MoveCategory.SPECIAL, 55, 95, 15, 100, 0, 5) diff --git a/src/enums/switch-type.ts b/src/enums/switch-type.ts index 752c0902636..d55872ae83b 100644 --- a/src/enums/switch-type.ts +++ b/src/enums/switch-type.ts @@ -10,5 +10,7 @@ export enum SwitchType { /** Transfers stat stages and other effects from the returning Pokemon to the switched in Pokemon */ BATON_PASS, /** Transfers the returning Pokemon's Substitute to the switched in Pokemon */ - SHED_TAIL + SHED_TAIL, + /** Force switchout to a random party member */ + FORCE_SWITCH, }