diff --git a/src/battle.ts b/src/battle.ts index 580bad9a5..601cbeb9c 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -11,6 +11,7 @@ import { BattleSpec } from "./enums/battle-spec"; import { PlayerGender } from "./system/game-data"; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; import { MoneyAchv } from "./system/achv"; +import { PokeballType } from "./data/pokeball"; export enum BattleType { WILD, @@ -61,6 +62,7 @@ export default class Battle { public battleSeed: string; private battleSeedState: string; public moneyScattered: number; + public lastUsedPokeball: PokeballType; private rngCounter: integer = 0; @@ -86,6 +88,7 @@ export default class Battle { this.battleSeed = Utils.randomString(16, true); this.battleSeedState = null; this.moneyScattered = 0; + this.lastUsedPokeball = null; } private initBattleSpec(): void { diff --git a/src/data/ability.ts b/src/data/ability.ts index 92b26ea15..63c9d84a1 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -22,6 +22,7 @@ import i18next, { Localizable } from "#app/plugins/i18n.js"; import { Command } from "../ui/command-ui-handler"; import Battle from "#app/battle.js"; import { ability } from "#app/locales/en/ability.js"; +import { PokeballType, getPokeballName } from "./pokeball"; export class Ability implements Localizable { public id: Abilities; @@ -2106,6 +2107,22 @@ export class PostTurnFormChangeAbAttr extends PostTurnAbAttr { } } +export class FetchBallAbAttr extends PostTurnAbAttr { + constructor() { + super(); + } + applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { + let lastUsed = pokemon.scene.currentBattle.lastUsedPokeball; + if(lastUsed != null) { + pokemon.scene.pokeballCounts[lastUsed]++; + pokemon.scene.currentBattle.lastUsedPokeball = null; + pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` found a\n${getPokeballName(lastUsed)}!`)); + return true; + } + return false; + } +} + export class PostBiomeChangeAbAttr extends AbAttr { } export class PostBiomeChangeWeatherChangeAbAttr extends PostBiomeChangeAbAttr { @@ -2452,7 +2469,6 @@ export class SuppressFieldAbilitiesAbAttr extends AbAttr { } } - export class AlwaysHitAbAttr extends AbAttr { } export class UncopiableAbilityAbAttr extends AbAttr { @@ -3403,7 +3419,7 @@ export function initAbilities() { new Ability(Abilities.LIBERO, 8) .unimplemented(), new Ability(Abilities.BALL_FETCH, 8) - .unimplemented(), + .attr(FetchBallAbAttr), new Ability(Abilities.COTTON_DOWN, 8) .unimplemented(), new Ability(Abilities.PROPELLER_TAIL, 8) diff --git a/src/phases.ts b/src/phases.ts index 9ed1161f7..1d16ba9c2 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4152,6 +4152,7 @@ export class AttemptCapturePhase extends PokemonPhase { scale: 1 }); + this.scene.currentBattle.lastUsedPokeball = this.pokeballType; this.removePb(); this.end(); }