Fixes for destiny bond
This commit is contained in:
@@ -70,6 +70,45 @@ public class DestinyBondTests
|
||||
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>
|
||||
/// 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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<DestinyBondEffect>())
|
||||
{
|
||||
fail = true;
|
||||
move.User.Volatile.Remove<DestinyBondEffect>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user