diff --git a/public/audio/se/crit_throw.wav b/public/audio/se/crit_throw.wav new file mode 100644 index 00000000000..a737410e7ce Binary files /dev/null and b/public/audio/se/crit_throw.wav differ diff --git a/public/locales b/public/locales index 4928231e22a..acad8499a4c 160000 --- a/public/locales +++ b/public/locales @@ -1 +1 @@ -Subproject commit 4928231e22a06dce2b55d9b04cd2b283c2ee4afb +Subproject commit acad8499a4ca488a9871902de140f635235f309a diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 6cc33dc476d..9b578c1e977 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -363,28 +363,30 @@ export default class BattleScene extends SceneBase { /** * Load the variant assets for the given sprite and stores them in {@linkcode variantColorCache} */ - loadPokemonVariantAssets(spriteKey: string, fileRoot: string, variant?: Variant) { + public async loadPokemonVariantAssets(spriteKey: string, fileRoot: string, variant?: Variant): Promise { const useExpSprite = this.experimentalSprites && this.hasExpSprite(spriteKey); if (useExpSprite) { fileRoot = `exp/${fileRoot}`; } let variantConfig = variantData; - fileRoot.split("/").map(p => variantConfig ? variantConfig = variantConfig[p] : null); + fileRoot.split("/").map((p) => (variantConfig ? (variantConfig = variantConfig[p]) : null)); const variantSet = variantConfig as VariantSet; - if (variantSet && (variant !== undefined && variantSet[variant] === 1)) { - const populateVariantColors = (key: string): Promise => { - return new Promise(resolve => { - if (variantColorCache.hasOwnProperty(key)) { - return resolve(); - } - this.cachedFetch(`./images/pokemon/variant/${fileRoot}.json`).then(res => res.json()).then(c => { - variantColorCache[key] = c; + + return new Promise((resolve) => { + if (variantSet && variant !== undefined && variantSet[variant] === 1) { + if (variantColorCache.hasOwnProperty(spriteKey)) { + return resolve(); + } + this.cachedFetch(`./images/pokemon/variant/${fileRoot}.json`) + .then((res) => res.json()) + .then((c) => { + variantColorCache[spriteKey] = c; resolve(); }); - }); - }; - populateVariantColors(spriteKey); - } + } else { + resolve(); + } + }); } async preload() { @@ -1191,6 +1193,9 @@ export default class BattleScene extends SceneBase { onComplete: () => { this.clearPhaseQueue(); + this.ui.freeUIData(); + this.uiContainer.remove(this.ui, true); + this.uiContainer.destroy(); this.children.removeAll(true); this.game.domContainer.innerHTML = ""; this.launchBattle(); @@ -1865,7 +1870,7 @@ export default class BattleScene extends SceneBase { generateRandomBiome(waveIndex: integer): Biome { const relWave = waveIndex % 250; - const biomes = Utils.getEnumValues(Biome).slice(1, Utils.getEnumValues(Biome).filter(b => b >= 40).length * -1); + const biomes = Utils.getEnumValues(Biome).filter(b => b !== Biome.TOWN && b !== Biome.END); const maxDepth = biomeDepths[Biome.END][0] - 2; const depthWeights = new Array(maxDepth + 1).fill(null) .map((_, i: integer) => ((1 - Math.min(Math.abs((i / (maxDepth - 1)) - (relWave / 250)) + 0.25, 1)) / 0.75) * 250); @@ -1878,9 +1883,9 @@ export default class BattleScene extends SceneBase { const randInt = Utils.randSeedInt(totalWeight); - for (const biome of biomes) { - if (randInt < biomeThresholds[biome]) { - return biome; + for (let i = 0; i < biomes.length; i++) { + if (randInt < biomeThresholds[i]) { + return biomes[i]; } } diff --git a/src/battle.ts b/src/battle.ts index 6dae845bfe1..b1196bb0139 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -7,7 +7,7 @@ import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/mod import type { PokeballType } from "#enums/pokeball"; import { trainerConfigs } from "#app/data/trainer-config"; import { SpeciesFormKey } from "#enums/species-form-key"; -import type { EnemyPokemon, PlayerPokemon, QueuedMove } from "#app/field/pokemon"; +import type { EnemyPokemon, PlayerPokemon, TurnMove } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { ArenaTagType } from "#enums/arena-tag-type"; import { BattleSpec } from "#enums/battle-spec"; @@ -45,12 +45,12 @@ export enum BattlerIndex { } export interface TurnCommand { - command: Command; - cursor?: number; - move?: QueuedMove; - targets?: BattlerIndex[]; - skip?: boolean; - args?: any[]; + command: Command; + cursor?: number; + move?: TurnMove; + targets?: BattlerIndex[]; + skip?: boolean; + args?: any[]; } export interface FaintLogEntry { diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 2743c36e7b5..3a58ff4a99d 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -612,7 +612,7 @@ export class InterruptedTag extends BattlerTag { super.onAdd(pokemon); pokemon.getMoveQueue().shift(); - pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.OTHER }); + pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.OTHER, targets: []}); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { diff --git a/src/data/challenge.ts b/src/data/challenge.ts index b5eca55cb71..a01ceab8aa3 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -88,6 +88,11 @@ export enum ChallengeType { * Modifies what weight AI pokemon have when generating movesets. UNIMPLEMENTED. */ MOVE_WEIGHT, + /** + * Modifies what the pokemon stats for Flip Stat Mode. + */ + FLIP_STAT, + } /** @@ -405,6 +410,16 @@ export abstract class Challenge { applyMoveWeight(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.IntegerHolder): boolean { return false; } + + /** + * An apply function for FlipStats. Derived classes should alter this. + * @param pokemon {@link Pokemon} What pokemon would learn the move. + * @param baseStats What are the stats to flip. + * @returns {@link boolean} Whether this function did anything. + */ + applyFlipStat(pokemon: Pokemon, baseStats: number[]) { + return false; + } } type ChallengeCondition = (data: GameData) => boolean; @@ -705,6 +720,33 @@ export class InverseBattleChallenge extends Challenge { } } +/** + * Implements a flip stat challenge. + */ +export class FlipStatChallenge extends Challenge { + constructor() { + super(Challenges.FLIP_STAT, 1); + } + + override applyFlipStat(pokemon: Pokemon, baseStats: number[]) { + const origStats = Utils.deepCopy(baseStats); + baseStats[0] = origStats[5]; + baseStats[1] = origStats[4]; + baseStats[2] = origStats[3]; + baseStats[3] = origStats[2]; + baseStats[4] = origStats[1]; + baseStats[5] = origStats[0]; + return true; + } + + static loadChallenge(source: FlipStatChallenge | any): FlipStatChallenge { + const newChallenge = new FlipStatChallenge(); + newChallenge.value = source.value; + newChallenge.severity = source.severity; + return newChallenge; + } +} + /** * Lowers the amount of starter points available. */ @@ -890,6 +932,9 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @returns True if any challenge was successfully applied. */ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_WEIGHT, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, weight: Utils.IntegerHolder): boolean; + +export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.FLIP_STAT, pokemon: Pokemon, baseStats: number[]): boolean; + export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType, ...args: any[]): boolean { let ret = false; gameMode.challenges.forEach(c => { @@ -934,6 +979,9 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType case ChallengeType.MOVE_WEIGHT: ret ||= c.applyMoveWeight(args[0], args[1], args[2], args[3]); break; + case ChallengeType.FLIP_STAT: + ret ||= c.applyFlipStat(args[0], args[1]); + break; } } }); @@ -959,6 +1007,8 @@ export function copyChallenge(source: Challenge | any): Challenge { return FreshStartChallenge.loadChallenge(source); case Challenges.INVERSE_BATTLE: return InverseBattleChallenge.loadChallenge(source); + case Challenges.FLIP_STAT: + return FlipStatChallenge.loadChallenge(source); } throw new Error("Unknown challenge copied"); } @@ -971,5 +1021,6 @@ export function initChallenges() { new SingleTypeChallenge(), new FreshStartChallenge(), new InverseBattleChallenge(), + new FlipStatChallenge() ); } diff --git a/src/data/daily-run.ts b/src/data/daily-run.ts index b0ce38cebd2..2a4a78a9caf 100644 --- a/src/data/daily-run.ts +++ b/src/data/daily-run.ts @@ -8,6 +8,7 @@ import type { PokemonSpeciesForm } from "#app/data/pokemon-species"; import PokemonSpecies, { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; +import { Biome } from "#app/enums/biome"; export interface DailyRunConfig { seed: integer; @@ -71,3 +72,76 @@ function getDailyRunStarter(starterSpeciesForm: PokemonSpeciesForm, startingLeve pokemon.destroy(); return starter; } + +interface BiomeWeights { + [key: integer]: integer +} + +// Initially weighted by amount of exits each biome has +// Town and End are set to 0 however +// And some other biomes were balanced +1/-1 based on average size of the total daily. +const dailyBiomeWeights: BiomeWeights = { + [Biome.CAVE]: 3, + [Biome.LAKE]: 3, + [Biome.PLAINS]: 3, + [Biome.SNOWY_FOREST]: 3, + [Biome.SWAMP]: 3, // 2 -> 3 + [Biome.TALL_GRASS]: 3, // 2 -> 3 + + [Biome.ABYSS]: 2, // 3 -> 2 + [Biome.RUINS]: 2, + [Biome.BADLANDS]: 2, + [Biome.BEACH]: 2, + [Biome.CONSTRUCTION_SITE]: 2, + [Biome.DESERT]: 2, + [Biome.DOJO]: 2, // 3 -> 2 + [Biome.FACTORY]: 2, + [Biome.FAIRY_CAVE]: 2, + [Biome.FOREST]: 2, + [Biome.GRASS]: 2, // 1 -> 2 + [Biome.MEADOW]: 2, + [Biome.MOUNTAIN]: 2, // 3 -> 2 + [Biome.SEA]: 2, + [Biome.SEABED]: 2, + [Biome.SLUM]: 2, + [Biome.TEMPLE]: 2, // 3 -> 2 + [Biome.VOLCANO]: 2, + + [Biome.GRAVEYARD]: 1, + [Biome.ICE_CAVE]: 1, + [Biome.ISLAND]: 1, + [Biome.JUNGLE]: 1, + [Biome.LABORATORY]: 1, + [Biome.METROPOLIS]: 1, + [Biome.POWER_PLANT]: 1, + [Biome.SPACE]: 1, + [Biome.WASTELAND]: 1, + + [Biome.TOWN]: 0, + [Biome.END]: 0, +}; + +export function getDailyStartingBiome(): Biome { + const biomes = Utils.getEnumValues(Biome).filter(b => b !== Biome.TOWN && b !== Biome.END); + + let totalWeight = 0; + const biomeThresholds: integer[] = []; + for (const biome of biomes) { + // Keep track of the total weight + totalWeight += dailyBiomeWeights[biome]; + + // Keep track of each biomes cumulative weight + biomeThresholds.push(totalWeight); + } + + const randInt = Utils.randSeedInt(totalWeight); + + for (let i = 0; i < biomes.length; i++) { + if (randInt < biomeThresholds[i]) { + return biomes[i]; + } + } + + // Fallback in case something went wrong + return biomes[Utils.randSeedInt(biomes.length)]; +} diff --git a/src/data/move.ts b/src/data/move.ts index 54b10a4ab80..572fbf4c2ac 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -87,7 +87,6 @@ export enum MoveFlags { NONE = 0, MAKES_CONTACT = 1 << 0, IGNORE_PROTECT = 1 << 1, - IGNORE_VIRTUAL = 1 << 2, /** * Sound-based moves have the following effects: * - Pokemon with the {@linkcode Abilities.SOUNDPROOF Soundproof Ability} are unaffected by other Pokemon's sound-based moves. @@ -98,35 +97,35 @@ export enum MoveFlags { * * cf https://bulbapedia.bulbagarden.net/wiki/Sound-based_move */ - SOUND_BASED = 1 << 3, - HIDE_USER = 1 << 4, - HIDE_TARGET = 1 << 5, - BITING_MOVE = 1 << 6, - PULSE_MOVE = 1 << 7, - PUNCHING_MOVE = 1 << 8, - SLICING_MOVE = 1 << 9, + SOUND_BASED = 1 << 2, + HIDE_USER = 1 << 3, + HIDE_TARGET = 1 << 4, + BITING_MOVE = 1 << 5, + PULSE_MOVE = 1 << 6, + PUNCHING_MOVE = 1 << 7, + SLICING_MOVE = 1 << 8, /** * Indicates a move should be affected by {@linkcode Abilities.RECKLESS} * @see {@linkcode Move.recklessMove()} */ - RECKLESS_MOVE = 1 << 10, + RECKLESS_MOVE = 1 << 9, /** Indicates a move should be affected by {@linkcode Abilities.BULLETPROOF} */ - BALLBOMB_MOVE = 1 << 11, + BALLBOMB_MOVE = 1 << 10, /** Grass types and pokemon with {@linkcode Abilities.OVERCOAT} are immune to powder moves */ - POWDER_MOVE = 1 << 12, + POWDER_MOVE = 1 << 11, /** Indicates a move should trigger {@linkcode Abilities.DANCER} */ - DANCE_MOVE = 1 << 13, + DANCE_MOVE = 1 << 12, /** Indicates a move should trigger {@linkcode Abilities.WIND_RIDER} */ - WIND_MOVE = 1 << 14, + WIND_MOVE = 1 << 13, /** Indicates a move should trigger {@linkcode Abilities.TRIAGE} */ - TRIAGE_MOVE = 1 << 15, - IGNORE_ABILITIES = 1 << 16, + TRIAGE_MOVE = 1 << 14, + IGNORE_ABILITIES = 1 << 15, /** Enables all hits of a multi-hit move to be accuracy checked individually */ - CHECK_ALL_HITS = 1 << 17, + CHECK_ALL_HITS = 1 << 16, /** Indicates a move is able to bypass its target's Substitute (if the target has one) */ - IGNORE_SUBSTITUTE = 1 << 18, + IGNORE_SUBSTITUTE = 1 << 17, /** Indicates a move is able to be redirected to allies in a double battle if the attacker faints */ - REDIRECT_COUNTER = 1 << 19, + REDIRECT_COUNTER = 1 << 18, } type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean; @@ -441,16 +440,6 @@ export default class Move implements Localizable { return this; } - /** - * Sets the {@linkcode MoveFlags.IGNORE_VIRTUAL} flag for the calling Move - * @see {@linkcode Moves.NATURE_POWER} - * @returns The {@linkcode Move} that called this function - */ - ignoresVirtual(): this { - this.setFlag(MoveFlags.IGNORE_VIRTUAL, true); - return this; - } - /** * Sets the {@linkcode MoveFlags.SOUND_BASED} flag for the calling Move * @see {@linkcode Moves.UPROAR} @@ -1552,7 +1541,7 @@ export class RecoilAttr extends MoveEffectAttr { } // Chloroblast and Struggle should not deal recoil damage if the move was not successful - if (this.useHp && [ MoveResult.FAIL, MoveResult.MISS ].includes(user.getLastXMoves(1)[0]?.result)) { + if (this.useHp && [ MoveResult.FAIL, MoveResult.MISS ].includes(user.getLastXMoves(1)[0]?.result ?? MoveResult.FAIL)) { return false; } @@ -6483,52 +6472,46 @@ export class FirstMoveTypeAttr extends MoveEffectAttr { } } -export class RandomMovesetMoveAttr extends OverrideMoveEffectAttr { - private enemyMoveset: boolean | null; - - constructor(enemyMoveset?: boolean) { - super(); - - this.enemyMoveset = enemyMoveset!; // TODO: is this bang correct? - } - - apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const moveset = (!this.enemyMoveset ? user : target).getMoveset(); - const moves = moveset.filter(m => !m?.getMove().hasFlag(MoveFlags.IGNORE_VIRTUAL)); - if (moves.length) { - const move = moves[user.randSeedInt(moves.length)]; - const moveIndex = moveset.findIndex(m => m?.moveId === move?.moveId); - const moveTargets = getMoveTargets(user, move?.moveId!); // TODO: is this bang correct? - if (!moveTargets.targets.length) { - return false; - } - let selectTargets: BattlerIndex[]; - switch (true) { - case (moveTargets.multiple || moveTargets.targets.length === 1): { - selectTargets = moveTargets.targets; - break; - } - case (moveTargets.targets.indexOf(target.getBattlerIndex()) > -1): { - selectTargets = [ target.getBattlerIndex() ]; - break; - } - default: { - moveTargets.targets.splice(moveTargets.targets.indexOf(user.getAlly().getBattlerIndex())); - selectTargets = [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ]; - break; - } - } - const targets = selectTargets; - user.getMoveQueue().push({ move: move?.moveId!, targets: targets, ignorePP: true }); // TODO: is this bang correct? - globalScene.unshiftPhase(new MovePhase(user, targets, moveset[moveIndex]!, true)); // There's a PR to re-do the move(s) that use this Attr, gonna put `!` for now - return true; +/** + * Attribute used to call a move. + * Used by other move attributes: {@linkcode RandomMoveAttr}, {@linkcode RandomMovesetMoveAttr}, {@linkcode CopyMoveAttr} + * @see {@linkcode apply} for move call + * @extends OverrideMoveEffectAttr + */ +class CallMoveAttr extends OverrideMoveEffectAttr { + protected invalidMoves: Moves[]; + protected hasTarget: boolean; + async apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { + const replaceMoveTarget = move.moveTarget === MoveTarget.NEAR_OTHER ? MoveTarget.NEAR_ENEMY : undefined; + const moveTargets = getMoveTargets(user, move.id, replaceMoveTarget); + if (moveTargets.targets.length === 0) { + return false; } + const targets = moveTargets.multiple || moveTargets.targets.length === 1 + ? moveTargets.targets + : [ this.hasTarget ? target.getBattlerIndex() : moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ]; // account for Mirror Move having a target already + user.getMoveQueue().push({ move: move.id, targets: targets, virtual: true, ignorePP: true }); + globalScene.unshiftPhase(new MovePhase(user, targets, new PokemonMove(move.id, 0, 0, true), true, true)); - return false; + await Promise.resolve(initMoveAnim(move.id).then(() => { + loadMoveAnimAssets([ move.id ], true); + })); + return true; } } -export class RandomMoveAttr extends OverrideMoveEffectAttr { +/** + * Attribute used to call a random move. + * Used for {@linkcode Moves.METRONOME} + * @see {@linkcode apply} for move selection and move call + * @extends CallMoveAttr to call a selected move + */ +export class RandomMoveAttr extends CallMoveAttr { + constructor(invalidMoves: Moves[]) { + super(); + this.invalidMoves = invalidMoves; + } + /** * This function exists solely to allow tests to override the randomly selected move by mocking this function. */ @@ -6536,31 +6519,353 @@ export class RandomMoveAttr extends OverrideMoveEffectAttr { return null; } + /** + * User calls a random moveId. + * + * Invalid moves are indicated by what is passed in to invalidMoves: {@linkcode invalidMetronomeMoves} + * @param user Pokemon that used the move and will call a random move + * @param target Pokemon that will be targeted by the random move (if single target) + * @param move Move being used + * @param args Unused + */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { - return new Promise(resolve => { - const moveIds = Utils.getEnumValues(Moves).filter(m => !allMoves[m].hasFlag(MoveFlags.IGNORE_VIRTUAL) && !allMoves[m].name.endsWith(" (N)")); - const moveId = this.getMoveOverride() ?? moveIds[user.randSeedInt(moveIds.length)]; - - const moveTargets = getMoveTargets(user, moveId); - if (!moveTargets.targets.length) { - resolve(false); - return; - } - const targets = moveTargets.multiple || moveTargets.targets.length === 1 - ? moveTargets.targets - : moveTargets.targets.indexOf(target.getBattlerIndex()) > -1 - ? [ target.getBattlerIndex() ] - : [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ]; - user.getMoveQueue().push({ move: moveId, targets: targets, ignorePP: true }); - globalScene.unshiftPhase(new MovePhase(user, targets, new PokemonMove(moveId, 0, 0, true), true)); - initMoveAnim(moveId).then(() => { - loadMoveAnimAssets([ moveId ], true) - .then(() => resolve(true)); - }); - }); + const moveIds = Utils.getEnumValues(Moves).map(m => !this.invalidMoves.includes(m) && !allMoves[m].name.endsWith(" (N)") ? m : Moves.NONE); + let moveId: Moves = Moves.NONE; + do { + moveId = this.getMoveOverride() ?? moveIds[user.randSeedInt(moveIds.length)]; + } + while (moveId === Moves.NONE); + return super.apply(user, target, allMoves[moveId], args); } } +/** + * Attribute used to call a random move in the user or party's moveset. + * Used for {@linkcode Moves.ASSIST} and {@linkcode Moves.SLEEP_TALK} + * + * Fails if the user has no callable moves. + * + * Invalid moves are indicated by what is passed in to invalidMoves: {@linkcode invalidAssistMoves} or {@linkcode invalidSleepTalkMoves} + * @extends RandomMoveAttr to use the callMove function on a moveId + * @see {@linkcode getCondition} for move selection + */ +export class RandomMovesetMoveAttr extends CallMoveAttr { + private includeParty: boolean; + private moveId: number; + constructor(invalidMoves: Moves[], includeParty: boolean = false) { + super(); + this.includeParty = includeParty; + this.invalidMoves = invalidMoves; + } + + /** + * User calls a random moveId selected in {@linkcode getCondition} + * @param user Pokemon that used the move and will call a random move + * @param target Pokemon that will be targeted by the random move (if single target) + * @param move Move being used + * @param args Unused + */ + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { + return super.apply(user, target, allMoves[this.moveId], args); + } + + getCondition(): MoveConditionFunc { + return (user, target, move) => { + // includeParty will be true for Assist, false for Sleep Talk + let allies: Pokemon[]; + if (this.includeParty) { + allies = user.isPlayer() ? globalScene.getPlayerParty().filter(p => p !== user) : globalScene.getEnemyParty().filter(p => p !== user); + } else { + allies = [ user ]; + } + const partyMoveset = allies.map(p => p.moveset).flat(); + const moves = partyMoveset.filter(m => !this.invalidMoves.includes(m!.moveId) && !m!.getMove().name.endsWith(" (N)")); + if (moves.length === 0) { + return false; + } + + this.moveId = moves[user.randSeedInt(moves.length)]!.moveId; + return true; + }; + } +} + +const invalidMetronomeMoves: Moves[] = [ + Moves.AFTER_YOU, + Moves.APPLE_ACID, + Moves.ARMOR_CANNON, + Moves.ASSIST, + Moves.ASTRAL_BARRAGE, + Moves.AURA_WHEEL, + Moves.BANEFUL_BUNKER, + Moves.BEAK_BLAST, + Moves.BEHEMOTH_BASH, + Moves.BEHEMOTH_BLADE, + Moves.BELCH, + Moves.BESTOW, + Moves.BLAZING_TORQUE, + Moves.BODY_PRESS, + Moves.BRANCH_POKE, + Moves.BREAKING_SWIPE, + Moves.CELEBRATE, + Moves.CHATTER, + Moves.CHILLING_WATER, + Moves.CHILLY_RECEPTION, + Moves.CLANGOROUS_SOUL, + Moves.COLLISION_COURSE, + Moves.COMBAT_TORQUE, + Moves.COMEUPPANCE, + Moves.COPYCAT, + Moves.COUNTER, + Moves.COVET, + Moves.CRAFTY_SHIELD, + Moves.DECORATE, + Moves.DESTINY_BOND, + Moves.DETECT, + Moves.DIAMOND_STORM, + Moves.DOODLE, + Moves.DOUBLE_IRON_BASH, + Moves.DOUBLE_SHOCK, + Moves.DRAGON_ASCENT, + Moves.DRAGON_ENERGY, + Moves.DRUM_BEATING, + Moves.DYNAMAX_CANNON, + Moves.ELECTRO_DRIFT, + Moves.ENDURE, + Moves.ETERNABEAM, + Moves.FALSE_SURRENDER, + Moves.FEINT, + Moves.FIERY_WRATH, + Moves.FILLET_AWAY, + Moves.FLEUR_CANNON, + Moves.FOCUS_PUNCH, + Moves.FOLLOW_ME, + Moves.FREEZE_SHOCK, + Moves.FREEZING_GLARE, + Moves.GLACIAL_LANCE, + Moves.GRAV_APPLE, + Moves.HELPING_HAND, + Moves.HOLD_HANDS, + Moves.HYPER_DRILL, + Moves.HYPERSPACE_FURY, + Moves.HYPERSPACE_HOLE, + Moves.ICE_BURN, + Moves.INSTRUCT, + Moves.JET_PUNCH, + Moves.JUNGLE_HEALING, + Moves.KINGS_SHIELD, + Moves.LIFE_DEW, + Moves.LIGHT_OF_RUIN, + Moves.MAKE_IT_RAIN, + Moves.MAGICAL_TORQUE, + Moves.MAT_BLOCK, + Moves.ME_FIRST, + Moves.METEOR_ASSAULT, + Moves.METRONOME, + Moves.MIMIC, + Moves.MIND_BLOWN, + Moves.MIRROR_COAT, + Moves.MIRROR_MOVE, + Moves.MOONGEIST_BEAM, + Moves.NATURE_POWER, + Moves.NATURES_MADNESS, + Moves.NOXIOUS_TORQUE, + Moves.OBSTRUCT, + Moves.ORDER_UP, + Moves.ORIGIN_PULSE, + Moves.OVERDRIVE, + Moves.PHOTON_GEYSER, + Moves.PLASMA_FISTS, + Moves.POPULATION_BOMB, + Moves.POUNCE, + Moves.POWER_SHIFT, + Moves.PRECIPICE_BLADES, + Moves.PROTECT, + Moves.PYRO_BALL, + Moves.QUASH, + Moves.QUICK_GUARD, + Moves.RAGE_FIST, + Moves.RAGE_POWDER, + Moves.RAGING_BULL, + Moves.RAGING_FURY, + Moves.RELIC_SONG, + Moves.REVIVAL_BLESSING, + Moves.RUINATION, + Moves.SALT_CURE, + Moves.SECRET_SWORD, + Moves.SHED_TAIL, + Moves.SHELL_TRAP, + Moves.SILK_TRAP, + Moves.SKETCH, + Moves.SLEEP_TALK, + Moves.SNAP_TRAP, + Moves.SNARL, + Moves.SNATCH, + Moves.SNORE, + Moves.SNOWSCAPE, + Moves.SPECTRAL_THIEF, + Moves.SPICY_EXTRACT, + Moves.SPIKY_SHIELD, + Moves.SPIRIT_BREAK, + Moves.SPOTLIGHT, + Moves.STEAM_ERUPTION, + Moves.STEEL_BEAM, + Moves.STRANGE_STEAM, + Moves.STRUGGLE, + Moves.SUNSTEEL_STRIKE, + Moves.SURGING_STRIKES, + Moves.SWITCHEROO, + Moves.TECHNO_BLAST, + Moves.TERA_STARSTORM, + Moves.THIEF, + Moves.THOUSAND_ARROWS, + Moves.THOUSAND_WAVES, + Moves.THUNDER_CAGE, + Moves.THUNDEROUS_KICK, + Moves.TIDY_UP, + Moves.TRAILBLAZE, + Moves.TRANSFORM, + Moves.TRICK, + Moves.TWIN_BEAM, + Moves.V_CREATE, + Moves.WICKED_BLOW, + Moves.WICKED_TORQUE, + Moves.WIDE_GUARD, +]; + +const invalidAssistMoves: Moves[] = [ + Moves.ASSIST, + Moves.BANEFUL_BUNKER, + Moves.BEAK_BLAST, + Moves.BELCH, + Moves.BESTOW, + Moves.BOUNCE, + Moves.CELEBRATE, + Moves.CHATTER, + Moves.CIRCLE_THROW, + Moves.COPYCAT, + Moves.COUNTER, + Moves.COVET, + Moves.DESTINY_BOND, + Moves.DETECT, + Moves.DIG, + Moves.DIVE, + Moves.DRAGON_TAIL, + Moves.ENDURE, + Moves.FEINT, + Moves.FLY, + Moves.FOCUS_PUNCH, + Moves.FOLLOW_ME, + Moves.HELPING_HAND, + Moves.HOLD_HANDS, + Moves.KINGS_SHIELD, + Moves.MAT_BLOCK, + Moves.ME_FIRST, + Moves.METRONOME, + Moves.MIMIC, + Moves.MIRROR_COAT, + Moves.MIRROR_MOVE, + Moves.NATURE_POWER, + Moves.PHANTOM_FORCE, + Moves.PROTECT, + Moves.RAGE_POWDER, + Moves.ROAR, + Moves.SHADOW_FORCE, + Moves.SHELL_TRAP, + Moves.SKETCH, + Moves.SKY_DROP, + Moves.SLEEP_TALK, + Moves.SNATCH, + Moves.SPIKY_SHIELD, + Moves.SPOTLIGHT, + Moves.STRUGGLE, + Moves.SWITCHEROO, + Moves.THIEF, + Moves.TRANSFORM, + Moves.TRICK, + Moves.WHIRLWIND, +]; + +const invalidSleepTalkMoves: Moves[] = [ + Moves.ASSIST, + Moves.BELCH, + Moves.BEAK_BLAST, + Moves.BIDE, + Moves.BOUNCE, + Moves.COPYCAT, + Moves.DIG, + Moves.DIVE, + Moves.DYNAMAX_CANNON, + Moves.FREEZE_SHOCK, + Moves.FLY, + Moves.FOCUS_PUNCH, + Moves.GEOMANCY, + Moves.ICE_BURN, + Moves.ME_FIRST, + Moves.METRONOME, + Moves.MIRROR_MOVE, + Moves.MIMIC, + Moves.PHANTOM_FORCE, + Moves.RAZOR_WIND, + Moves.SHADOW_FORCE, + Moves.SHELL_TRAP, + Moves.SKETCH, + Moves.SKULL_BASH, + Moves.SKY_ATTACK, + Moves.SKY_DROP, + Moves.SLEEP_TALK, + Moves.SOLAR_BLADE, + Moves.SOLAR_BEAM, + Moves.STRUGGLE, + Moves.UPROAR, +]; + +const invalidCopycatMoves = [ + Moves.ASSIST, + Moves.BANEFUL_BUNKER, + Moves.BEAK_BLAST, + Moves.BEHEMOTH_BASH, + Moves.BEHEMOTH_BLADE, + Moves.BESTOW, + Moves.CELEBRATE, + Moves.CHATTER, + Moves.CIRCLE_THROW, + Moves.COPYCAT, + Moves.COUNTER, + Moves.COVET, + Moves.DESTINY_BOND, + Moves.DETECT, + Moves.DRAGON_TAIL, + Moves.ENDURE, + Moves.FEINT, + Moves.FOCUS_PUNCH, + Moves.FOLLOW_ME, + Moves.HELPING_HAND, + Moves.HOLD_HANDS, + Moves.KINGS_SHIELD, + Moves.MAT_BLOCK, + Moves.ME_FIRST, + Moves.METRONOME, + Moves.MIMIC, + Moves.MIRROR_COAT, + Moves.MIRROR_MOVE, + Moves.PROTECT, + Moves.RAGE_POWDER, + Moves.ROAR, + Moves.SHELL_TRAP, + Moves.SKETCH, + Moves.SLEEP_TALK, + Moves.SNATCH, + Moves.SPIKY_SHIELD, + Moves.SPOTLIGHT, + Moves.STRUGGLE, + Moves.SWITCHEROO, + Moves.THIEF, + Moves.TRANSFORM, + Moves.TRICK, + Moves.WHIRLWIND, +]; + export class NaturePowerAttr extends OverrideMoveEffectAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { return new Promise(resolve => { @@ -6704,45 +7009,35 @@ export class NaturePowerAttr extends OverrideMoveEffectAttr { } } -const lastMoveCopiableCondition: MoveConditionFunc = (user, target, move) => { - const copiableMove = globalScene.currentBattle.lastMove; - - if (!copiableMove) { - return false; +/** + * Attribute used to copy a previously-used move. + * Used for {@linkcode Moves.COPYCAT} and {@linkcode Moves.MIRROR_MOVE} + * @see {@linkcode apply} for move selection and move call + * @extends CallMoveAttr to call a selected move + */ +export class CopyMoveAttr extends CallMoveAttr { + private mirrorMove: boolean; + constructor(mirrorMove: boolean, invalidMoves: Moves[] = []) { + super(); + this.mirrorMove = mirrorMove; + this.invalidMoves = invalidMoves; } - if (allMoves[copiableMove].isChargingMove()) { - return false; - } - - // TODO: Add last turn of Bide - - return true; -}; - -export class CopyMoveAttr extends OverrideMoveEffectAttr { - apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const lastMove = globalScene.currentBattle.lastMove; - - const moveTargets = getMoveTargets(user, lastMove); - if (!moveTargets.targets.length) { - return false; - } - - const targets = moveTargets.multiple || moveTargets.targets.length === 1 - ? moveTargets.targets - : moveTargets.targets.indexOf(target.getBattlerIndex()) > -1 - ? [ target.getBattlerIndex() ] - : [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ]; - user.getMoveQueue().push({ move: lastMove, targets: targets, ignorePP: true }); - - globalScene.unshiftPhase(new MovePhase(user as PlayerPokemon, targets, new PokemonMove(lastMove, 0, 0, true), true)); - - return true; + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { + this.hasTarget = this.mirrorMove; + const lastMove = this.mirrorMove ? target.getLastXMoves()[0].move : globalScene.currentBattle.lastMove; + return super.apply(user, target, allMoves[lastMove], args); } getCondition(): MoveConditionFunc { - return lastMoveCopiableCondition; + return (user, target, move) => { + if (this.mirrorMove) { + return target.getMoveHistory().length !== 0; + } else { + const lastMove = globalScene.currentBattle.lastMove; + return lastMove !== undefined && !this.invalidMoves.includes(lastMove); + } + }; } } @@ -7583,31 +7878,6 @@ export class LastResortAttr extends MoveAttr { } } - -/** - * The move only works if the target has a transferable held item - * @extends MoveAttr - * @see {@linkcode getCondition} - */ -export class AttackedByItemAttr extends MoveAttr { - /** - * @returns the {@linkcode MoveConditionFunc} for this {@linkcode Move} - */ - getCondition(): MoveConditionFunc { - return (user: Pokemon, target: Pokemon, move: Move) => { - const heldItems = target.getHeldItems().filter(i => i.isTransferable); - if (heldItems.length === 0) { - return false; - } - - const itemName = heldItems[0]?.type?.name ?? "item"; - globalScene.queueMessage(i18next.t("moveTriggers:attackedByItem", { pokemonName: getPokemonNameWithAffix(target), itemName: itemName })); - - return true; - }; - } -} - export class VariableTargetAttr extends MoveAttr { private targetChangeFunc: (user: Pokemon, target: Pokemon, move: Move) => number; @@ -7681,6 +7951,18 @@ const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Po const failIfGhostTypeCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => !target.isOfType(Type.GHOST); +const failIfNoTargetHeldItemsCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => target.getHeldItems().filter(i => i.isTransferable)?.length > 0; + +const attackedByItemMessageFunc = (user: Pokemon, target: Pokemon, move: Move) => { + const heldItems = target.getHeldItems().filter(i => i.isTransferable); + if (heldItems.length === 0) { + return ""; + } + const itemName = heldItems[0]?.type?.name ?? "item"; + const message: string = i18next.t("moveTriggers:attackedByItem", { pokemonName: getPokemonNameWithAffix(target), itemName: itemName }); + return message; +}; + export type MoveAttrFilter = (attr: MoveAttr) => boolean; function applyMoveAttrsInternal(attrFilter: MoveAttrFilter, user: Pokemon | null, target: Pokemon | null, move: Move, args: any[]): Promise { @@ -7896,11 +8178,20 @@ export type MoveTargetSet = { multiple: boolean; }; -export function getMoveTargets(user: Pokemon, move: Moves): MoveTargetSet { +export function getMoveTargets(user: Pokemon, move: Moves, replaceTarget?: MoveTarget): MoveTargetSet { const variableTarget = new Utils.NumberHolder(0); user.getOpponents().forEach(p => applyMoveAttrs(VariableTargetAttr, user, p, allMoves[move], variableTarget)); - const moveTarget = allMoves[move].hasAttr(VariableTargetAttr) ? variableTarget.value : move ? allMoves[move].moveTarget : move === undefined ? MoveTarget.NEAR_ENEMY : []; + let moveTarget: MoveTarget | undefined; + if (allMoves[move].hasAttr(VariableTargetAttr)) { + moveTarget = variableTarget.value; + } else if (replaceTarget !== undefined) { + moveTarget = replaceTarget; + } else if (move) { + moveTarget = allMoves[move].moveTarget; + } else if (move === undefined) { + moveTarget = MoveTarget.NEAR_ENEMY; + } const opponents = user.getOpponents(); let set: Pokemon[] = []; @@ -7992,7 +8283,6 @@ export function initMoves() { .chargeText(i18next.t("moveTriggers:whippedUpAWhirlwind", { pokemonName: "{USER}" })) .attr(HighCritAttr) .windMove() - .ignoresVirtual() .target(MoveTarget.ALL_NEAR_ENEMIES), new SelfStatusMove(Moves.SWORDS_DANCE, Type.NORMAL, -1, 20, -1, 0, 1) .attr(StatStageChangeAttr, [ Stat.ATK ], 2, true) @@ -8011,8 +8301,7 @@ export function initMoves() { 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) - .condition(failOnGravityCondition) - .ignoresVirtual(), + .condition(failOnGravityCondition), new AttackMove(Moves.BIND, Type.NORMAL, MoveCategory.PHYSICAL, 15, 85, 20, -1, 0, 1) .attr(TrapAttr, BattlerTagType.BIND), new AttackMove(Moves.SLAM, Type.NORMAL, MoveCategory.PHYSICAL, 80, 75, 20, -1, 0, 1), @@ -8161,8 +8450,7 @@ export function initMoves() { new ChargingAttackMove(Moves.SOLAR_BEAM, Type.GRASS, MoveCategory.SPECIAL, 120, 100, 10, -1, 0, 1) .chargeText(i18next.t("moveTriggers:tookInSunlight", { pokemonName: "{USER}" })) .chargeAttr(WeatherInstantChargeAttr, [ WeatherType.SUNNY, WeatherType.HARSH_SUN ]) - .attr(AntiSunlightPowerDecreaseAttr) - .ignoresVirtual(), + .attr(AntiSunlightPowerDecreaseAttr), new StatusMove(Moves.POISON_POWDER, Type.POISON, 75, 35, -1, 0, 1) .attr(StatusEffectAttr, StatusEffect.POISON) .powderMove(), @@ -8211,8 +8499,7 @@ export function initMoves() { .makesContact(false), new ChargingAttackMove(Moves.DIG, Type.GROUND, MoveCategory.PHYSICAL, 80, 100, 10, -1, 0, 1) .chargeText(i18next.t("moveTriggers:dugAHole", { pokemonName: "{USER}" })) - .chargeAttr(SemiInvulnerableAttr, BattlerTagType.UNDERGROUND) - .ignoresVirtual(), + .chargeAttr(SemiInvulnerableAttr, BattlerTagType.UNDERGROUND), new StatusMove(Moves.TOXIC, Type.POISON, 90, 10, -1, 0, 1) .attr(StatusEffectAttr, StatusEffect.TOXIC) .attr(ToxicAccuracyAttr), @@ -8236,8 +8523,7 @@ export function initMoves() { .attr(LevelDamageAttr), new StatusMove(Moves.MIMIC, Type.NORMAL, -1, 10, -1, 0, 1) .attr(MovesetCopyMoveAttr) - .ignoresSubstitute() - .ignoresVirtual(), + .ignoresSubstitute(), new StatusMove(Moves.SCREECH, Type.NORMAL, 85, 40, -1, 0, 1) .attr(StatStageChangeAttr, [ Stat.DEF ], -2) .soundBased(), @@ -8273,15 +8559,12 @@ export function initMoves() { new SelfStatusMove(Moves.FOCUS_ENERGY, Type.NORMAL, -1, 30, -1, 0, 1) .attr(AddBattlerTagAttr, BattlerTagType.CRIT_BOOST, true, true), new AttackMove(Moves.BIDE, Type.NORMAL, MoveCategory.PHYSICAL, -1, -1, 10, -1, 1, 1) - .ignoresVirtual() .target(MoveTarget.USER) .unimplemented(), new SelfStatusMove(Moves.METRONOME, Type.NORMAL, -1, 10, -1, 0, 1) - .attr(RandomMoveAttr) - .ignoresVirtual(), + .attr(RandomMoveAttr, invalidMetronomeMoves), new StatusMove(Moves.MIRROR_MOVE, Type.FLYING, -1, 20, -1, 0, 1) - .attr(CopyMoveAttr) - .ignoresVirtual(), + .attr(CopyMoveAttr, true), new AttackMove(Moves.SELF_DESTRUCT, Type.NORMAL, MoveCategory.PHYSICAL, 200, 100, 5, -1, 0, 1) .attr(SacrificialAttr) .makesContact(false) @@ -8309,8 +8592,7 @@ export function initMoves() { .target(MoveTarget.ALL_NEAR_ENEMIES), new ChargingAttackMove(Moves.SKULL_BASH, Type.NORMAL, MoveCategory.PHYSICAL, 130, 100, 10, -1, 0, 1) .chargeText(i18next.t("moveTriggers:loweredItsHead", { pokemonName: "{USER}" })) - .chargeAttr(StatStageChangeAttr, [ Stat.DEF ], 1, true) - .ignoresVirtual(), + .chargeAttr(StatStageChangeAttr, [ Stat.DEF ], 1, true), new AttackMove(Moves.SPIKE_CANNON, Type.NORMAL, MoveCategory.PHYSICAL, 20, 100, 15, -1, 0, 1) .attr(MultiHitAttr) .makesContact(false), @@ -8350,8 +8632,7 @@ export function initMoves() { .chargeText(i18next.t("moveTriggers:isGlowing", { pokemonName: "{USER}" })) .attr(HighCritAttr) .attr(FlinchAttr) - .makesContact(false) - .ignoresVirtual(), + .makesContact(false), new StatusMove(Moves.TRANSFORM, Type.NORMAL, -1, 10, -1, 0, 1) .attr(TransformAttr) // transforming from or into fusion pokemon causes various problems (such as crashes) @@ -8414,12 +8695,10 @@ export function initMoves() { new AttackMove(Moves.STRUGGLE, Type.NORMAL, MoveCategory.PHYSICAL, 50, -1, 1, -1, 0, 1) .attr(RecoilAttr, true, 0.25, true) .attr(TypelessAttr) - .ignoresVirtual() .target(MoveTarget.RANDOM_NEAR_ENEMY), new StatusMove(Moves.SKETCH, Type.NORMAL, -1, 1, -1, 0, 2) .ignoresSubstitute() - .attr(SketchAttr) - .ignoresVirtual(), + .attr(SketchAttr), new AttackMove(Moves.TRIPLE_KICK, Type.FIGHTING, MoveCategory.PHYSICAL, 10, 90, 10, -1, 0, 2) .attr(MultiHitAttr, MultiHitType._3) .attr(MultiHitPowerIncrementAttr, 3) @@ -8572,10 +8851,9 @@ export function initMoves() { .condition((user, target, move) => user.isOppositeGender(target)), new SelfStatusMove(Moves.SLEEP_TALK, Type.NORMAL, -1, 10, -1, 0, 2) .attr(BypassSleepAttr) - .attr(RandomMovesetMoveAttr) + .attr(RandomMovesetMoveAttr, invalidSleepTalkMoves, false) .condition(userSleptOrComatoseCondition) - .target(MoveTarget.ALL_ENEMIES) - .ignoresVirtual(), + .target(MoveTarget.NEAR_ENEMY), new StatusMove(Moves.HEAL_BELL, Type.NORMAL, -1, 5, -1, 0, 2) .attr(PartyStatusCureAttr, i18next.t("moveTriggers:bellChimed"), Abilities.SOUNDPROOF) .soundBased() @@ -8700,7 +8978,6 @@ export function initMoves() { .attr(FlinchAttr) .condition(new FirstMoveCondition()), new AttackMove(Moves.UPROAR, Type.NORMAL, MoveCategory.SPECIAL, 90, 100, 10, -1, 0, 3) - .ignoresVirtual() .soundBased() .target(MoveTarget.RANDOM_NEAR_ENEMY) .partial(), // Does not lock the user, does not stop Pokemon from sleeping @@ -8743,7 +9020,6 @@ export function initMoves() { new AttackMove(Moves.FOCUS_PUNCH, Type.FIGHTING, MoveCategory.PHYSICAL, 150, 100, 20, -1, -3, 3) .attr(MessageHeaderAttr, (user, move) => i18next.t("moveTriggers:isTighteningFocus", { pokemonName: getPokemonNameWithAffix(user) })) .punchingMove() - .ignoresVirtual() .condition((user, target, move) => !user.turnData.attacksReceived.find(r => r.damage)), new AttackMove(Moves.SMELLING_SALTS, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 10, -1, 0, 3) .attr(MovePowerMultiplierAttr, (user, target, move) => target.status?.effect === StatusEffect.PARALYSIS ? 2 : 1) @@ -8751,8 +9027,7 @@ export function initMoves() { new SelfStatusMove(Moves.FOLLOW_ME, Type.NORMAL, -1, 20, -1, 2, 3) .attr(AddBattlerTagAttr, BattlerTagType.CENTER_OF_ATTENTION, true), new StatusMove(Moves.NATURE_POWER, Type.NORMAL, -1, 20, -1, 0, 3) - .attr(NaturePowerAttr) - .ignoresVirtual(), + .attr(NaturePowerAttr), new SelfStatusMove(Moves.CHARGE, Type.ELECTRIC, -1, 20, -1, 0, 3) .attr(StatStageChangeAttr, [ Stat.SPDEF ], 1, true) .attr(AddBattlerTagAttr, BattlerTagType.CHARGED, true, false), @@ -8773,8 +9048,7 @@ export function initMoves() { .triageMove() .attr(AddArenaTagAttr, ArenaTagType.WISH, 2, true), new SelfStatusMove(Moves.ASSIST, Type.NORMAL, -1, 20, -1, 0, 3) - .attr(RandomMovesetMoveAttr, true) - .ignoresVirtual(), + .attr(RandomMovesetMoveAttr, invalidAssistMoves, true), new SelfStatusMove(Moves.INGRAIN, Type.GRASS, -1, 20, -1, 0, 3) .attr(AddBattlerTagAttr, BattlerTagType.INGRAIN, true, true) .attr(AddBattlerTagAttr, BattlerTagType.IGNORE_FLYING, true, true) @@ -8821,8 +9095,7 @@ export function initMoves() { new ChargingAttackMove(Moves.DIVE, Type.WATER, MoveCategory.PHYSICAL, 80, 100, 10, -1, 0, 3) .chargeText(i18next.t("moveTriggers:hidUnderwater", { pokemonName: "{USER}" })) .chargeAttr(SemiInvulnerableAttr, BattlerTagType.UNDERWATER) - .chargeAttr(GulpMissileTagAttr) - .ignoresVirtual(), + .chargeAttr(GulpMissileTagAttr), new AttackMove(Moves.ARM_THRUST, Type.FIGHTING, MoveCategory.PHYSICAL, 15, 100, 20, -1, 0, 3) .attr(MultiHitAttr), new SelfStatusMove(Moves.CAMOUFLAGE, Type.NORMAL, -1, 20, -1, 0, 3) @@ -8959,8 +9232,7 @@ export function initMoves() { .chargeText(i18next.t("moveTriggers:sprangUp", { pokemonName: "{USER}" })) .chargeAttr(SemiInvulnerableAttr, BattlerTagType.FLYING) .attr(StatusEffectAttr, StatusEffect.PARALYSIS) - .condition(failOnGravityCondition) - .ignoresVirtual(), + .condition(failOnGravityCondition), new AttackMove(Moves.MUD_SHOT, Type.GROUND, MoveCategory.SPECIAL, 55, 95, 15, 100, 0, 3) .attr(StatStageChangeAttr, [ Stat.SPD ], -1), new AttackMove(Moves.POISON_TAIL, Type.POISON, MoveCategory.PHYSICAL, 50, 100, 25, 10, 0, 3) @@ -9087,12 +9359,10 @@ export function initMoves() { .target(MoveTarget.USER_SIDE), new StatusMove(Moves.ME_FIRST, Type.NORMAL, -1, 20, -1, 0, 4) .ignoresSubstitute() - .ignoresVirtual() .target(MoveTarget.NEAR_ENEMY) .unimplemented(), new SelfStatusMove(Moves.COPYCAT, Type.NORMAL, -1, 20, -1, 0, 4) - .attr(CopyMoveAttr) - .ignoresVirtual(), + .attr(CopyMoveAttr, false, invalidCopycatMoves), new StatusMove(Moves.POWER_SWAP, Type.PSYCHIC, -1, 10, 100, 0, 4) .attr(SwapStatStagesAttr, [ Stat.ATK, Stat.SPATK ]) .ignoresSubstitute(), @@ -9316,8 +9586,7 @@ export function initMoves() { new ChargingAttackMove(Moves.SHADOW_FORCE, Type.GHOST, MoveCategory.PHYSICAL, 120, 100, 5, -1, 0, 4) .chargeText(i18next.t("moveTriggers:vanishedInstantly", { pokemonName: "{USER}" })) .chargeAttr(SemiInvulnerableAttr, BattlerTagType.HIDDEN) - .ignoresProtect() - .ignoresVirtual(), + .ignoresProtect(), new SelfStatusMove(Moves.HONE_CLAWS, Type.DARK, -1, 15, -1, 0, 5) .attr(StatStageChangeAttr, [ Stat.ATK, Stat.ACC ], 1, true), new StatusMove(Moves.WIDE_GUARD, Type.ROCK, -1, 10, -1, 3, 5) @@ -9444,7 +9713,6 @@ export function initMoves() { .chargeAttr(SemiInvulnerableAttr, BattlerTagType.FLYING) .condition(failOnGravityCondition) .condition((user, target, move) => !target.getTag(BattlerTagType.SUBSTITUTE)) - .ignoresVirtual() .partial(), // Should immobilize the target, Flying types should take no damage. cf https://bulbapedia.bulbagarden.net/wiki/Sky_Drop_(move) and https://www.smogon.com/dex/sv/moves/sky-drop/ new SelfStatusMove(Moves.SHIFT_GEAR, Type.STEEL, -1, 10, -1, 0, 5) .attr(StatStageChangeAttr, [ Stat.ATK ], 1, true) @@ -9601,8 +9869,7 @@ export function initMoves() { .makesContact(false), new ChargingAttackMove(Moves.ICE_BURN, Type.ICE, MoveCategory.SPECIAL, 140, 90, 5, 30, 0, 5) .chargeText(i18next.t("moveTriggers:becameCloakedInFreezingAir", { pokemonName: "{USER}" })) - .attr(StatusEffectAttr, StatusEffect.BURN) - .ignoresVirtual(), + .attr(StatusEffectAttr, StatusEffect.BURN), new AttackMove(Moves.SNARL, Type.DARK, MoveCategory.SPECIAL, 55, 95, 15, 100, 0, 5) .attr(StatStageChangeAttr, [ Stat.SPATK ], -1) .soundBased() @@ -9645,8 +9912,7 @@ export function initMoves() { new ChargingAttackMove(Moves.PHANTOM_FORCE, Type.GHOST, MoveCategory.PHYSICAL, 90, 100, 10, -1, 0, 6) .chargeText(i18next.t("moveTriggers:vanishedInstantly", { pokemonName: "{USER}" })) .chargeAttr(SemiInvulnerableAttr, BattlerTagType.HIDDEN) - .ignoresProtect() - .ignoresVirtual(), + .ignoresProtect(), new StatusMove(Moves.TRICK_OR_TREAT, Type.GHOST, 100, 20, -1, 0, 6) .attr(AddTypeAttr, Type.GHOST), new StatusMove(Moves.NOBLE_ROAR, Type.NORMAL, 100, 30, -1, 0, 6) @@ -9755,8 +10021,7 @@ export function initMoves() { .powderMove(), new ChargingSelfStatusMove(Moves.GEOMANCY, Type.FAIRY, -1, 10, -1, 0, 6) .chargeText(i18next.t("moveTriggers:isChargingPower", { pokemonName: "{USER}" })) - .attr(StatStageChangeAttr, [ Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2, true) - .ignoresVirtual(), + .attr(StatStageChangeAttr, [ Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2, true), new StatusMove(Moves.MAGNETIC_FLUX, Type.ELECTRIC, -1, 20, -1, 0, 6) .attr(StatStageChangeAttr, [ Stat.DEF, Stat.SPDEF ], 1, false, { condition: (user, target, move) => !![ Abilities.PLUS, Abilities.MINUS ].find(a => target.hasAbility(a, false)) }) .ignoresSubstitute() @@ -9823,116 +10088,79 @@ export function initMoves() { .ignoresProtect(), /* Unused */ new AttackMove(Moves.BREAKNECK_BLITZ__PHYSICAL, Type.NORMAL, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.BREAKNECK_BLITZ__SPECIAL, Type.NORMAL, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.ALL_OUT_PUMMELING__PHYSICAL, Type.FIGHTING, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.ALL_OUT_PUMMELING__SPECIAL, Type.FIGHTING, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SUPERSONIC_SKYSTRIKE__PHYSICAL, Type.FLYING, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SUPERSONIC_SKYSTRIKE__SPECIAL, Type.FLYING, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.ACID_DOWNPOUR__PHYSICAL, Type.POISON, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.ACID_DOWNPOUR__SPECIAL, Type.POISON, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.TECTONIC_RAGE__PHYSICAL, Type.GROUND, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.TECTONIC_RAGE__SPECIAL, Type.GROUND, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.CONTINENTAL_CRUSH__PHYSICAL, Type.ROCK, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.CONTINENTAL_CRUSH__SPECIAL, Type.ROCK, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SAVAGE_SPIN_OUT__PHYSICAL, Type.BUG, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SAVAGE_SPIN_OUT__SPECIAL, Type.BUG, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.NEVER_ENDING_NIGHTMARE__PHYSICAL, Type.GHOST, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.NEVER_ENDING_NIGHTMARE__SPECIAL, Type.GHOST, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.CORKSCREW_CRASH__PHYSICAL, Type.STEEL, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.CORKSCREW_CRASH__SPECIAL, Type.STEEL, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.INFERNO_OVERDRIVE__PHYSICAL, Type.FIRE, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.INFERNO_OVERDRIVE__SPECIAL, Type.FIRE, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.HYDRO_VORTEX__PHYSICAL, Type.WATER, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.HYDRO_VORTEX__SPECIAL, Type.WATER, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.BLOOM_DOOM__PHYSICAL, Type.GRASS, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.BLOOM_DOOM__SPECIAL, Type.GRASS, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.GIGAVOLT_HAVOC__PHYSICAL, Type.ELECTRIC, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.GIGAVOLT_HAVOC__SPECIAL, Type.ELECTRIC, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SHATTERED_PSYCHE__PHYSICAL, Type.PSYCHIC, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SHATTERED_PSYCHE__SPECIAL, Type.PSYCHIC, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SUBZERO_SLAMMER__PHYSICAL, Type.ICE, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SUBZERO_SLAMMER__SPECIAL, Type.ICE, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.DEVASTATING_DRAKE__PHYSICAL, Type.DRAGON, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.DEVASTATING_DRAKE__SPECIAL, Type.DRAGON, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.BLACK_HOLE_ECLIPSE__PHYSICAL, Type.DARK, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.BLACK_HOLE_ECLIPSE__SPECIAL, Type.DARK, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.TWINKLE_TACKLE__PHYSICAL, Type.FAIRY, MoveCategory.PHYSICAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.TWINKLE_TACKLE__SPECIAL, Type.FAIRY, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.CATASTROPIKA, Type.ELECTRIC, MoveCategory.PHYSICAL, 210, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), /* End Unused */ new SelfStatusMove(Moves.SHORE_UP, Type.GROUND, -1, 5, -1, 0, 7) .attr(SandHealAttr) @@ -10049,35 +10277,33 @@ export function initMoves() { .target(MoveTarget.USER_SIDE), /* Unused */ new AttackMove(Moves.SINISTER_ARROW_RAID, Type.GHOST, MoveCategory.PHYSICAL, 180, -1, 1, -1, 0, 7) + .unimplemented() .makesContact(false) - .edgeCase() // I assume it's because the user needs spirit shackle and decidueye - .ignoresVirtual(), + .edgeCase(), // I assume it's because the user needs spirit shackle and decidueye new AttackMove(Moves.MALICIOUS_MOONSAULT, Type.DARK, MoveCategory.PHYSICAL, 180, -1, 1, -1, 0, 7) + .unimplemented() .attr(AlwaysHitMinimizeAttr) .attr(HitsTagAttr, BattlerTagType.MINIMIZED, true) - .edgeCase() // I assume it's because it needs darkest lariat and incineroar - .ignoresVirtual(), + .edgeCase(), // I assume it's because it needs darkest lariat and incineroar new AttackMove(Moves.OCEANIC_OPERETTA, Type.WATER, MoveCategory.SPECIAL, 195, -1, 1, -1, 0, 7) - .edgeCase() // I assume it's because it needs sparkling aria and primarina - .ignoresVirtual(), + .unimplemented() + .edgeCase(), // I assume it's because it needs sparkling aria and primarina new AttackMove(Moves.GUARDIAN_OF_ALOLA, Type.FAIRY, MoveCategory.SPECIAL, -1, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.SOUL_STEALING_7_STAR_STRIKE, Type.GHOST, MoveCategory.PHYSICAL, 195, -1, 1, -1, 0, 7) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.STOKED_SPARKSURFER, Type.ELECTRIC, MoveCategory.SPECIAL, 175, -1, 1, 100, 0, 7) - .edgeCase() // I assume it's because it needs thunderbolt and Alola Raichu - .ignoresVirtual(), + .unimplemented() + .edgeCase(), // I assume it's because it needs thunderbolt and Alola Raichu new AttackMove(Moves.PULVERIZING_PANCAKE, Type.NORMAL, MoveCategory.PHYSICAL, 210, -1, 1, -1, 0, 7) - .edgeCase() // I assume it's because it needs giga impact and snorlax - .ignoresVirtual(), + .unimplemented() + .edgeCase(), // I assume it's because it needs giga impact and snorlax new SelfStatusMove(Moves.EXTREME_EVOBOOST, Type.NORMAL, -1, 1, -1, 0, 7) - .attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2, true) - .ignoresVirtual(), + .unimplemented() + .attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2, true), new AttackMove(Moves.GENESIS_SUPERNOVA, Type.PSYCHIC, MoveCategory.SPECIAL, 185, -1, 1, 100, 0, 7) - .attr(TerrainChangeAttr, TerrainType.PSYCHIC) - .ignoresVirtual(), + .unimplemented() + .attr(TerrainChangeAttr, TerrainType.PSYCHIC), /* End Unused */ new AttackMove(Moves.SHELL_TRAP, Type.FIRE, MoveCategory.SPECIAL, 150, 100, 5, -1, -3, 7) .attr(AddBattlerTagHeaderAttr, BattlerTagType.SHELL_TRAP) @@ -10116,8 +10342,8 @@ export function initMoves() { .attr(FormChangeItemTypeAttr), /* Unused */ new AttackMove(Moves.TEN_MILLION_VOLT_THUNDERBOLT, Type.ELECTRIC, MoveCategory.SPECIAL, 195, -1, 1, -1, 0, 7) - .edgeCase() // I assume it's because it needs thunderbolt and pikachu in a cap - .ignoresVirtual(), + .unimplemented() + .edgeCase(), // I assume it's because it needs thunderbolt and pikachu in a cap /* End Unused */ new AttackMove(Moves.MIND_BLOWN, Type.FIRE, MoveCategory.SPECIAL, 150, 100, 5, -1, 0, 7) .condition(failIfDampCondition) @@ -10131,28 +10357,28 @@ export function initMoves() { .ignoresAbilities(), /* Unused */ new AttackMove(Moves.LIGHT_THAT_BURNS_THE_SKY, Type.PSYCHIC, MoveCategory.SPECIAL, 200, -1, 1, -1, 0, 7) + .unimplemented() .attr(PhotonGeyserCategoryAttr) - .ignoresAbilities() - .ignoresVirtual(), + .ignoresAbilities(), new AttackMove(Moves.SEARING_SUNRAZE_SMASH, Type.STEEL, MoveCategory.PHYSICAL, 200, -1, 1, -1, 0, 7) - .ignoresAbilities() - .ignoresVirtual(), + .unimplemented() + .ignoresAbilities(), new AttackMove(Moves.MENACING_MOONRAZE_MAELSTROM, Type.GHOST, MoveCategory.SPECIAL, 200, -1, 1, -1, 0, 7) - .ignoresAbilities() - .ignoresVirtual(), + .unimplemented() + .ignoresAbilities(), new AttackMove(Moves.LETS_SNUGGLE_FOREVER, Type.FAIRY, MoveCategory.PHYSICAL, 190, -1, 1, -1, 0, 7) - .edgeCase() // I assume it needs play rough and mimikyu - .ignoresVirtual(), + .unimplemented() + .edgeCase(), // I assume it needs play rough and mimikyu new AttackMove(Moves.SPLINTERED_STORMSHARDS, Type.ROCK, MoveCategory.PHYSICAL, 190, -1, 1, -1, 0, 7) + .unimplemented() .attr(ClearTerrainAttr) - .makesContact(false) - .ignoresVirtual(), + .makesContact(false), new AttackMove(Moves.CLANGOROUS_SOULBLAZE, Type.DRAGON, MoveCategory.SPECIAL, 185, -1, 1, 100, 0, 7) + .unimplemented() .attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ], 1, true, { firstTargetOnly: true }) .soundBased() .target(MoveTarget.ALL_NEAR_ENEMIES) - .edgeCase() // I assume it needs clanging scales and Kommo-O - .ignoresVirtual(), + .edgeCase(), // I assume it needs clanging scales and Kommo-O /* End Unused */ new AttackMove(Moves.ZIPPY_ZAP, Type.ELECTRIC, MoveCategory.PHYSICAL, 50, 100, 15, -1, 2, 7) // LGPE Implementation .attr(CritOnlyAttr), @@ -10190,9 +10416,9 @@ export function initMoves() { .punchingMove(), /* Unused */ new SelfStatusMove(Moves.MAX_GUARD, Type.NORMAL, -1, 10, -1, 4, 8) + .unimplemented() .attr(ProtectAttr) - .condition(failIfLastCondition) - .ignoresVirtual(), + .condition(failIfLastCondition), /* End Unused */ new AttackMove(Moves.DYNAMAX_CANNON, Type.DRAGON, MoveCategory.SPECIAL, 100, 100, 5, -1, 0, 8) .attr(MovePowerMultiplierAttr, (user, target, move) => { @@ -10205,8 +10431,7 @@ export function initMoves() { return 1; } }) - .attr(DiscourageFrequentUseAttr) - .ignoresVirtual(), + .attr(DiscourageFrequentUseAttr), new AttackMove(Moves.SNIPE_SHOT, Type.WATER, MoveCategory.SPECIAL, 80, 100, 15, -1, 0, 8) .attr(HighCritAttr) @@ -10252,76 +10477,58 @@ export function initMoves() { /* Unused */ new AttackMove(Moves.MAX_FLARE, Type.FIRE, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_FLUTTERBY, Type.BUG, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_LIGHTNING, Type.ELECTRIC, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_STRIKE, Type.NORMAL, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_KNUCKLE, Type.FIGHTING, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_PHANTASM, Type.GHOST, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_HAILSTORM, Type.ICE, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_OOZE, Type.POISON, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_GEYSER, Type.WATER, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_AIRSTREAM, Type.FLYING, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_STARFALL, Type.FAIRY, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_WYRMWIND, Type.DRAGON, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_MINDSTORM, Type.PSYCHIC, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_ROCKFALL, Type.ROCK, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_QUAKE, Type.GROUND, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_DARKNESS, Type.DARK, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_OVERGROWTH, Type.GRASS, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), new AttackMove(Moves.MAX_STEELSPIKE, Type.STEEL, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) - .unimplemented() - .ignoresVirtual(), + .unimplemented(), /* End Unused */ new SelfStatusMove(Moves.CLANGOROUS_SOUL, Type.DRAGON, 100, 5, -1, 0, 8) .attr(CutHpStatStageBoostAttr, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ], 1, 3) @@ -10394,8 +10601,7 @@ export function initMoves() { .makesContact(false), new ChargingAttackMove(Moves.METEOR_BEAM, Type.ROCK, MoveCategory.SPECIAL, 120, 90, 10, -1, 0, 8) .chargeText(i18next.t("moveTriggers:isOverflowingWithSpacePower", { pokemonName: "{USER}" })) - .chargeAttr(StatStageChangeAttr, [ Stat.SPATK ], 1, true) - .ignoresVirtual(), + .chargeAttr(StatStageChangeAttr, [ Stat.SPATK ], 1, true), new AttackMove(Moves.SHELL_SIDE_ARM, Type.POISON, MoveCategory.SPECIAL, 90, 100, 10, 20, 0, 8) .attr(ShellSideArmCategoryAttr) .attr(StatusEffectAttr, StatusEffect.POISON) @@ -10422,7 +10628,8 @@ export function initMoves() { new AttackMove(Moves.LASH_OUT, Type.DARK, MoveCategory.PHYSICAL, 75, 100, 5, -1, 0, 8) .attr(MovePowerMultiplierAttr, (user, _target, _move) => user.turnData.statStagesDecreased ? 2 : 1), new AttackMove(Moves.POLTERGEIST, Type.GHOST, MoveCategory.PHYSICAL, 110, 90, 5, -1, 0, 8) - .attr(AttackedByItemAttr) + .condition(failIfNoTargetHeldItemsCondition) + .attr(PreMoveMessageAttr, attackedByItemMessageFunc) .makesContact(false), new StatusMove(Moves.CORROSIVE_GAS, Type.POISON, 100, 40, -1, 0, 8) .target(MoveTarget.ALL_NEAR_OTHERS) @@ -10853,8 +11060,7 @@ export function initMoves() { new ChargingAttackMove(Moves.ELECTRO_SHOT, Type.ELECTRIC, MoveCategory.SPECIAL, 130, 100, 10, 100, 0, 9) .chargeText(i18next.t("moveTriggers:absorbedElectricity", { pokemonName: "{USER}" })) .chargeAttr(StatStageChangeAttr, [ Stat.SPATK ], 1, true) - .chargeAttr(WeatherInstantChargeAttr, [ WeatherType.RAIN, WeatherType.HEAVY_RAIN ]) - .ignoresVirtual(), + .chargeAttr(WeatherInstantChargeAttr, [ WeatherType.RAIN, WeatherType.HEAVY_RAIN ]), new AttackMove(Moves.TERA_STARSTORM, Type.NORMAL, MoveCategory.SPECIAL, 120, 100, 5, -1, 0, 9) .attr(TeraMoveCategoryAttr) .attr(TeraStarstormTypeAttr) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 84486b30372..574c2a67f65 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -516,8 +516,7 @@ export abstract class PokemonSpeciesForm { globalScene.anims.get(spriteKey).frameRate = 10; } const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant).replace("variant/", "").replace(/_[1-3]$/, ""); - globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant); - resolve(); + globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant).then(() => resolve()); }); if (startLoad) { if (!globalScene.load.isLoading()) { @@ -948,19 +947,6 @@ export class PokemonForm extends PokemonSpeciesForm { } } -export const noStarterFormKeys: string[] = [ - SpeciesFormKey.MEGA, - SpeciesFormKey.MEGA_X, - SpeciesFormKey.MEGA_Y, - SpeciesFormKey.PRIMAL, - SpeciesFormKey.ORIGIN, - SpeciesFormKey.THERIAN, - SpeciesFormKey.GIGANTAMAX, - SpeciesFormKey.GIGANTAMAX_RAPID, - SpeciesFormKey.GIGANTAMAX_SINGLE, - SpeciesFormKey.ETERNAMAX -].map(k => k.toString()); - /** * Method to get the daily list of starters with Pokerus. * @returns A list of starters with Pokerus @@ -1834,7 +1820,7 @@ export function initSpecies() { new PokemonSpecies(Species.COFAGRIGUS, 5, false, false, false, "Coffin Pokémon", Type.GHOST, null, 1.7, 76.5, Abilities.MUMMY, Abilities.NONE, Abilities.NONE, 483, 58, 50, 145, 95, 105, 30, 90, 50, 169, GrowthRate.MEDIUM_FAST, 50, false), new PokemonSpecies(Species.TIRTOUGA, 5, false, false, false, "Prototurtle Pokémon", Type.WATER, Type.ROCK, 0.7, 16.5, Abilities.SOLID_ROCK, Abilities.STURDY, Abilities.SWIFT_SWIM, 355, 54, 78, 103, 53, 45, 22, 45, 50, 71, GrowthRate.MEDIUM_FAST, 87.5, false), new PokemonSpecies(Species.CARRACOSTA, 5, false, false, false, "Prototurtle Pokémon", Type.WATER, Type.ROCK, 1.2, 81, Abilities.SOLID_ROCK, Abilities.STURDY, Abilities.SWIFT_SWIM, 495, 74, 108, 133, 83, 65, 32, 45, 50, 173, GrowthRate.MEDIUM_FAST, 87.5, false), - new PokemonSpecies(Species.ARCHEN, 5, false, false, false, "First Bird Pokémon", Type.ROCK, Type.FLYING, 0.5, 9.5, Abilities.DEFEATIST, Abilities.NONE, Abilities.EMERGENCY_EXIT, 401, 55, 112, 45, 74, 45, 70, 45, 50, 71, GrowthRate.MEDIUM_FAST, 87.5, false), //Custom Hidden + new PokemonSpecies(Species.ARCHEN, 5, false, false, false, "First Bird Pokémon", Type.ROCK, Type.FLYING, 0.5, 9.5, Abilities.DEFEATIST, Abilities.NONE, Abilities.WIMP_OUT, 401, 55, 112, 45, 74, 45, 70, 45, 50, 71, GrowthRate.MEDIUM_FAST, 87.5, false), //Custom Hidden new PokemonSpecies(Species.ARCHEOPS, 5, false, false, false, "First Bird Pokémon", Type.ROCK, Type.FLYING, 1.4, 32, Abilities.DEFEATIST, Abilities.NONE, Abilities.EMERGENCY_EXIT, 567, 75, 140, 65, 112, 65, 110, 45, 50, 177, GrowthRate.MEDIUM_FAST, 87.5, false), //Custom Hidden new PokemonSpecies(Species.TRUBBISH, 5, false, false, false, "Trash Bag Pokémon", Type.POISON, null, 0.6, 31, Abilities.STENCH, Abilities.STICKY_HOLD, Abilities.AFTERMATH, 329, 50, 50, 62, 40, 62, 65, 190, 50, 66, GrowthRate.MEDIUM_FAST, 50, false), new PokemonSpecies(Species.GARBODOR, 5, false, false, false, "Trash Heap Pokémon", Type.POISON, null, 1.9, 107.3, Abilities.STENCH, Abilities.WEAK_ARMOR, Abilities.AFTERMATH, 474, 80, 95, 82, 60, 82, 75, 60, 50, 166, GrowthRate.MEDIUM_FAST, 50, false, true, diff --git a/src/enums/challenges.ts b/src/enums/challenges.ts index c4dc7460dfe..7b506a61a2f 100644 --- a/src/enums/challenges.ts +++ b/src/enums/challenges.ts @@ -5,4 +5,5 @@ export enum Challenges { LOWER_STARTER_POINTS, FRESH_START, INVERSE_BATTLE, + FLIP_STAT, } diff --git a/src/field/mystery-encounter-intro.ts b/src/field/mystery-encounter-intro.ts index 4fce9b1dfc9..0110dabc7a9 100644 --- a/src/field/mystery-encounter-intro.ts +++ b/src/field/mystery-encounter-intro.ts @@ -215,11 +215,12 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con resolve(); } + const shinyPromises: Promise[] = []; this.spriteConfigs.forEach((config) => { if (config.isPokemon) { globalScene.loadPokemonAtlas(config.spriteKey, config.fileRoot); if (config.isShiny) { - globalScene.loadPokemonVariantAssets(config.spriteKey, config.fileRoot, config.variant); + shinyPromises.push(globalScene.loadPokemonVariantAssets(config.spriteKey, config.fileRoot, config.variant)); } } else if (config.isItem) { globalScene.loadAtlas("items", ""); @@ -254,7 +255,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con return true; }); - resolve(); + Promise.all(shinyPromises).then(() => resolve()); }); if (!globalScene.load.isLoading()) { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index d40254c8a6b..432f0a92fec 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1057,6 +1057,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { calculateBaseStats(): number[] { const baseStats = this.getSpeciesForm(true).baseStats.slice(0); + applyChallenges(globalScene.gameMode, ChallengeType.FLIP_STAT, this, baseStats); // Shuckle Juice globalScene.applyModifiers(PokemonBaseStatTotalModifier, this.isPlayer(), this, baseStats); // Old Gateau @@ -3298,7 +3299,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - getMoveQueue(): QueuedMove[] { + getMoveQueue(): TurnMove[] { return this.summonData.moveQueue; } @@ -4810,17 +4811,19 @@ export class EnemyPokemon extends Pokemon { * the Pokemon the move will target. * @returns this Pokemon's next move in the format {move, moveTargets} */ - getNextMove(): QueuedMove { + getNextMove(): TurnMove { // If this Pokemon has a move already queued, return it. - const queuedMove = this.getMoveQueue().length - ? this.getMoveset().find(m => m?.moveId === this.getMoveQueue()[0].move) - : null; - if (queuedMove) { - if (queuedMove.isUsable(this, this.getMoveQueue()[0].ignorePP)) { - return { move: queuedMove.moveId, targets: this.getMoveQueue()[0].targets, ignorePP: this.getMoveQueue()[0].ignorePP }; - } else { - this.getMoveQueue().shift(); - return this.getNextMove(); + const moveQueue = this.getMoveQueue(); + if (moveQueue.length !== 0) { + const queuedMove = moveQueue[0]; + if (queuedMove) { + const moveIndex = this.getMoveset().findIndex(m => m?.moveId === queuedMove.move); + if ((moveIndex > -1 && this.getMoveset()[moveIndex]!.isUsable(this, queuedMove.ignorePP)) || queuedMove.virtual) { + return queuedMove; + } else { + this.getMoveQueue().shift(); + return this.getNextMove(); + } } } @@ -5242,15 +5245,10 @@ export class EnemyPokemon extends Pokemon { export interface TurnMove { move: Moves; - targets?: BattlerIndex[]; - result: MoveResult; + targets: BattlerIndex[]; + result?: MoveResult; virtual?: boolean; turn?: number; -} - -export interface QueuedMove { - move: Moves; - targets: BattlerIndex[]; ignorePP?: boolean; } @@ -5266,7 +5264,7 @@ export interface AttackMoveResult { export class PokemonSummonData { /** [Atk, Def, SpAtk, SpDef, Spd, Acc, Eva] */ public statStages: number[] = [ 0, 0, 0, 0, 0, 0, 0 ]; - public moveQueue: QueuedMove[] = []; + public moveQueue: TurnMove[] = []; public tags: BattlerTag[] = []; public abilitySuppressed: boolean = false; public abilitiesApplied: Abilities[] = []; diff --git a/src/field/trainer.ts b/src/field/trainer.ts index fc12eb57abe..2b74c1e5069 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -428,7 +428,7 @@ export default class Trainer extends Phaser.GameObjects.Container { } // Prompts reroll of party member species if species already present in the enemy party - if (this.checkDuplicateSpecies(ret, baseSpecies)) { + if (this.checkDuplicateSpecies(baseSpecies.speciesId)) { console.log("Duplicate species detected, prompting reroll..."); retry = true; } @@ -443,17 +443,23 @@ export default class Trainer extends Phaser.GameObjects.Container { /** * Checks if the enemy trainer already has the Pokemon species in their party - * @param {PokemonSpecies} species {@linkcode PokemonSpecies} - * @param {PokemonSpecies} baseSpecies {@linkcode PokemonSpecies} - baseSpecies of the Pokemon if species is forced to evolve + * @param baseSpecies - The base {@linkcode Species} of the current Pokemon * @returns `true` if the species is already present in the party */ - checkDuplicateSpecies(species: PokemonSpecies, baseSpecies: PokemonSpecies): boolean { - const staticPartyPokemon = (signatureSpecies[TrainerType[this.config.trainerType]] ?? []).flat(1); - - const currentPartySpecies = globalScene.getEnemyParty().map(p => { - return p.species.speciesId; + checkDuplicateSpecies(baseSpecies: Species): boolean { + const staticSpecies = (signatureSpecies[TrainerType[this.config.trainerType]] ?? []).flat(1).map(s => { + let root = s; + while (pokemonPrevolutions.hasOwnProperty(root)) { + root = pokemonPrevolutions[root]; + } + return root; }); - return currentPartySpecies.includes(species.speciesId) || staticPartyPokemon.includes(baseSpecies.speciesId); + + const currentSpecies = globalScene.getEnemyParty().map(p => { + return p.species.getRootSpeciesId(); + }); + + return currentSpecies.includes(baseSpecies) || staticSpecies.includes(baseSpecies); } getPartyMemberMatchupScores(trainerSlot: TrainerSlot = TrainerSlot.NONE, forSwitch: boolean = false): [integer, integer][] { diff --git a/src/game-mode.ts b/src/game-mode.ts index 4e0f5715851..78a65a54890 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -12,6 +12,7 @@ import { Biome } from "#enums/biome"; import { Species } from "#enums/species"; import { Challenges } from "./enums/challenges"; import { globalScene } from "#app/global-scene"; +import { getDailyStartingBiome } from "./data/daily-run"; export enum GameModes { CLASSIC, @@ -120,7 +121,7 @@ export class GameMode implements GameModeConfig { getStartingBiome(): Biome { switch (this.modeId) { case GameModes.DAILY: - return globalScene.generateRandomBiome(this.getWaveForDifficulty(1)); + return getDailyStartingBiome(); default: return Overrides.STARTING_BIOME_OVERRIDE || Biome.TOWN; } diff --git a/src/loading-scene.ts b/src/loading-scene.ts index 2e9484a847d..40b6417f9f2 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -319,6 +319,7 @@ export class LoadingScene extends SceneBase { this.loadSe("pb_move"); this.loadSe("pb_catch"); this.loadSe("pb_lock"); + this.loadSe("crit_throw"); this.loadSe("pb_tray_enter"); this.loadSe("pb_tray_ball"); diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 6f354d7c74a..1f4fc0d6271 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -64,7 +64,7 @@ export class AttemptCapturePhase extends PokemonPhase { this.pokeball.setOrigin(0.5, 0.625); globalScene.field.add(this.pokeball); - globalScene.playSound("se/pb_throw", isCritical ? { rate: 0.2 } : undefined); // Crit catch throws are higher pitched + globalScene.playSound(isCritical ? "se/crit_throw" : "se/pb_throw"); globalScene.time.delayedCall(300, () => { globalScene.field.moveBelow(this.pokeball as Phaser.GameObjects.GameObject, pokemon); }); diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index d7293ec02fe..e2bad953fc5 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -11,7 +11,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type"; import { Biome } from "#app/enums/biome"; import { Moves } from "#app/enums/moves"; import { PokeballType } from "#enums/pokeball"; -import type { PlayerPokemon } from "#app/field/pokemon"; +import type { PlayerPokemon, TurnMove } from "#app/field/pokemon"; import { FieldPosition } from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import { Command } from "#app/ui/command-ui-handler"; @@ -86,19 +86,19 @@ export class CommandPhase extends FieldPhase { const moveQueue = playerPokemon.getMoveQueue(); while (moveQueue.length && moveQueue[0] - && moveQueue[0].move && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move) + && moveQueue[0].move && !moveQueue[0].virtual && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move) || !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct? moveQueue.shift(); } - if (moveQueue.length) { + if (moveQueue.length > 0) { const queuedMove = moveQueue[0]; if (!queuedMove.move) { - this.handleCommand(Command.FIGHT, -1, false); + this.handleCommand(Command.FIGHT, -1); } else { const moveIndex = playerPokemon.getMoveset().findIndex(m => m?.moveId === queuedMove.move); - if (moveIndex > -1 && playerPokemon.getMoveset()[moveIndex]!.isUsable(playerPokemon, queuedMove.ignorePP)) { // TODO: is the bang correct? - this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, { targets: queuedMove.targets, multiple: queuedMove.targets.length > 1 }); + if ((moveIndex > -1 && playerPokemon.getMoveset()[moveIndex]!.isUsable(playerPokemon, queuedMove.ignorePP)) || queuedMove.virtual) { // TODO: is the bang correct? + this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, queuedMove); } else { globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); } @@ -120,12 +120,24 @@ export class CommandPhase extends FieldPhase { switch (command) { case Command.FIGHT: let useStruggle = false; + const turnMove: TurnMove | undefined = (args.length === 2 ? (args[1] as TurnMove) : undefined); if (cursor === -1 || playerPokemon.trySelectMove(cursor, args[0] as boolean) || (useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) { - const moveId = !useStruggle ? cursor > -1 ? playerPokemon.getMoveset()[cursor]!.moveId : Moves.NONE : Moves.STRUGGLE; // TODO: is the bang correct? + + let moveId: Moves; + if (useStruggle) { + moveId = Moves.STRUGGLE; + } else if (turnMove !== undefined) { + moveId = turnMove.move; + } else if (cursor > -1) { + moveId = playerPokemon.getMoveset()[cursor]!.moveId; + } else { + moveId = Moves.NONE; + } + const turnCommand: TurnCommand = { command: Command.FIGHT, cursor: cursor, move: { move: moveId, targets: [], ignorePP: args[0] }, args: args }; - const moveTargets: MoveTargetSet = args.length < 3 ? getMoveTargets(playerPokemon, moveId) : args[2]; + const moveTargets: MoveTargetSet = turnMove === undefined ? getMoveTargets(playerPokemon, moveId) : { targets: turnMove.targets, multiple: turnMove.targets.length > 1 }; if (!moveId) { turnCommand.targets = [ this.fieldIndex ]; } diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 0673ad3effe..5330540c8b2 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -296,11 +296,6 @@ export class MovePhase extends BattlePhase { globalScene.eventTarget.dispatchEvent(new MoveUsedEvent(this.pokemon?.id, this.move.getMove(), this.move.ppUsed)); } - // Update the battle's "last move" pointer, unless we're currently mimicking a move. - if (!allMoves[this.move.moveId].hasAttr(CopyMoveAttr)) { - globalScene.currentBattle.lastMove = this.move.moveId; - } - /** * Determine if the move is successful (meaning that its damage/effects can be attempted) * by checking that all of the following are true: @@ -324,6 +319,14 @@ export class MovePhase extends BattlePhase { const success = passesConditions && !failedDueToWeather && !failedDueToTerrain; + // Update the battle's "last move" pointer, unless we're currently mimicking a move. + if (!allMoves[this.move.moveId].hasAttr(CopyMoveAttr)) { + // The last move used is unaffected by moves that fail + if (success) { + globalScene.currentBattle.lastMove = this.move.moveId; + } + } + /** * If the move has not failed, trigger ability-based user type changes and then execute it. * @@ -518,7 +521,7 @@ export class MovePhase extends BattlePhase { frenzyMissFunc(this.pokemon, this.move.getMove()); } - this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL }); + this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL, targets: this.targets }); this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT); this.pokemon.lapseTags(BattlerTagLapseType.AFTER_MOVE); diff --git a/src/system/achv.ts b/src/system/achv.ts index 1f5662dbdbe..fb17e7b1ced 100644 --- a/src/system/achv.ts +++ b/src/system/achv.ts @@ -5,7 +5,7 @@ import i18next from "i18next"; import * as Utils from "../utils"; import { PlayerGender } from "#enums/player-gender"; import type { Challenge } from "#app/data/challenge"; -import { FreshStartChallenge, SingleGenerationChallenge, SingleTypeChallenge, InverseBattleChallenge } from "#app/data/challenge"; +import { FlipStatChallenge, FreshStartChallenge, SingleGenerationChallenge, SingleTypeChallenge, InverseBattleChallenge } from "#app/data/challenge"; import type { ConditionFn } from "#app/@types/common"; import { Stat, getShortenedStatKey } from "#app/enums/stat"; import { Challenges } from "#app/enums/challenges"; @@ -280,6 +280,10 @@ export function getAchievementDescription(localizationKey: string): string { return i18next.t("achv:FRESH_START.description", { context: genderStr }); case "INVERSE_BATTLE": return i18next.t("achv:INVERSE_BATTLE.description", { context: genderStr }); + case "FLIP_STATS": + return i18next.t("achv:FLIP_STATS.description", { context: genderStr }); + case "FLIP_INVERSE": + return i18next.t("achv:FLIP_INVERSE.description", { context: genderStr }); case "BREEDERS_IN_SPACE": return i18next.t("achv:BREEDERS_IN_SPACE.description", { context: genderStr }); default: @@ -288,6 +292,7 @@ export function getAchievementDescription(localizationKey: string): string { } + export const achvs = { _10K_MONEY: new MoneyAchv("10K_MONEY", "", 10000, "nugget", 10), _100K_MONEY: new MoneyAchv("100K_MONEY", "", 100000, "big_nugget", 25).setSecret(true), @@ -330,35 +335,37 @@ export const achvs = { PERFECT_IVS: new Achv("PERFECT_IVS", "", "PERFECT_IVS.description", "blunder_policy", 100), CLASSIC_VICTORY: new Achv("CLASSIC_VICTORY", "", "CLASSIC_VICTORY.description", "relic_crown", 150, (_) => globalScene.gameData.gameStats.sessionsWon === 0), UNEVOLVED_CLASSIC_VICTORY: new Achv("UNEVOLVED_CLASSIC_VICTORY", "", "UNEVOLVED_CLASSIC_VICTORY.description", "eviolite", 175, (_) => globalScene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)), - MONO_GEN_ONE_VICTORY: new ChallengeAchv("MONO_GEN_ONE", "", "MONO_GEN_ONE.description", "ribbon_gen1", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 1 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_TWO_VICTORY: new ChallengeAchv("MONO_GEN_TWO", "", "MONO_GEN_TWO.description", "ribbon_gen2", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 2 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_THREE_VICTORY: new ChallengeAchv("MONO_GEN_THREE", "", "MONO_GEN_THREE.description", "ribbon_gen3", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 3 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_FOUR_VICTORY: new ChallengeAchv("MONO_GEN_FOUR", "", "MONO_GEN_FOUR.description", "ribbon_gen4", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 4 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_FIVE_VICTORY: new ChallengeAchv("MONO_GEN_FIVE", "", "MONO_GEN_FIVE.description", "ribbon_gen5", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 5 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_SIX_VICTORY: new ChallengeAchv("MONO_GEN_SIX", "", "MONO_GEN_SIX.description", "ribbon_gen6", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 6 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_SEVEN_VICTORY: new ChallengeAchv("MONO_GEN_SEVEN", "", "MONO_GEN_SEVEN.description", "ribbon_gen7", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 7 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_EIGHT_VICTORY: new ChallengeAchv("MONO_GEN_EIGHT", "", "MONO_GEN_EIGHT.description", "ribbon_gen8", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 8 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GEN_NINE_VICTORY: new ChallengeAchv("MONO_GEN_NINE", "", "MONO_GEN_NINE.description", "ribbon_gen9", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 9 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_NORMAL: new ChallengeAchv("MONO_NORMAL", "", "MONO_NORMAL.description", "silk_scarf", 100, (c) => c instanceof SingleTypeChallenge && c.value === 1 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_FIGHTING: new ChallengeAchv("MONO_FIGHTING", "", "MONO_FIGHTING.description", "black_belt", 100, (c) => c instanceof SingleTypeChallenge && c.value === 2 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_FLYING: new ChallengeAchv("MONO_FLYING", "", "MONO_FLYING.description", "sharp_beak", 100, (c) => c instanceof SingleTypeChallenge && c.value === 3 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_POISON: new ChallengeAchv("MONO_POISON", "", "MONO_POISON.description", "poison_barb", 100, (c) => c instanceof SingleTypeChallenge && c.value === 4 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GROUND: new ChallengeAchv("MONO_GROUND", "", "MONO_GROUND.description", "soft_sand", 100, (c) => c instanceof SingleTypeChallenge && c.value === 5 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_ROCK: new ChallengeAchv("MONO_ROCK", "", "MONO_ROCK.description", "hard_stone", 100, (c) => c instanceof SingleTypeChallenge && c.value === 6 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_BUG: new ChallengeAchv("MONO_BUG", "", "MONO_BUG.description", "silver_powder", 100, (c) => c instanceof SingleTypeChallenge && c.value === 7 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GHOST: new ChallengeAchv("MONO_GHOST", "", "MONO_GHOST.description", "spell_tag", 100, (c) => c instanceof SingleTypeChallenge && c.value === 8 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_STEEL: new ChallengeAchv("MONO_STEEL", "", "MONO_STEEL.description", "metal_coat", 100, (c) => c instanceof SingleTypeChallenge && c.value === 9 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_FIRE: new ChallengeAchv("MONO_FIRE", "", "MONO_FIRE.description", "charcoal", 100, (c) => c instanceof SingleTypeChallenge && c.value === 10 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_WATER: new ChallengeAchv("MONO_WATER", "", "MONO_WATER.description", "mystic_water", 100, (c) => c instanceof SingleTypeChallenge && c.value === 11 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_GRASS: new ChallengeAchv("MONO_GRASS", "", "MONO_GRASS.description", "miracle_seed", 100, (c) => c instanceof SingleTypeChallenge && c.value === 12 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_ELECTRIC: new ChallengeAchv("MONO_ELECTRIC", "", "MONO_ELECTRIC.description", "magnet", 100, (c) => c instanceof SingleTypeChallenge && c.value === 13 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_PSYCHIC: new ChallengeAchv("MONO_PSYCHIC", "", "MONO_PSYCHIC.description", "twisted_spoon", 100, (c) => c instanceof SingleTypeChallenge && c.value === 14 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_ICE: new ChallengeAchv("MONO_ICE", "", "MONO_ICE.description", "never_melt_ice", 100, (c) => c instanceof SingleTypeChallenge && c.value === 15 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_DRAGON: new ChallengeAchv("MONO_DRAGON", "", "MONO_DRAGON.description", "dragon_fang", 100, (c) => c instanceof SingleTypeChallenge && c.value === 16 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_DARK: new ChallengeAchv("MONO_DARK", "", "MONO_DARK.description", "black_glasses", 100, (c) => c instanceof SingleTypeChallenge && c.value === 17 && !globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)), - MONO_FAIRY: new ChallengeAchv("MONO_FAIRY", "", "MONO_FAIRY.description", "fairy_feather", 100, (c) => c instanceof SingleTypeChallenge && c.value === 18 && !globalScene.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) => c instanceof FreshStartChallenge && c.value > 0 && !globalScene.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), + MONO_GEN_ONE_VICTORY: new ChallengeAchv("MONO_GEN_ONE", "", "MONO_GEN_ONE.description", "ribbon_gen1", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 1 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_TWO_VICTORY: new ChallengeAchv("MONO_GEN_TWO", "", "MONO_GEN_TWO.description", "ribbon_gen2", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 2 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_THREE_VICTORY: new ChallengeAchv("MONO_GEN_THREE", "", "MONO_GEN_THREE.description", "ribbon_gen3", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 3 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_FOUR_VICTORY: new ChallengeAchv("MONO_GEN_FOUR", "", "MONO_GEN_FOUR.description", "ribbon_gen4", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 4 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_FIVE_VICTORY: new ChallengeAchv("MONO_GEN_FIVE", "", "MONO_GEN_FIVE.description", "ribbon_gen5", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 5 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_SIX_VICTORY: new ChallengeAchv("MONO_GEN_SIX", "", "MONO_GEN_SIX.description", "ribbon_gen6", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 6 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_SEVEN_VICTORY: new ChallengeAchv("MONO_GEN_SEVEN", "", "MONO_GEN_SEVEN.description", "ribbon_gen7", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 7 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_EIGHT_VICTORY: new ChallengeAchv("MONO_GEN_EIGHT", "", "MONO_GEN_EIGHT.description", "ribbon_gen8", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 8 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GEN_NINE_VICTORY: new ChallengeAchv("MONO_GEN_NINE", "", "MONO_GEN_NINE.description", "ribbon_gen9", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 9 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_NORMAL: new ChallengeAchv("MONO_NORMAL", "", "MONO_NORMAL.description", "silk_scarf", 100, (c) => c instanceof SingleTypeChallenge && c.value === 1 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_FIGHTING: new ChallengeAchv("MONO_FIGHTING", "", "MONO_FIGHTING.description", "black_belt", 100, (c) => c instanceof SingleTypeChallenge && c.value === 2 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_FLYING: new ChallengeAchv("MONO_FLYING", "", "MONO_FLYING.description", "sharp_beak", 100, (c) => c instanceof SingleTypeChallenge && c.value === 3 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_POISON: new ChallengeAchv("MONO_POISON", "", "MONO_POISON.description", "poison_barb", 100, (c) => c instanceof SingleTypeChallenge && c.value === 4 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GROUND: new ChallengeAchv("MONO_GROUND", "", "MONO_GROUND.description", "soft_sand", 100, (c) => c instanceof SingleTypeChallenge && c.value === 5 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_ROCK: new ChallengeAchv("MONO_ROCK", "", "MONO_ROCK.description", "hard_stone", 100, (c) => c instanceof SingleTypeChallenge && c.value === 6 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_BUG: new ChallengeAchv("MONO_BUG", "", "MONO_BUG.description", "silver_powder", 100, (c) => c instanceof SingleTypeChallenge && c.value === 7 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GHOST: new ChallengeAchv("MONO_GHOST", "", "MONO_GHOST.description", "spell_tag", 100, (c) => c instanceof SingleTypeChallenge && c.value === 8 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_STEEL: new ChallengeAchv("MONO_STEEL", "", "MONO_STEEL.description", "metal_coat", 100, (c) => c instanceof SingleTypeChallenge && c.value === 9 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_FIRE: new ChallengeAchv("MONO_FIRE", "", "MONO_FIRE.description", "charcoal", 100, (c) => c instanceof SingleTypeChallenge && c.value === 10 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_WATER: new ChallengeAchv("MONO_WATER", "", "MONO_WATER.description", "mystic_water", 100, (c) => c instanceof SingleTypeChallenge && c.value === 11 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_GRASS: new ChallengeAchv("MONO_GRASS", "", "MONO_GRASS.description", "miracle_seed", 100, (c) => c instanceof SingleTypeChallenge && c.value === 12 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_ELECTRIC: new ChallengeAchv("MONO_ELECTRIC", "", "MONO_ELECTRIC.description", "magnet", 100, (c) => c instanceof SingleTypeChallenge && c.value === 13 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_PSYCHIC: new ChallengeAchv("MONO_PSYCHIC", "", "MONO_PSYCHIC.description", "twisted_spoon", 100, (c) => c instanceof SingleTypeChallenge && c.value === 14 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_ICE: new ChallengeAchv("MONO_ICE", "", "MONO_ICE.description", "never_melt_ice", 100, (c) => c instanceof SingleTypeChallenge && c.value === 15 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_DRAGON: new ChallengeAchv("MONO_DRAGON", "", "MONO_DRAGON.description", "dragon_fang", 100, (c) => c instanceof SingleTypeChallenge && c.value === 16 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_DARK: new ChallengeAchv("MONO_DARK", "", "MONO_DARK.description", "black_glasses", 100, (c) => c instanceof SingleTypeChallenge && c.value === 17 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + MONO_FAIRY: new ChallengeAchv("MONO_FAIRY", "", "MONO_FAIRY.description", "fairy_feather", 100, (c) => c instanceof SingleTypeChallenge && c.value === 18 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + FRESH_START: new ChallengeAchv("FRESH_START", "", "FRESH_START.description", "reviver_seed", 100, (c) => c instanceof FreshStartChallenge && c.value > 0 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), + INVERSE_BATTLE: new ChallengeAchv("INVERSE_BATTLE", "", "INVERSE_BATTLE.description", "inverse", 100, (c) => c instanceof InverseBattleChallenge && c.value > 0), + FLIP_STATS: new ChallengeAchv("FLIP_STATS", "", "FLIP_STATS.description", "dubious_disc", 100, (c) => c instanceof FlipStatChallenge && c.value > 0), + FLIP_INVERSE: new ChallengeAchv("FLIP_INVERSE", "", "FLIP_INVERSE.description", "cracked_pot", 100, (c) => c instanceof FlipStatChallenge && c.value > 0 && globalScene.gameMode.challenges.every(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), BREEDERS_IN_SPACE: new Achv("BREEDERS_IN_SPACE", "", "BREEDERS_IN_SPACE.description", "moon_stone", 50).setSecret(), }; diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 11b98d3fee6..58d416eb468 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -6,7 +6,7 @@ import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import type PokemonSpecies from "#app/data/pokemon-species"; -import { allSpecies, getPokemonSpecies, noStarterFormKeys } from "#app/data/pokemon-species"; +import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; import * as Utils from "#app/utils"; import Overrides from "#app/overrides"; @@ -1619,9 +1619,6 @@ export class GameData { const dexEntry = this.dexData[species.speciesId]; const caughtAttr = dexEntry.caughtAttr; const formIndex = pokemon.formIndex; - if (noStarterFormKeys.includes(pokemon.getFormKey())) { - pokemon.formIndex = 0; - } const dexAttr = pokemon.getDexAttr(); pokemon.formIndex = formIndex; diff --git a/src/test/moves/assist.test.ts b/src/test/moves/assist.test.ts new file mode 100644 index 00000000000..81633d9a277 --- /dev/null +++ b/src/test/moves/assist.test.ts @@ -0,0 +1,105 @@ +import { BattlerIndex } from "#app/battle"; +import { Stat } from "#app/enums/stat"; +import { MoveResult } from "#app/field/pokemon"; +import { CommandPhase } from "#app/phases/command-phase"; +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("Moves - Assist", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + // Manual moveset overrides are required for the player pokemon in these tests + // because the normal moveset override doesn't allow for accurate testing of moveset changes + game.override + .ability(Abilities.BALL_FETCH) + .battleType("double") + .disableCrits() + .enemySpecies(Species.MAGIKARP) + .enemyLevel(100) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH); + }); + + it("should only use an ally's moves", async () => { + game.override.enemyMoveset(Moves.SWORDS_DANCE); + await game.classicMode.startBattle([ Species.FEEBAS, Species.SHUCKLE ]); + + const [ feebas, shuckle ] = game.scene.getPlayerField(); + // These are all moves Assist cannot call; Sketch will be used to test that it can call other moves properly + game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + game.move.changeMoveset(shuckle, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + + game.move.select(Moves.ASSIST, 0); + game.move.select(Moves.SKETCH, 1); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER ]); + // Player_2 uses Sketch, copies Swords Dance, Player_1 uses Assist, uses Player_2's Sketched Swords Dance + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.getStatStage(Stat.ATK)).toBe(2); // Stat raised from Assist -> Swords Dance + }); + + it("should fail if there are no allies", async () => { + await game.classicMode.startBattle([ Species.FEEBAS ]); + + const feebas = game.scene.getPlayerPokemon()!; + game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + + game.move.select(Moves.ASSIST, 0); + await game.toNextTurn(); + expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); + + it("should fail if ally has no usable moves and user has usable moves", async () => { + game.override.enemyMoveset(Moves.SWORDS_DANCE); + await game.classicMode.startBattle([ Species.FEEBAS, Species.SHUCKLE ]); + + const [ feebas, shuckle ] = game.scene.getPlayerField(); + game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + game.move.changeMoveset(shuckle, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + + game.move.select(Moves.SKETCH, 0); + game.move.select(Moves.PROTECT, 1); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + // Player uses Sketch to copy Swords Dance, Player_2 stalls a turn. Player will attempt Assist and should have no usable moves + await game.toNextTurn(); + game.move.select(Moves.ASSIST, 0); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.PROTECT, 1); + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); + + it("should apply secondary effects of a move", async () => { + game.override.moveset([ Moves.ASSIST, Moves.WOOD_HAMMER, Moves.WOOD_HAMMER, Moves.WOOD_HAMMER ]); + await game.classicMode.startBattle([ Species.FEEBAS, Species.SHUCKLE ]); + + const [ feebas, shuckle ] = game.scene.getPlayerField(); + game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + game.move.changeMoveset(shuckle, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + + game.move.select(Moves.ASSIST, 0); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.ASSIST, 1); + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.isFullHp()).toBeFalsy(); // should receive recoil damage from Wood Hammer + }); +}); diff --git a/src/test/moves/copycat.test.ts b/src/test/moves/copycat.test.ts new file mode 100644 index 00000000000..d9e64289481 --- /dev/null +++ b/src/test/moves/copycat.test.ts @@ -0,0 +1,91 @@ +import { BattlerIndex } from "#app/battle"; +import { allMoves, RandomMoveAttr } from "#app/data/move"; +import { Stat } from "#app/enums/stat"; +import { MoveResult } from "#app/field/pokemon"; +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, vi } from "vitest"; + +describe("Moves - Copycat", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + const randomMoveAttr = allMoves[Moves.METRONOME].getAttrs(RandomMoveAttr)[0]; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .moveset([ Moves.COPYCAT, Moves.SPIKY_SHIELD, Moves.SWORDS_DANCE, Moves.SPLASH ]) + .ability(Abilities.BALL_FETCH) + .battleType("single") + .disableCrits() + .starterSpecies(Species.FEEBAS) + .enemySpecies(Species.MAGIKARP) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH); + }); + + it("should copy the last move successfully executed", async () => { + game.override.enemyMoveset(Moves.SUCKER_PUNCH); + await game.classicMode.startBattle(); + + game.move.select(Moves.SWORDS_DANCE); + await game.toNextTurn(); + + game.move.select(Moves.COPYCAT); // Last successful move should be Swords Dance + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.getStatStage(Stat.ATK)).toBe(4); + }); + + it("should fail when the last move used is not a valid Copycat move", async () => { + game.override.enemyMoveset(Moves.PROTECT); // Protect is not a valid move for Copycat to copy + await game.classicMode.startBattle(); + + game.move.select(Moves.SPIKY_SHIELD); // Spiky Shield is not a valid move for Copycat to copy + await game.toNextTurn(); + + game.move.select(Moves.COPYCAT); + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); + + it("should copy the called move when the last move successfully calls another", async () => { + game.override + .moveset([ Moves.SPLASH, Moves.METRONOME ]) + .enemyMoveset(Moves.COPYCAT); + await game.classicMode.startBattle(); + vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.SWORDS_DANCE); + + game.move.select(Moves.METRONOME); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); // Player moves first, so enemy can copy Swords Dance + await game.toNextTurn(); + + expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.ATK)).toBe(2); + }); + + it("should apply secondary effects of a move", async () => { + game.override.enemyMoveset(Moves.ACID_SPRAY); // Secondary effect lowers SpDef by 2 stages + await game.classicMode.startBattle(); + + game.move.select(Moves.COPYCAT); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.toNextTurn(); + + expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.SPDEF)).toBe(-2); + }); +}); diff --git a/src/test/moves/metronome.test.ts b/src/test/moves/metronome.test.ts new file mode 100644 index 00000000000..946dc92de0f --- /dev/null +++ b/src/test/moves/metronome.test.ts @@ -0,0 +1,113 @@ +import { RechargingTag, SemiInvulnerableTag } from "#app/data/battler-tags"; +import { allMoves, RandomMoveAttr } from "#app/data/move"; +import { Abilities } from "#app/enums/abilities"; +import { Stat } from "#app/enums/stat"; +import { CommandPhase } from "#app/phases/command-phase"; +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, it, expect, vi } from "vitest"; + +describe("Moves - Metronome", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + const randomMoveAttr = allMoves[Moves.METRONOME].getAttrs(RandomMoveAttr)[0]; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .moveset([ Moves.METRONOME, Moves.SPLASH ]) + .battleType("single") + .startingLevel(100) + .starterSpecies(Species.REGIELEKI) + .enemyLevel(100) + .enemySpecies(Species.SHUCKLE) + .enemyMoveset(Moves.SPLASH) + .enemyAbility(Abilities.BALL_FETCH); + }); + + it("should have one semi-invulnerable turn and deal damage on the second turn when a semi-invulnerable move is called", async () => { + await game.classicMode.startBattle(); + const player = game.scene.getPlayerPokemon()!; + const enemy = game.scene.getEnemyPokemon()!; + vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.DIVE); + + game.move.select(Moves.METRONOME); + await game.toNextTurn(); + + expect(player.getTag(SemiInvulnerableTag)).toBeTruthy(); + + await game.toNextTurn(); + expect(player.getTag(SemiInvulnerableTag)).toBeFalsy(); + expect(enemy.isFullHp()).toBeFalsy(); + }); + + it("should apply secondary effects of a move", async () => { + await game.classicMode.startBattle(); + const player = game.scene.getPlayerPokemon()!; + vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.WOOD_HAMMER); + + game.move.select(Moves.METRONOME); + await game.toNextTurn(); + + expect(player.isFullHp()).toBeFalsy(); + }); + + it("should recharge after using recharge move", async () => { + await game.classicMode.startBattle(); + const player = game.scene.getPlayerPokemon()!; + vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.HYPER_BEAM); + vi.spyOn(allMoves[Moves.HYPER_BEAM], "accuracy", "get").mockReturnValue(100); + + game.move.select(Moves.METRONOME); + await game.toNextTurn(); + + expect(player.getTag(RechargingTag)).toBeTruthy(); + }); + + it("should only target ally for Aromatic Mist", async () => { + game.override.battleType("double"); + await game.classicMode.startBattle([ Species.REGIELEKI, Species.RATTATA ]); + const [ leftPlayer, rightPlayer ] = game.scene.getPlayerField(); + const [ leftOpp, rightOpp ] = game.scene.getEnemyField(); + vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.AROMATIC_MIST); + + game.move.select(Moves.METRONOME, 0); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); + + expect(rightPlayer.getStatStage(Stat.SPDEF)).toBe(1); + expect(leftPlayer.getStatStage(Stat.SPDEF)).toBe(0); + expect(leftOpp.getStatStage(Stat.SPDEF)).toBe(0); + expect(rightOpp.getStatStage(Stat.SPDEF)).toBe(0); + }); + + it("should cause opponent to flee, and not crash for Roar", async () => { + await game.classicMode.startBattle(); + vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.ROAR); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.METRONOME); + await game.phaseInterceptor.to("BerryPhase"); + + const isVisible = enemyPokemon.visible; + const hasFled = enemyPokemon.switchOutStatus; + expect(!isVisible && hasFled).toBe(true); + + await game.phaseInterceptor.to("CommandPhase"); + }); +}); diff --git a/src/test/moves/mirror_move.test.ts b/src/test/moves/mirror_move.test.ts new file mode 100644 index 00000000000..e55c55038ae --- /dev/null +++ b/src/test/moves/mirror_move.test.ts @@ -0,0 +1,84 @@ +import { BattlerIndex } from "#app/battle"; +import { Stat } from "#app/enums/stat"; +import { MoveResult } from "#app/field/pokemon"; +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("Moves - Mirror Move", () => { + 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.MIRROR_MOVE, Moves.SPLASH ]) + .ability(Abilities.BALL_FETCH) + .battleType("single") + .disableCrits() + .enemySpecies(Species.MAGIKARP) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH); + }); + + it("should use the last move that the target used on the user", async () => { + game.override + .battleType("double") + .enemyMoveset([ Moves.TACKLE, Moves.GROWL ]); + await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + + game.move.select(Moves.MIRROR_MOVE, 0, BattlerIndex.ENEMY); // target's last move is Tackle, enemy should receive damage from Mirror Move copying Tackle + game.move.select(Moves.SPLASH, 1); + await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); + await game.forceEnemyMove(Moves.GROWL, BattlerIndex.PLAYER_2); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER ]); + await game.toNextTurn(); + + expect(game.scene.getEnemyField()[0].isFullHp()).toBeFalsy(); + }); + + it("should apply secondary effects of a move", async () => { + game.override.enemyMoveset(Moves.ACID_SPRAY); + await game.classicMode.startBattle([ Species.FEEBAS ]); + + game.move.select(Moves.MIRROR_MOVE); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.toNextTurn(); + + expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.SPDEF)).toBe(-2); + }); + + it("should be able to copy status moves", async () => { + game.override.enemyMoveset(Moves.GROWL); + await game.classicMode.startBattle([ Species.FEEBAS ]); + + game.move.select(Moves.MIRROR_MOVE); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.toNextTurn(); + + expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.ATK)).toBe(-1); + }); + + it("should fail if the target has not used any moves", async () => { + await game.classicMode.startBattle([ Species.FEEBAS ]); + + game.move.select(Moves.MIRROR_MOVE); + await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); +}); diff --git a/src/test/moves/sleep_talk.test.ts b/src/test/moves/sleep_talk.test.ts new file mode 100644 index 00000000000..9ad2d23f903 --- /dev/null +++ b/src/test/moves/sleep_talk.test.ts @@ -0,0 +1,75 @@ +import { Stat } from "#app/enums/stat"; +import { StatusEffect } from "#app/enums/status-effect"; +import { MoveResult } from "#app/field/pokemon"; +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("Moves - Sleep Talk", () => { + 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.SLEEP_TALK ]) + .statusEffect(StatusEffect.SLEEP) + .ability(Abilities.BALL_FETCH) + .battleType("single") + .disableCrits() + .enemySpecies(Species.MAGIKARP) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset(Moves.SPLASH) + .enemyLevel(100); + }); + + it("should fail when the user is not asleep", async () => { + game.override.statusEffect(StatusEffect.NONE); + await game.classicMode.startBattle([ Species.FEEBAS ]); + + game.move.select(Moves.SLEEP_TALK); + await game.toNextTurn(); + expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); + + it("should fail if the user has no valid moves", async () => { + game.override.moveset([ Moves.SLEEP_TALK, Moves.DIG, Moves.METRONOME, Moves.SOLAR_BEAM ]); + await game.classicMode.startBattle([ Species.FEEBAS ]); + + game.move.select(Moves.SLEEP_TALK); + await game.toNextTurn(); + expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); + + it("should call a random valid move if the user is asleep", async () => { + game.override.moveset([ Moves.SLEEP_TALK, Moves.DIG, Moves.FLY, Moves.SWORDS_DANCE ]); // Dig and Fly are invalid moves, Swords Dance should always be called + await game.classicMode.startBattle([ Species.FEEBAS ]); + + game.move.select(Moves.SLEEP_TALK); + await game.toNextTurn(); + expect(game.scene.getPlayerPokemon()!.getStatStage(Stat.ATK)); + }); + + it("should apply secondary effects of a move", async () => { + game.override.moveset([ Moves.SLEEP_TALK, Moves.DIG, Moves.FLY, Moves.WOOD_HAMMER ]); // Dig and Fly are invalid moves, Wood Hammer should always be called + await game.classicMode.startBattle(); + + game.move.select(Moves.SLEEP_TALK); + await game.toNextTurn(); + + expect(game.scene.getPlayerPokemon()!.isFullHp()).toBeFalsy(); // Wood Hammer recoil effect should be applied + }); +}); diff --git a/src/test/moves/spit_up.test.ts b/src/test/moves/spit_up.test.ts index fd21bb3c6c1..7f9dfaad38b 100644 --- a/src/test/moves/spit_up.test.ts +++ b/src/test/moves/spit_up.test.ts @@ -125,7 +125,7 @@ describe("Moves - Spit Up", () => { game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.FAIL }); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.FAIL, targets: [ game.scene.getEnemyPokemon()!.getBattlerIndex() ]}); expect(spitUp.calculateBattlePower).not.toHaveBeenCalled(); }); @@ -148,7 +148,7 @@ describe("Moves - Spit Up", () => { await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS }); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS, targets: [ game.scene.getEnemyPokemon()!.getBattlerIndex() ]}); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); @@ -176,7 +176,7 @@ describe("Moves - Spit Up", () => { game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS }); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS, targets: [ game.scene.getEnemyPokemon()!.getBattlerIndex() ]}); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); diff --git a/src/test/moves/stockpile.test.ts b/src/test/moves/stockpile.test.ts index e50fe041b0a..f83459cd09d 100644 --- a/src/test/moves/stockpile.test.ts +++ b/src/test/moves/stockpile.test.ts @@ -72,7 +72,7 @@ describe("Moves - Stockpile", () => { expect(user.getStatStage(Stat.SPDEF)).toBe(3); expect(stockpilingTag).toBeDefined(); expect(stockpilingTag.stockpiledCount).toBe(3); - expect(user.getMoveHistory().at(-1)).toMatchObject({ result: MoveResult.FAIL, move: Moves.STOCKPILE }); + expect(user.getMoveHistory().at(-1)).toMatchObject({ result: MoveResult.FAIL, move: Moves.STOCKPILE, targets: [ user.getBattlerIndex() ]}); } } }); diff --git a/src/test/moves/swallow.test.ts b/src/test/moves/swallow.test.ts index c154d3c7c2c..b2435ba77b3 100644 --- a/src/test/moves/swallow.test.ts +++ b/src/test/moves/swallow.test.ts @@ -135,7 +135,7 @@ describe("Moves - Swallow", () => { game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.FAIL }); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.FAIL, targets: [ pokemon.getBattlerIndex() ]}); }); describe("restores stat stage boosts granted by stacks", () => { @@ -156,7 +156,7 @@ describe("Moves - Swallow", () => { await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS }); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS, targets: [ pokemon.getBattlerIndex() ]}); expect(pokemon.getStatStage(Stat.DEF)).toBe(0); expect(pokemon.getStatStage(Stat.SPDEF)).toBe(0); @@ -183,7 +183,7 @@ describe("Moves - Swallow", () => { await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS }); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS, targets: [ pokemon.getBattlerIndex() ]}); expect(pokemon.getStatStage(Stat.DEF)).toBe(1); expect(pokemon.getStatStage(Stat.SPDEF)).toBe(-2); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 05740a349c6..0cca087ce8d 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -364,6 +364,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { success = this.setCursor(0); } else if (this.rowCursor < this.shopOptionsRows.length + 1) { success = this.setRowCursor(this.rowCursor + 1); + } else { + success = this.setRowCursor(0); } break; case Button.DOWN: @@ -371,13 +373,15 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { success = this.setRowCursor(this.rowCursor - 1); } else if (this.lockRarityButtonContainer.visible && this.cursor === 0) { success = this.setCursor(3); + } else { + success = this.setRowCursor(this.shopOptionsRows.length + 1); } break; case Button.LEFT: if (!this.rowCursor) { switch (this.cursor) { case 0: - success = false; + success = this.setCursor(2); break; case 1: if (this.lockRarityButtonContainer.visible) { @@ -395,11 +399,21 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { success = false; } break; + case 3: + if (this.lockRarityButtonContainer.visible) { + success = this.setCursor(2); + } else { + success = false; + } } } else if (this.cursor) { success = this.setCursor(this.cursor - 1); - } else if (this.rowCursor === 1 && this.rerollButtonContainer.visible) { - success = this.setRowCursor(0); + } else { + if (this.rowCursor === 1 && this.options.length === 0) { + success = false; + } else { + success = this.setCursor(this.getRowItems(this.rowCursor) - 1); + } } break; case Button.RIGHT: @@ -416,7 +430,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { success = this.setCursor(2); break; case 2: - success = false; + success = this.setCursor(0); break; case 3: if (this.transferButtonContainer.visible) { @@ -428,8 +442,12 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { } } else if (this.cursor < this.getRowItems(this.rowCursor) - 1) { success = this.setCursor(this.cursor + 1); - } else if (this.rowCursor === 1 && this.transferButtonContainer.visible) { - success = this.setRowCursor(0); + } else { + if (this.rowCursor === 1 && this.options.length === 0) { + success = this.setRowCursor(0); + } else { + success = this.setCursor(0); + } } break; } @@ -519,6 +537,14 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { newCursor = 2; } } + // Allows to find lock rarity button when looping from the top + if (rowCursor === 0 && lastRowCursor > 1 && newCursor === 0 && this.lockRarityButtonContainer.visible) { + newCursor = 3; + } + // Allows to loop to top when lock rarity button is shown + if (rowCursor === this.shopOptionsRows.length + 1 && lastRowCursor === 0 && this.cursor === 3) { + newCursor = 0; + } this.cursor = -1; this.setCursor(newCursor); return true; diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index 13f5020e5ad..fe2ac9e1221 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -157,6 +157,12 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { success = (this.cursor === 0) ? this.setCursor(this.cursor) : this.setCursor(this.cursor - 1, cursorPosition); } else if (this.scrollCursor) { success = this.setScrollCursor(this.scrollCursor - 1, cursorPosition); + } else if ((this.cursor === 0) && (this.scrollCursor === 0)) { + this.setScrollCursor(SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN); + // Revert to avoid an extra session slot sticking out + this.revertSessionSlot(SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN); + this.setCursor(SLOTS_ON_SCREEN - 1); + success = true; } break; case Button.DOWN: @@ -164,6 +170,11 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { success = this.setCursor(this.cursor + 1, cursorPosition); } else if (this.scrollCursor < SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN) { success = this.setScrollCursor(this.scrollCursor + 1, cursorPosition); + } else if ((this.cursor === SLOTS_ON_SCREEN - 1) && (this.scrollCursor === SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN)) { + this.setScrollCursor(0); + this.revertSessionSlot(SLOTS_ON_SCREEN - 1); + this.setCursor(0); + success = true; } break; case Button.RIGHT: diff --git a/src/ui/settings/navigationMenu.ts b/src/ui/settings/navigationMenu.ts index eeb6da319ef..5fa53b7c270 100644 --- a/src/ui/settings/navigationMenu.ts +++ b/src/ui/settings/navigationMenu.ts @@ -89,6 +89,13 @@ export class NavigationManager { } } + /** + * Removes menus from the manager in preparation for reset + */ + public clearNavigationMenus() { + this.navigationMenus.length = 0; + } + } export default class NavigationMenu extends Phaser.GameObjects.Container { diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 29c58d7087e..40325d24af7 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -2698,6 +2698,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.updateScroll(); }; + override destroy(): void { + // Without this the reference gets hung up and no startercontainers get GCd + this.starterContainers = []; + } + updateScroll = () => { const maxColumns = 9; const maxRows = 9; diff --git a/src/ui/ui-handler.ts b/src/ui/ui-handler.ts index 1f0155aef8b..89f8d9e65b6 100644 --- a/src/ui/ui-handler.ts +++ b/src/ui/ui-handler.ts @@ -62,4 +62,9 @@ export default abstract class UiHandler { clear() { this.active = false; } + /** + * To be implemented by individual handlers when necessary to free memory + * Called when {@linkcode BattleScene} is reset + */ + destroy(): void {} } diff --git a/src/ui/ui.ts b/src/ui/ui.ts index 6d44997f649..9e8c52b1d24 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -53,6 +53,7 @@ import TestDialogueUiHandler from "#app/ui/test-dialogue-ui-handler"; import AutoCompleteUiHandler from "./autocomplete-ui-handler"; import { Device } from "#enums/devices"; import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler"; +import { NavigationManager } from "./settings/navigationMenu"; export enum Mode { MESSAGE, @@ -614,4 +615,14 @@ export default class UI extends Phaser.GameObjects.Container { return globalScene.inputMethod; } } + + /** + * Attempts to free memory held by UI handlers + * and clears menus from {@linkcode NavigationManager} to prepare for reset + */ + public freeUIData(): void { + this.handlers.forEach(h => h.destroy()); + this.handlers = []; + NavigationManager.getInstance().clearNavigationMenus(); + } }