More unit tests, more fixes

This commit is contained in:
2026-07-05 19:02:00 +02:00
parent 6a82c20cf2
commit 94ddf63861
16 changed files with 1994 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ public class Defog : Script, IScriptOnSecondaryEffect
{
[PublicAPI] public static HashSet<StringKey> DefoggedEffects =
[
ScriptUtils.ResolveName<AuroraVeilEffect>(),
ScriptUtils.ResolveName<MistEffect>(),
ScriptUtils.ResolveName<LightScreenEffect>(),
ScriptUtils.ResolveName<ReflectEffect>(),
@@ -24,10 +25,14 @@ public class Defog : Script, IScriptOnSecondaryEffect
if (target.BattleData == null)
return;
var targetSide = target.BattleData.Battle.Sides[target.BattleData.SideIndex];
foreach (var effect in DefoggedEffects)
target.ChangeStatBoost(Statistic.Evasion, -1, false, false);
foreach (var sides in target.BattleData.Battle.Sides)
{
targetSide.VolatileScripts.Remove(effect);
foreach (var effect in DefoggedEffects)
{
sides.VolatileScripts.Remove(effect);
}
}
}
}

View File

@@ -11,12 +11,24 @@ public class Disable : Script, IScriptOnSecondaryEffect
var battleData = move.User.BattleData;
if (battleData == null)
return;
if (target.Volatile.Contains<DisableEffect>())
{
move.GetHitData(target, hit).Fail();
return;
}
var lastMove = target.BattleData?.LastMoveChoice;
if (lastMove == null)
{
move.GetHitData(target, hit).Fail();
return;
}
// If the last move was struggle, the move fails and no disable is applied.
if (target.Library.MiscLibrary.IsReplacementChoice(lastMove))
{
move.GetHitData(target, hit).Fail();
return;
}
var lastMoveName = lastMove.ChosenMove.MoveData.Name;
target.Volatile.Add(new DisableEffect(lastMoveName));
}

View File

@@ -3,10 +3,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "dream_eater")]
public class DreamEater : Script, IScriptOnSecondaryEffect, IScriptBlockOutgoingHit
{
private static readonly StringKey AsleepStatus = new("asleep");
private static readonly StringKey ComatoseAbility = new("comatose");
/// <inheritdoc />
public void BlockOutgoingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (!target.HasStatus("asleep"))
if (!target.HasStatus(AsleepStatus) && target.ActiveAbility?.Name != ComatoseAbility)
block = true;
}
@@ -23,6 +26,8 @@ public class DreamEater : Script, IScriptOnSecondaryEffect, IScriptBlockOutgoing
target.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
var invert = args.Invert;
healed = args.Healed;
if (healed == 0)
healed = 1;
if (invert)
{

View File

@@ -30,7 +30,7 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderground))
if (move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderground))
damage *= 2;
}

View File

@@ -30,7 +30,7 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderwater))
if (move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderwater))
damage *= 2;
}