From b5206ff9d13bf225fed2467343db87aba0d591d0 Mon Sep 17 00:00:00 2001 From: takeyourt1me <144757710+takeyourt1me@users.noreply.github.com> Date: Fri, 3 May 2024 14:09:11 -0700 Subject: [PATCH] Final Version Working implementation of PreAttackChangeType class that has been applied to libero and protean --- src/data/ability.ts | 13 +++++-------- src/field/pokemon.ts | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 74d10925766..6b1e0f6df8c 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -860,14 +860,13 @@ export class PreAttackChangeType extends PreAttackAbAttr{ 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)){ + if (originalType.length > 1 || originalType[0] !== MoveType){ pokemon.summonData.types = [MoveType]; + pokemon.battleSummonData.abilityTriggeredThisSwitch = true; pokemon.updateInfo(); pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` tranformed\ninto the ${Utils.toReadableString(Type[MoveType])} type!`)); } @@ -3001,9 +3000,7 @@ 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!')) - //.unimplemented(), + .attr(PreAttackChangeType,(user,target,move) => move.name !== 'Struggle' && !user.isTerastallized() && user.battleSummonData.abilityTriggeredThisSwitch === false), new Ability(Abilities.FUR_COAT, 6) .attr(ReceivedMoveDamageMultiplierAbAttr, (target, user, move) => move.category === MoveCategory.PHYSICAL, 0.5) .ignorable(), @@ -3224,7 +3221,7 @@ export function initAbilities() { new Ability(Abilities.DAUNTLESS_SHIELD, 8) .attr(PostSummonStatChangeAbAttr, BattleStat.DEF, 1, true), new Ability(Abilities.LIBERO, 8) - .unimplemented(), + .attr(PreAttackChangeType,(user,target,move) => move.name !== 'Struggle' && !user.isTerastallized() && user.battleSummonData.abilityTriggeredThisSwitch === false), new Ability(Abilities.BALL_FETCH, 8) .unimplemented(), new Ability(Abilities.COTTON_DOWN, 8) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index df8e1389d45..9428f913af0 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1247,7 +1247,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,) + applyPreAttackAbAttrs(PreAttackChangeType,source,this,battlerMove,) const type = variableType.value as Type; const types = this.getTypes(true, true); @@ -3044,12 +3044,13 @@ export class PokemonSummonData { export class PokemonBattleData { public hitCount: integer = 0; public endured: boolean = false; - public berriesEaten: BerryType[] = []; + public berriesEaten: BerryType[] = []; } export class PokemonBattleSummonData { public turnCount: integer = 1; public moveHistory: TurnMove[] = []; + public abilityTriggeredThisSwitch: boolean = false; } export class PokemonTurnData {