Fixes for destiny bond

This commit is contained in:
2026-07-05 19:13:18 +02:00
parent 94ddf63861
commit db839ac214
2 changed files with 49 additions and 1 deletions

View File

@@ -70,6 +70,45 @@ public class DestinyBondTests
await Assert.That(userVolatile.Contains(ScriptUtils.ResolveName<DestinyBondEffect>())).IsTrue(); await Assert.That(userVolatile.Contains(ScriptUtils.ResolveName<DestinyBondEffect>())).IsTrue();
} }
/// <summary>
/// Bulbapedia (Generation VII): Destiny Bond "will always fail if it was successfully executed on the
/// previous turn." A user that still carries the <see cref="DestinyBondEffect"/> from the previous use
/// fails the move. The <see cref="IScriptFailMove"/> hook runs before the effect is removed by the
/// user's move, so the lingering effect is what marks the consecutive use.
/// </summary>
[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();
}
/// <summary>
/// Bulbapedia (Generation VII): the move only fails "if it was successfully executed on the previous
/// turn." Without a lingering <see cref="DestinyBondEffect"/> on the user, the move executes normally.
/// </summary>
[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();
}
/// <summary> /// <summary>
/// Bulbapedia: "if the user faints as the direct result of an attack, the attacking Pokémon also /// 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 /// faints." When the Destiny Bound user faints from move damage, the attacker takes damage far in

View File

@@ -3,11 +3,20 @@ using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves; namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "destiny_bond")] [Script(ScriptCategory.Move, "destiny_bond")]
public class DestinyBond : Script, IScriptOnSecondaryEffect public class DestinyBond : Script, IScriptOnSecondaryEffect, IScriptFailMove
{ {
/// <inheritdoc /> /// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{ {
move.User.Volatile.Add(new DestinyBondEffect()); move.User.Volatile.Add(new DestinyBondEffect());
} }
public void FailMove(IExecutingMove move, ref bool fail)
{
if (move.User.Volatile.Contains<DestinyBondEffect>())
{
fail = true;
move.User.Volatile.Remove<DestinyBondEffect>();
}
}
} }