diff --git a/src/data/ability.ts b/src/data/ability.ts index e0bd24b4e62..4fbf08a7cb1 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1773,7 +1773,7 @@ export class PostTerrainChangeAddBattlerTagAttr extends PostTerrainChangeAbAttr } applyPostTerrainChange(pokemon: Pokemon, passive: boolean, terrain: TerrainType, args: any[]): boolean { - if (!this.terrainTypes.find(t => terrain === terrain)) + if (!this.terrainTypes.find(t => t === terrain)) return false; return pokemon.addTag(this.tagType, this.turnCount); @@ -1807,6 +1807,23 @@ export class PostTurnResetStatusAbAttr extends PostTurnAbAttr { } } +export class MoodyAbAttr extends PostTurnAbAttr { + constructor() { + super(true); + } + + 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)); + return true; + } +} + export class PostTurnStatChangeAbAttr extends PostTurnAbAttr { private stats: BattleStat[]; private levels: integer; @@ -2771,8 +2788,7 @@ export function initAbilities() { new Ability(Abilities.TELEPATHY, "Telepathy (N)", "Anticipates an ally's attack and dodges it.", 5) .ignorable(), new Ability(Abilities.MOODY, "Moody", "Raises one stat sharply and lowers another every turn.", 5) - .attr(PostTurnStatChangeAbAttr, BattleStat.RAND, 2) - .attr(PostTurnStatChangeAbAttr, BattleStat.RAND, -1), + .attr(MoodyAbAttr), new Ability(Abilities.OVERCOAT, "Overcoat", "Protects the Pokémon from things like sand, hail, and powder.", 5) .attr(BlockWeatherDamageAttr) .attr(MoveImmunityAbAttr, (pokemon, attacker, move) => pokemon !== attacker && move.getMove().hasFlag(MoveFlags.POWDER_MOVE))