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

@@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Battle_Bond_(Ability)">Bulbapedia - Battle Bond</see>
/// </summary>
[Script(ScriptCategory.Ability, "battle_bond")]
public class BattleBond : Script
public class BattleBond : Script, IScriptChangeNumberOfHits
{
/// <inheritdoc />
public override void OnOpponentFaints(IExecutingMove move, IPokemon target, byte hit)
@@ -28,7 +28,7 @@ public class BattleBond : Script
}
/// <inheritdoc />
public override void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
public void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
{
if (choice.ChosenMove.MoveData.Name == "water_shuriken" && choice.User.Form.Name == "ash")
{

View File

@@ -7,10 +7,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Gale_Wings_(Ability)">Bulbapedia - Gale Wings</see>
/// </summary>
[Script(ScriptCategory.Ability, "gale_wings")]
public class GaleWings : Script
public class GaleWings : Script, IScriptChangePriority
{
/// <inheritdoc />
public override void ChangePriority(IMoveChoice choice, ref sbyte priority)
public void ChangePriority(IMoveChoice choice, ref sbyte priority)
{
if (choice.User.CurrentHealth != choice.User.MaxHealth)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Lightning_Rod_(Ability)">Bulbapedia - Lightning Rod</see>
/// </summary>
[Script(ScriptCategory.Ability, "lightning_rod")]
public class LightningRod : Script
public class LightningRod : Script, IScriptChangeIncomingTargets
{
/// <inheritdoc />
public override void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
if (moveChoice.ChosenMove.MoveData.MoveType.Name == "electric" && targets.Count == 1)
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Magic_Bounce_(Ability)">Bulbapedia - Magic Bounce</see>
/// </summary>
[Script(ScriptCategory.Ability, "magic_bounce")]
public class MagicBounce : Script
public class MagicBounce : Script, IScriptChangeIncomingTargets
{
/// <inheritdoc />
public override void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
if (moveChoice.ChosenMove.MoveData.HasFlag("reflectable"))
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Parental_Bond_(Ability)">Bulbapedia - Parental Bond</see>
/// </summary>
[Script(ScriptCategory.Ability, "parental_bond")]
public class ParentalBond : Script
public class ParentalBond : Script, IScriptChangeNumberOfHits
{
/// <inheritdoc />
public override void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
public void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
{
if (numberOfHits == 1)
numberOfHits = 2;

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Prankster_(Ability)">Bulbapedia - Prankster</see>
/// </summary>
[Script(ScriptCategory.Ability, "prankster")]
public class Prankster : Script
public class Prankster : Script, IScriptChangePriority
{
/// <inheritdoc />
public override void ChangePriority(IMoveChoice choice, ref sbyte priority)
public void ChangePriority(IMoveChoice choice, ref sbyte priority)
{
if (choice.ChosenMove.MoveData.Category == MoveCategory.Status && priority != sbyte.MaxValue)
priority++;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Protean_(Ability)">Bulbapedia - Protean</see>
/// </summary>
[Script(ScriptCategory.Ability, "protean")]
public class Protean : Script
public class Protean : Script, IScriptOnBeforeMove
{
/// <inheritdoc />
public override void OnBeforeMove(IExecutingMove move)
public void OnBeforeMove(IExecutingMove move)
{
if (move.User.Types.Count == 1 && move.User.Types[0] == move.UseMove.MoveType)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Quick_Feet_(Ability)">Bulbapedia - Quick Feet</see>
/// </summary>
[Script(ScriptCategory.Ability, "quick_feet")]
public class QuickFeet : Script
public class QuickFeet : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
if (choice.User.StatusScript.IsEmpty)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Rush_(Ability)">Bulbapedia - Sand Rush</see>
/// </summary>
[Script(ScriptCategory.Ability, "sand_rush")]
public class SandRush : Script
public class SandRush : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
if (choice.User.BattleData?.Battle.WeatherName == ScriptUtils.ResolveName<Weather.Sandstorm>())
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Slush_Rush_(Ability)">Bulbapedia - Slush Rush</see>
/// </summary>
[Script(ScriptCategory.Ability, "slush_rush")]
public class SlushRush : Script
public class SlushRush : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
if (choice.User.BattleData?.Battle.WeatherName == ScriptUtils.ResolveName<Weather.Hail>())
{

View File

@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Rush_(Ability)">Bulbapedia - Sand Rush</see>
/// </summary>
[Script(ScriptCategory.Ability, "speed_modifier_in_weather")]
public class SpeedModifierInWeather : Script, IScriptOnInitialize
public class SpeedModifierInWeather : Script, IScriptOnInitialize, IScriptChangeSpeed
{
private StringKey _weather;
private float _modifier;
@@ -33,7 +33,7 @@ public class SpeedModifierInWeather : Script, IScriptOnInitialize
}
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
var battle = choice.User.BattleData?.Battle;
if (battle is null)

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Stall_(Ability)">Bulbapedia - Stall</see>
/// </summary>
[Script(ScriptCategory.Ability, "stall")]
public class Stall : Script
public class Stall : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
speed = 0;
}

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Stance_Change_(Ability)">Bulbapedia - Stance Change</see>
/// </summary>
[Script(ScriptCategory.Ability, "stance_change")]
public class StanceChange : Script
public class StanceChange : Script, IScriptOnBeforeMove
{
/// <inheritdoc />
public override void OnBeforeMove(IExecutingMove move)
public void OnBeforeMove(IExecutingMove move)
{
if (move.User.Species.Name != "aegislash")
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Storm_Drain_(Ability)">Bulbapedia - Storm Drain</see>
/// </summary>
[Script(ScriptCategory.Ability, "storm_drain")]
public class StormDrain : Script
public class StormDrain : Script, IScriptChangeIncomingTargets
{
/// <inheritdoc />
public override void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
if (moveChoice.ChosenMove.MoveData.MoveType.Name == "water" && targets.Count == 1)
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Surge_Surfer_(Ability)">Bulbapedia - Surge Surfer</see>
/// </summary>
[Script(ScriptCategory.Ability, "surge_surfer")]
public class SurgeSurfer : Script
public class SurgeSurfer : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
if (choice.User.BattleData?.Battle.TerrainName == ScriptUtils.ResolveName<Terrain.ElectricTerrain>())
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Swift_Swim_(Ability)">Bulbapedia - Swift Swim</see>
/// </summary>
[Script(ScriptCategory.Ability, "swift_swim")]
public class SwiftSwim : Script
public class SwiftSwim : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
if (choice.User.BattleData?.Battle.WeatherName == ScriptUtils.ResolveName<Weather.Rain>())
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Triage_(Ability)">Bulbapedia - Triage</see>
/// </summary>
[Script(ScriptCategory.Ability, "triage")]
public class Triage : Script
public class Triage : Script, IScriptChangePriority
{
/// <inheritdoc />
public override void ChangePriority(IMoveChoice choice, ref sbyte priority)
public void ChangePriority(IMoveChoice choice, ref sbyte priority)
{
if (!choice.ChosenMove.MoveData.HasFlag("heal"))
return;

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Truant_(Ability)">Bulbapedia - Truant</see>
/// </summary>
[Script(ScriptCategory.Ability, "truant")]
public class Truant : Script
public class Truant : Script, IScriptOnAfterMove
{
/// <inheritdoc />
public override void OnAfterMove(IExecutingMove move)
public void OnAfterMove(IExecutingMove move)
{
move.User.Volatile.Add(new TruantEffect(move.User));
}

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Unburden_(Ability)">Bulbapedia - Unburden</see>
/// </summary>
[Script(ScriptCategory.Ability, "unburden")]
public class Unburden : Script
public class Unburden : Script, IScriptChangeSpeed
{
/// <inheritdoc />
public override void ChangeSpeed(ITurnChoice choice, ref uint speed)
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
{
if (choice.User.HasItemBeenRemovedForBattle)
{