From a78186aa8c21dd5899771088fa3eed4b19b97cbb Mon Sep 17 00:00:00 2001 From: takeyourt1me <144757710+takeyourt1me@users.noreply.github.com> Date: Fri, 3 May 2024 00:42:58 -0700 Subject: [PATCH] Changing works, need to make 1 time use Now applies type change correctly, but need to find right condition to make it only apply once per switch. --- src/data/ability.ts | 40 ++++++++++++++++------------------------ src/field/pokemon.ts | 3 ++- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index f1a76ff8b2c..ba114495f45 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -841,20 +841,27 @@ export class VariableMovePowerAbAttr extends PreAttackAbAttr { } export class PreAttackChangeType extends PreAttackAbAttr{ - applyPreAttack(pokemon:Pokemon,passive:boolean,defender:Pokemon,move:PokemonMove): boolean { - const MoveType = move.getMove().type; - const originalType = pokemon.getTypes(); - + private condition: PokemonAttackCondition; + constructor (condition:PokemonAttackCondition){ + super(true); + this.condition = condition; + } + applyPreAttack(pokemon:Pokemon,passive:boolean,defender:Pokemon,move:PokemonMove): boolean{ + console.log("Made it here within the function!!") + //console.log(pokemon.battleData.hitCount) + console.log(this.condition(pokemon,defender,move.getMove())) + const MoveType = move.getMove().type; + const originalType = pokemon.getTypes(); + if (this.condition(pokemon,defender,move.getMove())){ if (originalType.length > 1 || !pokemon.isOfType(MoveType)){ pokemon.summonData.types = [MoveType]; pokemon.updateInfo(); pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` tranformed\ninto the ${Utils.toReadableString(Type[MoveType])} type!`)); - return true; } - return false; } - } - + return false; + } + } export class VariableMoveTypeAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { //const power = args[0] as Utils.IntegerHolder; @@ -1139,21 +1146,6 @@ export class PostDefendStealHeldItemAbAttr extends PostDefendAbAttr { } } -export class PostAttackChangeType extends PostAttackAbAttr{ - applyPostAttack(pokemon:Pokemon,passive:boolean,defender:Pokemon,move:PokemonMove): boolean { - //if (this.condition(pokemon,defender,move.getMove())){ - const MoveType = move.getMove().type; - const originalType = pokemon.getTypes(); - - if (originalType.length > 1 || !pokemon.isOfType(MoveType)){ - pokemon.summonData.types = [MoveType]; - pokemon.updateInfo(); - pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` tranformed\ninto the ${Utils.toReadableString(Type[MoveType])} type!`)); - return true; - } - return false; - } - } export class PostVictoryAbAttr extends AbAttr { applyPostVictory(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise { return false; @@ -2996,8 +2988,8 @@ export function initAbilities() { new Ability(Abilities.CHEEK_POUCH, 6) .unimplemented(), new Ability(Abilities.PROTEAN, 6) + .attr(PreAttackChangeType,(user,target,move) => move.name !== 'Struggle' && !user.isTerastallized()), //.attr(PostSummonMessageAbAttr,(pokemon: Pokemon) => getPokemonMessage(pokemon,' Testing out the text!')) - .attr(PreAttackChangeType), //.unimplemented(), new Ability(Abilities.FUR_COAT, 6) .attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.category === MoveCategory.PHYSICAL, 0.5) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 9a7bfb48621..c9f3d3635ac 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -27,7 +27,7 @@ import { TempBattleStat } from '../data/temp-battle-stat'; import { ArenaTagSide, WeakenMoveScreenTag, WeakenMoveTypeTag } from '../data/arena-tag'; import { ArenaTagType } from "../data/enums/arena-tag-type"; import { Biome } from "../data/enums/biome"; -import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr } from '../data/ability'; +import { Ability, AbAttr, BattleStatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, FieldVariableMovePowerAbAttr, IgnoreOpponentStatChangesAbAttr, MoveImmunityAbAttr, MoveTypeChangeAttr, NonSuperEffectiveImmunityAbAttr, PreApplyBattlerTagAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, ReduceStatusEffectDurationAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, VariableMoveTypeAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyBattleStatMultiplierAbAttrs, applyPostDefendAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, PreAttackChangeType } from '../data/ability'; import { Abilities } from "#app/data/enums/abilities"; import PokemonData from '../system/pokemon-data'; import Battle, { BattlerIndex } from '../battle'; @@ -1230,6 +1230,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // 2nd argument is for MoveTypeChangePowerMultiplierAbAttr applyAbAttrs(VariableMoveTypeAbAttr, source, null, variableType, typeChangeMovePowerMultiplier); applyPreAttackAbAttrs(MoveTypeChangeAttr, source, this, battlerMove, variableType, typeChangeMovePowerMultiplier); + applyPreAttackAbAttrs(PreAttackChangeType,source,null,battlerMove,) const type = variableType.value as Type; const types = this.getTypes(true, true);