Refactor move selection prevention to use interface

This commit is contained in:
2025-06-28 10:36:43 +02:00
parent 04cf585f5a
commit 2319160b52
12 changed files with 59 additions and 27 deletions

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "belch")]
public class Belch : Script
public class Belch : Script, IScriptPreventMoveSelection
{
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
var battleData = choice.User.BattleData;
if (battleData == null)

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "celebrate")]
public class Celebrate : Script
public class Celebrate : Script, IScriptPreventMoveSelection
{
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
// This move is mostly useless, and it's not worth the effort to implement it.
// Prevent it from being selected.

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "last_resort")]
public class LastResort : Script
public class LastResort : Script, IScriptPreventMoveSelection
{
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
var battleData = choice.User.BattleData;
if (battleData == null)

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "disable")]
public class DisableEffect : Script
public class DisableEffect : Script, IScriptPreventMoveSelection
{
private int _turnsLeft = 4;
private readonly StringKey _move;
@@ -12,7 +12,7 @@ public class DisableEffect : Script
}
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.Name == _move)
prevent = true;

View File

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

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "imprison")]
public class ImprisonEffect : Script
public class ImprisonEffect : Script, IScriptPreventMoveSelection
{
private readonly IPokemon _user;
@@ -11,7 +11,7 @@ public class ImprisonEffect : Script
}
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (_user.Moves.WhereNotNull().Any(x => x.MoveData.Name == choice.ChosenMove.MoveData.Name))
prevent = true;

View File

@@ -3,12 +3,12 @@ using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "taunt")]
public class TauntEffect(int turns) : Script
public class TauntEffect(int turns) : Script, IScriptPreventMoveSelection
{
private int _turns = turns;
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.Category == MoveCategory.Status)
{

View File

@@ -1,12 +1,12 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "throat_chop")]
public class ThroatChopEffect : Script
public class ThroatChopEffect : Script, IScriptPreventMoveSelection
{
private int _turns = 3;
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.HasFlag("sound"))
prevent = true;

View File

@@ -1,12 +1,12 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "torment")]
public class TormentEffect(IMoveChoice? moveChoice) : Script
public class TormentEffect(IMoveChoice? moveChoice) : Script, IScriptPreventMoveSelection
{
private IMoveChoice? _moveChoice = moveChoice;
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (_moveChoice == null)
return;