diff --git a/README.md b/README.md index b2955f8c4..d08107867 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you have the motivation and experience with Typescript/Javascript (or are wil ### ❔ FAQ **How do I test a new _______?** -- In the `battle-scene.ts` file there are overrides for most values you'll need to change for testing +- In the `src/overrides.ts` file there are overrides for most values you'll need to change for testing ## 🪧 To Do diff --git a/src/data/ability.ts b/src/data/ability.ts index 960818a24..b43b3b625 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -827,13 +827,16 @@ export class PostDefendAbilitySwapAbAttr extends PostDefendAbAttr { } export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr { - constructor() { + private ability: Abilities; + + constructor(ability: Abilities) { super(); + this.ability = ability; } applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && !attacker.getAbility().hasAttr(UnsuppressableAbilityAbAttr) && !attacker.getAbility().hasAttr(PostDefendAbilityGiveAbAttr)) { - attacker.summonData.ability = pokemon.getAbility().id; + attacker.summonData.ability = this.ability; return true; } @@ -1982,13 +1985,19 @@ export class MoodyAbAttr extends PostTurnAbAttr { } applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - // TODO: Edge case of not choosing to buff or debuff a stat that's already maxed let selectableStats = [BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD]; - let increaseStat = selectableStats[Utils.randInt(selectableStats.length)]; - selectableStats = selectableStats.filter(s => s !== increaseStat); - let decreaseStat = selectableStats[Utils.randInt(selectableStats.length)]; - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [increaseStat], 2)); - pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [decreaseStat], -1)); + let increaseStatArray = selectableStats.filter(s => pokemon.summonData.battleStats[s] < 6); + let decreaseStatArray = selectableStats.filter(s => pokemon.summonData.battleStats[s] > -6); + + if (increaseStatArray.length > 0) { + let increaseStat = increaseStatArray[Utils.randInt(increaseStatArray.length)]; + decreaseStatArray = decreaseStatArray.filter(s => s !== increaseStat); + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [increaseStat], 2)); + } + if (decreaseStatArray.length > 0) { + let decreaseStat = selectableStats[Utils.randInt(selectableStats.length)]; + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [decreaseStat], -1)); + } return true; } } @@ -3023,7 +3032,7 @@ export function initAbilities() { new Ability(Abilities.INFILTRATOR, 5) .unimplemented(), new Ability(Abilities.MUMMY, 5) - .attr(PostDefendAbilityGiveAbAttr) + .attr(PostDefendAbilityGiveAbAttr, Abilities.MUMMY) .bypassFaint(), new Ability(Abilities.MOXIE, 5) .attr(PostVictoryStatChangeAbAttr, BattleStat.ATK, 1), @@ -3395,7 +3404,7 @@ export function initAbilities() { .attr(UnswappableAbilityAbAttr) .attr(UnsuppressableAbilityAbAttr), new Ability(Abilities.LINGERING_AROMA, 9) - .attr(PostDefendAbilityGiveAbAttr) + .attr(PostDefendAbilityGiveAbAttr, Abilities.LINGERING_AROMA) .bypassFaint(), new Ability(Abilities.SEED_SOWER, 9) .attr(PostDefendTerrainChangeAbAttr, TerrainType.GRASSY), diff --git a/src/data/move.ts b/src/data/move.ts index 0fedea1ec..dc6d326b2 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1496,6 +1496,23 @@ export class StatChangeAttr extends MoveEffectAttr { } } +export class AcupressureStatChangeAttr extends MoveEffectAttr { + constructor() { + super(); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise { + let randStats = [ BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD, BattleStat.ACC, BattleStat.EVA ]; + randStats = randStats.filter(s => target.summonData.battleStats[s] < 6); + if (randStats.length > 0) { + let boostStat = [randStats[Utils.randInt(randStats.length)]]; + user.scene.unshiftPhase(new StatChangePhase(user.scene, target.getBattlerIndex(), this.selfTarget, boostStat, 2)); + return true; + } + return false; + } +} + export class GrowthStatChangeAttr extends StatChangeAttr { constructor() { super([ BattleStat.ATK, BattleStat.SPATK ], 1, true); @@ -4823,7 +4840,7 @@ export function initMoves() { .attr(AddArenaTagAttr, ArenaTagType.TAILWIND, 4, true) .target(MoveTarget.USER_SIDE), new StatusMove(Moves.ACUPRESSURE, Type.NORMAL, -1, 30, -1, 0, 4) - .attr(StatChangeAttr, BattleStat.RAND, 2) + .attr(AcupressureStatChangeAttr) .target(MoveTarget.USER_OR_NEAR_ALLY), new AttackMove(Moves.METAL_BURST, Type.STEEL, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4) .attr(CounterDamageAttr, (move: Move) => (move.category === MoveCategory.PHYSICAL || move.category === MoveCategory.SPECIAL), 1.5) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 27728680c..05340344a 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -43,8 +43,8 @@ import { Nature, getNatureStatMultiplier } from '../data/nature'; import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from '../data/pokemon-forms'; import { TerrainType } from '../data/terrain'; import { TrainerSlot } from '../data/trainer-config'; +import { ABILITY_OVERRIDE, MOVE_OVERRIDE, MOVE_OVERRIDE_2, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_MOVE_OVERRIDE_2, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../overrides'; import { BerryType } from '../data/berry'; -import { ABILITY_OVERRIDE, MOVE_OVERRIDE, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../overrides'; import i18next from '../plugins/i18n'; export enum FieldPosition { @@ -725,6 +725,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.moveset[0] = new PokemonMove(MOVE_OVERRIDE, Math.min(this.moveset[0].ppUsed, allMoves[MOVE_OVERRIDE].pp)); else if (OPP_MOVE_OVERRIDE && !this.isPlayer()) this.moveset[0] = new PokemonMove(OPP_MOVE_OVERRIDE, Math.min(this.moveset[0].ppUsed, allMoves[OPP_MOVE_OVERRIDE].pp)); + if (MOVE_OVERRIDE_2 && this.isPlayer()) + this.moveset[1] = new PokemonMove(MOVE_OVERRIDE_2, Math.min(this.moveset[1].ppUsed, allMoves[MOVE_OVERRIDE_2].pp)); + else if (OPP_MOVE_OVERRIDE_2 && !this.isPlayer()) + this.moveset[1] = new PokemonMove(OPP_MOVE_OVERRIDE_2, Math.min(this.moveset[1].ppUsed, allMoves[OPP_MOVE_OVERRIDE_2].pp)); + return ret; } @@ -2474,9 +2479,10 @@ export class PlayerPokemon extends Pokemon { if (newEvolution.condition.predicate(this)) { const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, undefined, this.shiny, this.variant, this.ivs, this.nature); newPokemon.natureOverride = this.natureOverride; + newPokemon.passive = this.passive; + newPokemon.moveset = this.moveset.slice(); newPokemon.moveset = this.copyMoveset(); newPokemon.luck = this.luck; - newPokemon.fusionSpecies = this.fusionSpecies; newPokemon.fusionFormIndex = this.fusionFormIndex; newPokemon.fusionAbilityIndex = this.fusionAbilityIndex; diff --git a/src/overrides.ts b/src/overrides.ts index 732b1a5a4..4b9bcaa0b 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -15,9 +15,11 @@ export const WEATHER_OVERRIDE = WeatherType.NONE; export const ABILITY_OVERRIDE = Abilities.NONE; export const MOVE_OVERRIDE = Moves.NONE; +export const MOVE_OVERRIDE_2 = Moves.NONE; export const OPP_SPECIES_OVERRIDE = 0; export const OPP_ABILITY_OVERRIDE = Abilities.NONE; export const OPP_MOVE_OVERRIDE = Moves.NONE; +export const OPP_MOVE_OVERRIDE_2 = Moves.NONE; export const OPP_SHINY_OVERRIDE = false; export const OPP_VARIANT_OVERRIDE = 0;