From 6a87c1b4ccb317e1bf928c758631218db5931ff9 Mon Sep 17 00:00:00 2001 From: LaukkaE <73663099+LaukkaE@users.noreply.github.com> Date: Mon, 1 Apr 2024 20:26:35 +0300 Subject: [PATCH] Implement freezedry (#22) * implement freezedry * remove console log --- src/data/move.ts | 22 ++++++++++++++++++++-- src/field/pokemon.ts | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index a3b4db75c..d22f5a525 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1768,6 +1768,23 @@ export class BlizzardAccuracyAttr extends VariableAccuracyAttr { } } +export class VariableMoveTypeMultiplierAttr extends MoveAttr { + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + return false; + } +} + +export class FreezeDryMultiplierAttr extends VariableMoveTypeMultiplierAttr { + apply(user:Pokemon,target:Pokemon, move:Move, args: any[]) : boolean { + const multiplier = args[0] as Utils.NumberHolder; + if (target.isOfType(Type.WATER)){ + //Increased twice because initial reduction against water + multiplier.value *=4; + } + return false; + } +} + export class OneHitKOAccuracyAttr extends MoveAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const accuracy = args[0] as Utils.NumberHolder; @@ -4060,8 +4077,9 @@ export function initMoves() { new AttackMove(Moves.PETAL_BLIZZARD, "Petal Blizzard", Type.GRASS, MoveCategory.PHYSICAL, 90, 100, 15, "The user stirs up a violent petal blizzard and attacks everything around it.", -1, 0, 6) .windMove() .target(MoveTarget.ALL_NEAR_OTHERS), - new AttackMove(Moves.FREEZE_DRY, "Freeze-Dry (P)", Type.ICE, MoveCategory.SPECIAL, 70, 100, 20, "The user rapidly cools the target. This may also leave the target frozen. This move is super effective on Water types.", 10, 0, 6) - .attr(StatusEffectAttr, StatusEffect.FREEZE), + new AttackMove(Moves.FREEZE_DRY, "Freeze-Dry", Type.ICE, MoveCategory.SPECIAL, 70, 100, 20, "The user rapidly cools the target. This may also leave the target frozen. This move is super effective on Water types.", 10, 0, 6) + .attr(StatusEffectAttr, StatusEffect.FREEZE) + .attr(FreezeDryMultiplierAttr), new AttackMove(Moves.DISARMING_VOICE, "Disarming Voice", Type.FAIRY, MoveCategory.SPECIAL, 40, -1, 15, "Letting out a charming cry, the user does emotional damage to opposing Pokémon. This attack never misses.", -1, 0, 6) .soundBased() .target(MoveTarget.ALL_NEAR_ENEMIES), diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 3240fc32f..d5983a3b5 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2,7 +2,7 @@ import Phaser from 'phaser'; import BattleScene, { AnySound } from '../battle-scene'; import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from '../ui/battle-info'; import { Moves } from "../data/enums/moves"; -import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, VariablePowerAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, MultiHitAttr, StatusMoveTypeImmunityAttr, MoveTarget, VariableDefAttr, AttackMove, ModifiedDamageAttr } from "../data/move"; +import Move, { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtkAttr, VariablePowerAttr, allMoves, MoveCategory, TypelessAttr, CritOnlyAttr, getMoveTargets, OneHitKOAttr, MultiHitAttr, StatusMoveTypeImmunityAttr, MoveTarget, VariableDefAttr, AttackMove, ModifiedDamageAttr, VariableMoveTypeMultiplierAttr } from "../data/move"; import { default as PokemonSpecies, PokemonSpeciesForm, SpeciesFormKey, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from '../data/pokemon-species'; import * as Utils from '../utils'; import { Type, TypeDamageMultiplier, getTypeDamageMultiplier, getTypeRgb } from '../data/type'; @@ -1042,6 +1042,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const typeMultiplier = new Utils.NumberHolder(!typeless && (moveCategory !== MoveCategory.STATUS || move.getAttrs(StatusMoveTypeImmunityAttr).find(attr => (attr as StatusMoveTypeImmunityAttr).immuneType === move.type)) ? getTypeDamageMultiplier(move.type, types[0]) * (types.length > 1 ? getTypeDamageMultiplier(move.type, types[1]) : 1) : 1); + applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier); if (typeless) typeMultiplier.value = 1; if (this.getTypes(true, true).find(t => move.isTypeImmune(t)))