diff --git a/Plugins/PkmnLib.Plugin.Gen7.Tests/Scripts/Moves/DestinyBondTests.cs b/Plugins/PkmnLib.Plugin.Gen7.Tests/Scripts/Moves/DestinyBondTests.cs index 58d7f41..95e566d 100644 --- a/Plugins/PkmnLib.Plugin.Gen7.Tests/Scripts/Moves/DestinyBondTests.cs +++ b/Plugins/PkmnLib.Plugin.Gen7.Tests/Scripts/Moves/DestinyBondTests.cs @@ -70,6 +70,45 @@ public class DestinyBondTests await Assert.That(userVolatile.Contains(ScriptUtils.ResolveName())).IsTrue(); } + /// + /// Bulbapedia (Generation VII): Destiny Bond "will always fail if it was successfully executed on the + /// previous turn." A user that still carries the from the previous use + /// fails the move. The hook runs before the effect is removed by the + /// user's move, so the lingering effect is what marks the consecutive use. + /// + [Test] + public async Task FailMove_UserStillDestinyBound_FailsMove() + { + // Arrange + var (script, move, _, userVolatile) = CreateTestSetup(); + userVolatile.Add(new DestinyBondEffect()); + var fail = false; + + // Act + script.FailMove(move, ref fail); + + // Assert + await Assert.That(fail).IsTrue(); + } + + /// + /// Bulbapedia (Generation VII): the move only fails "if it was successfully executed on the previous + /// turn." Without a lingering on the user, the move executes normally. + /// + [Test] + public async Task FailMove_UserNotDestinyBound_DoesNotFailMove() + { + // Arrange + var (script, move, _, _) = CreateTestSetup(); + var fail = false; + + // Act + script.FailMove(move, ref fail); + + // Assert + await Assert.That(fail).IsFalse(); + } + /// /// Bulbapedia: "if the user faints as the direct result of an attack, the attacking Pokémon also /// faints." When the Destiny Bound user faints from move damage, the attacker takes damage far in diff --git a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/DestinyBond.cs b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/DestinyBond.cs index 412a953..a07996f 100644 --- a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/DestinyBond.cs +++ b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/DestinyBond.cs @@ -3,11 +3,20 @@ using PkmnLib.Plugin.Gen7.Scripts.Pokemon; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "destiny_bond")] -public class DestinyBond : Script, IScriptOnSecondaryEffect +public class DestinyBond : Script, IScriptOnSecondaryEffect, IScriptFailMove { /// public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) { move.User.Volatile.Add(new DestinyBondEffect()); } + + public void FailMove(IExecutingMove move, ref bool fail) + { + if (move.User.Volatile.Contains()) + { + fail = true; + move.User.Volatile.Remove(); + } + } } \ No newline at end of file