Refactor move classes to implement respective interfaces for better structure
All checks were successful
Build / Build (push) Successful in 52s

This commit is contained in:
2025-06-28 12:02:24 +02:00
parent 2319160b52
commit b7bdf2b744
115 changed files with 407 additions and 348 deletions

View File

@@ -2,7 +2,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public abstract class BaseChargeEffect : Script
public abstract class BaseChargeEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
private readonly StringKey _moveName;
@@ -14,7 +14,7 @@ public abstract class BaseChargeEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "bide")]
public class BideEffect : Script
public class BideEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon? _owner;
public byte Turns;
@@ -34,7 +34,7 @@ public class BideEffect : Script
private ITurnChoice? _choice;
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
if (_owner == null)
return;

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_bounce")]
public class ChargeBounceEffect : Script
public class ChargeBounceEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class ChargeBounceEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bounce", opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_fly")]
public class ChargeFlyEffect : Script
public class ChargeFlyEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class ChargeFlyEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "fly", opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_move_effect")]
public class ChargeMoveEffect : Script
public class ChargeMoveEffect : Script, IScriptForceTurnSelection
{
public readonly StringKey MoveName;
private readonly IPokemon _user;
@@ -19,7 +19,7 @@ public class ChargeMoveEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = TurnChoiceHelper.CreateMoveChoice(_user, MoveName, _targetSide, _targetPosition);
}

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_sky_drop")]
public class ChargeSkyDropEffect : Script
public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class ChargeSkyDropEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "sky_drop", opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "confusion")]
public class Confusion : Script
public class Confusion : Script, IScriptStopBeforeMove
{
private int _turnsConfused;
@@ -19,7 +19,7 @@ public class Confusion : Script
}
/// <inheritdoc />
public override void StopBeforeMove(IExecutingMove move, ref bool stop)
public void StopBeforeMove(IExecutingMove move, ref bool stop)
{
_turnsConfused--;
move.Battle.EventHook.Invoke(new DialogEvent("pokemon_is_confused", new Dictionary<string, object>

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "destiny_bond")]
public class DestinyBondEffect : Script
public class DestinyBondEffect : Script, IScriptOnBeforeMove
{
/// <inheritdoc />
public override void OnFaint(IPokemon pokemon, DamageSource source)
@@ -15,7 +15,7 @@ public class DestinyBondEffect : Script
}
/// <inheritdoc />
public override void OnBeforeMove(IExecutingMove move)
public void OnBeforeMove(IExecutingMove move)
{
RemoveSelf();
}

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "dig")]
public class DigEffect : Script
public class DigEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class DigEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "dig", opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "dive")]
public class DiveEffect : Script
public class DiveEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class DiveEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "dive", opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "encore")]
public class EncoreEffect : Script
public class EncoreEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
private readonly StringKey _move;
@@ -17,7 +17,7 @@ public class EncoreEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, opposingSideIndex, position);

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "flinch_effect")]
public class FlinchEffect : Script
public class FlinchEffect : Script, IScriptPreventMove
{
/// <inheritdoc />
public override void PreventMove(IExecutingMove move, ref bool prevent)
public void PreventMove(IExecutingMove move, ref bool prevent)
{
prevent = true;
var args = new CustomTriggers.OnFlinchArgs(move);

View File

@@ -1,12 +1,12 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "fury_cutter")]
public class FuryCutterEffect : Script
public class FuryCutterEffect : Script, IScriptOnBeforeMove
{
public int TurnCount { get; set; }
/// <inheritdoc />
public override void OnBeforeMove(IExecutingMove move)
public void OnBeforeMove(IExecutingMove move)
{
if (move.UseMove.Name != "fury_cutter")
RemoveSelf();

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "heal_block")]
public class HealBlockEffect : Script, IScriptPreventMoveSelection
public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreventMove
{
private int _duration;
@@ -26,7 +26,7 @@ public class HealBlockEffect : Script, IScriptPreventMoveSelection
}
/// <inheritdoc />
public override void PreventMove(IExecutingMove move, ref bool prevent)
public void PreventMove(IExecutingMove move, ref bool prevent)
{
if (move.ChosenMove.MoveData.HasFlag("heal"))
prevent = true;

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "ice_ball")]
public class IceBallEffect : Script
public class IceBallEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
private readonly StringKey _moveName;
@@ -17,7 +17,7 @@ public class IceBallEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);

View File

@@ -10,10 +10,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
/// gender that has Cute Charm as its Ability, and is caused to a Pokémon that infatuates a Pokémon holding a Destiny Knot.
/// </remarks>
[Script(ScriptCategory.Pokemon, "infatuated")]
public class Infatuated : Script
public class Infatuated : Script, IScriptPreventMove
{
/// <inheritdoc />
public override void PreventMove(IExecutingMove move, ref bool prevent)
public void PreventMove(IExecutingMove move, ref bool prevent)
{
if (move.User.BattleData?.Battle.Random.GetBool() == true)
prevent = true;

View File

@@ -2,7 +2,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public abstract class OutrageLikeEffect : Script
public abstract class OutrageLikeEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
private int _turns;
@@ -20,7 +20,7 @@ public abstract class OutrageLikeEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, _targetSide, _targetPosition);
}

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "phantom_force")]
public class PhantomForceCharge : Script
public class PhantomForceCharge : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class PhantomForceCharge : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "phantom_force", opposingSideIndex, position);

View File

@@ -5,13 +5,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
/// or protect-like moves.
/// </summary>
[Script(ScriptCategory.Pokemon, "protection_failure")]
public class ProtectionFailureScript : Script
public class ProtectionFailureScript : Script, IScriptOnBeforeTurnStart
{
public int ProtectTurns { get; set; }
public bool UsedProtect { get; set; }
/// <inheritdoc />
public override void OnBeforeTurnStart(ITurnChoice choice)
public void OnBeforeTurnStart(ITurnChoice choice)
{
UsedProtect = false;
}

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "requires_recharge")]
public class RequiresRechargeEffect : Script
public class RequiresRechargeEffect : Script, IScriptForceTurnSelection, IScriptOnBeforeTurnStart
{
private readonly IPokemon _owner;
@@ -11,13 +11,13 @@ public class RequiresRechargeEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = new PassChoice(_owner);
}
/// <inheritdoc />
public override void OnBeforeTurnStart(ITurnChoice choice)
public void OnBeforeTurnStart(ITurnChoice choice)
{
RemoveSelf();
_owner.BattleData?.Battle.EventHook.Invoke(new DialogEvent("pokemon_must_recharge",

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "shadow_force")]
public class ShadowForceCharge : Script
public class ShadowForceCharge : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class ShadowForceCharge : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "shadow_force", opposingSideIndex, position);

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "skull_bash")]
public class SkullBashEffect : Script
public class SkullBashEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class SkullBashEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "skull_bash", sideIndex, position);
}

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "sky_attack")]
public class SkyAttackEffect : Script
public class SkyAttackEffect : Script, IScriptForceTurnSelection
{
private readonly IPokemon _owner;
@@ -13,7 +13,7 @@ public class SkyAttackEffect : Script
}
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "sky_attack", sideIndex, position);
}

View File

@@ -1,12 +1,12 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "slow_start")]
public class SlowStartEffect : Script
public class SlowStartEffect : Script, IScriptChangeSpeed
{
private int _turnsRemaining = 5;
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
speed /= 2;
}

View File

@@ -3,7 +3,7 @@ using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "taunt")]
public class TauntEffect(int turns) : Script, IScriptPreventMoveSelection
public class TauntEffect(int turns) : Script, IScriptPreventMoveSelection, IScriptFailMove
{
private int _turns = turns;
@@ -17,7 +17,7 @@ public class TauntEffect(int turns) : Script, IScriptPreventMoveSelection
}
/// <inheritdoc />
public override void FailMove(IExecutingMove move, ref bool fail)
public void FailMove(IExecutingMove move, ref bool fail)
{
if (move.ChosenMove.MoveData.Category == MoveCategory.Status)
{

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "throat_chop")]
public class ThroatChopEffect : Script, IScriptPreventMoveSelection
public class ThroatChopEffect : Script, IScriptPreventMoveSelection, IScriptFailMove
{
private int _turns = 3;
@@ -13,7 +13,7 @@ public class ThroatChopEffect : Script, IScriptPreventMoveSelection
}
/// <inheritdoc />
public override void FailMove(IExecutingMove move, ref bool fail)
public void FailMove(IExecutingMove move, ref bool fail)
{
if (move.UseMove.HasFlag("sound"))
fail = true;

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "torment")]
public class TormentEffect(IMoveChoice? moveChoice) : Script, IScriptPreventMoveSelection
public class TormentEffect(IMoveChoice? moveChoice) : Script, IScriptPreventMoveSelection, IScriptOnBeforeTurnStart
{
private IMoveChoice? _moveChoice = moveChoice;
@@ -17,7 +17,7 @@ public class TormentEffect(IMoveChoice? moveChoice) : Script, IScriptPreventMove
}
/// <inheritdoc />
public override void OnBeforeTurnStart(ITurnChoice choice)
public void OnBeforeTurnStart(ITurnChoice choice)
{
if (choice is IMoveChoice moveChoice)
_moveChoice = moveChoice;

View File

@@ -1,9 +1,9 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public class TruantEffect(IPokemon owner) : Script
public class TruantEffect(IPokemon owner) : Script, IScriptForceTurnSelection
{
/// <inheritdoc />
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = new PassChoice(owner);
}