From ea459826d0d55d72916269d2d372fb092fc0cb34 Mon Sep 17 00:00:00 2001 From: notpatchmaybe <104580041+notpatchmaybe@users.noreply.github.com> Date: Sat, 11 May 2024 15:42:57 +0100 Subject: [PATCH] Heart Swap implementation. (#712) * Heart Swap implementation. Simply switches the values in 3 arrays. * Fixed missing space * Removed some lines. Removed a for loop. * Removed an unneccesary line * TSDoc commentation added * Changed message method to be more descriptive * Adjusted message line to be consistent with Pokemon Showdown * Adjusted priorBoostArray to priorBoost integer Only one values is relevant at a time, so the array was pointless, woops. --- src/data/move.ts | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/data/move.ts b/src/data/move.ts index cada55e64..f3b1c4dcc 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1775,6 +1775,37 @@ export class ResetStatsAttr extends MoveEffectAttr { } } +/** + * Attribute used for moves which swap the user and the target's stat changes. + */ +export class SwapStatsAttr extends MoveEffectAttr +{ + /** + * Swaps the user and the target's stat changes. + * @param user Pokemon that used the move + * @param target The target of the move + * @param move Move with this attribute + * @param args N/A + * @returns true if the function succeeds + */ + apply(user: Pokemon, target: Pokemon, move: Move, args: any []): boolean + { + if (!super.apply(user, target, move, args)) + return false; //Exits if the move can't apply + let priorBoost : integer; //For storing a stat boost + for (let s = 0; s < target.summonData.battleStats.length; s++) + { + priorBoost = user.summonData.battleStats[s]; //Store user stat boost + user.summonData.battleStats[s] = target.summonData.battleStats[s]; //Applies target boost to self + target.summonData.battleStats[s] = priorBoost; //Applies stored boost to target + } + target.updateInfo(); + user.updateInfo(); + target.scene.queueMessage(getPokemonMessage(user, ' switched stat changes with the target!')); + return true; + } +} + export class HpSplitAttr extends MoveEffectAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise { return new Promise(resolve => { @@ -5181,7 +5212,7 @@ export function initMoves() { .attr(AddArenaTrapTagAttr, ArenaTagType.TOXIC_SPIKES) .target(MoveTarget.ENEMY_SIDE), new StatusMove(Moves.HEART_SWAP, Type.PSYCHIC, -1, 10, -1, 0, 4) - .unimplemented(), + .attr(SwapStatsAttr), new SelfStatusMove(Moves.AQUA_RING, Type.WATER, -1, 20, -1, 0, 4) .attr(AddBattlerTagAttr, BattlerTagType.AQUA_RING, true, true), new SelfStatusMove(Moves.MAGNET_RISE, Type.ELECTRIC, -1, 10, -1, 0, 4)