From 0d7c335cd93e0263f53f3c798314b75194eb67f6 Mon Sep 17 00:00:00 2001 From: Jason Guan <114308729+34jasonguan@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:00:58 -0400 Subject: [PATCH] [Bug] Make Destiny Bond fail when used consecutively in accordance with Gen VII+ implementation (#3504) * make destiny bond fail on consecutive turns * Update move.ts to remove .length shorthand Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com> * change 'turnMove' variable name Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com> * update variable names Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com> * add comments * Replace tabs with spaces --------- Co-authored-by: schmidtc1 <62030095+schmidtc1@users.noreply.github.com> Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/data/move.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 40016b26ab7..c8043282b00 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3,7 +3,7 @@ import { BattleStat, getBattleStatName } from "./battle-stat"; import { EncoreTag, GulpMissileTag, HelpingHandTag, SemiInvulnerableTag, ShellTrapTag, StockpilingTag, TrappedTag, TypeBoostTag } from "./battler-tags"; import { getPokemonNameWithAffix } from "../messages"; import Pokemon, { AttackMoveResult, EnemyPokemon, HitResult, MoveResult, PlayerPokemon, PokemonMove, TurnMove } from "../field/pokemon"; -import { StatusEffect, getStatusEffectHealText, isNonVolatileStatusEffect, getNonVolatileStatusEffects} from "./status-effect"; +import { StatusEffect, getStatusEffectHealText, isNonVolatileStatusEffect, getNonVolatileStatusEffects } from "./status-effect"; import { getTypeResistances, Type } from "./type"; import { Constructor } from "#app/utils"; import * as Utils from "../utils"; @@ -6854,7 +6854,16 @@ export function initMoves() { .attr(ExposedMoveAttr, BattlerTagType.IGNORE_GHOST), new SelfStatusMove(Moves.DESTINY_BOND, Type.GHOST, -1, 5, -1, 0, 2) .ignoresProtect() - .attr(DestinyBondAttr), + .attr(DestinyBondAttr) + .condition((user, target, move) => { + // Retrieves user's previous move, returns empty array if no moves have been used + const lastTurnMove = user.getLastXMoves(1); + // Checks last move and allows destiny bond to be used if: + // - no previous moves have been made + // - the previous move used was not destiny bond + // - the previous move was unsuccessful + return lastTurnMove.length === 0 || lastTurnMove[0].move !== move.id || lastTurnMove[0].result !== MoveResult.SUCCESS; + }), new StatusMove(Moves.PERISH_SONG, Type.NORMAL, -1, 5, -1, 0, 2) .attr(FaintCountdownAttr) .ignoresProtect()