From 44cd2ee03ee782d15c70898ccc425dbe41bc001b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 2 Nov 2024 12:59:55 +0100 Subject: [PATCH] Adds a bunch more move scripts --- PkmnLib.Dynamic/Events/DialogEvent.cs | 17 ++++ PkmnLib.Dynamic/Models/Pokemon.cs | 21 ++++- .../ScriptHandling/Registry/ScriptUtils.cs | 2 + PkmnLib.Dynamic/ScriptHandling/Script.cs | 7 ++ PkmnLib.Dynamic/ScriptHandling/ScriptSet.cs | 3 + .../Scripts/Moves/AuroraVeil.cs | 52 ++++++++++++ .../Scripts/Moves/Autotomize.cs | 41 +++++++++ .../Scripts/Moves/ChangeAllTargetStats.cs | 40 +++++++++ .../Scripts/Moves/ChangeTargetStats.cs | 83 +++++++++++++++++++ .../Scripts/Moves/CurePartyStatus.cs | 27 ++++++ .../Moves/DoublePowerIfTargetDamagedInTurn.cs | 39 +++++++++ .../Scripts/Moves/Struggle.cs | 36 ++++++++ .../Scripts/Side/AuroraVeilEffect.cs | 71 ++++++++++++++++ .../DoublePowerIfTargetDamagedInTurnData.cs | 24 ++++++ .../Scripts/Side/LightScreenEffect.cs | 10 +++ .../Scripts/Side/ReflectEffect.cs | 10 +++ .../Scripts/Weather/Hail.cs | 10 +++ 17 files changed, 492 insertions(+), 1 deletion(-) create mode 100644 PkmnLib.Dynamic/Events/DialogEvent.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/AuroraVeil.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Autotomize.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/ChangeAllTargetStats.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/ChangeTargetStats.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/CurePartyStatus.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/DoublePowerIfTargetDamagedInTurn.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Struggle.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/AuroraVeilEffect.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/DoublePowerIfTargetDamagedInTurnData.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/LightScreenEffect.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/ReflectEffect.cs create mode 100644 Plugins/PkmnLib.Plugin.Gen7/Scripts/Weather/Hail.cs diff --git a/PkmnLib.Dynamic/Events/DialogEvent.cs b/PkmnLib.Dynamic/Events/DialogEvent.cs new file mode 100644 index 0000000..a89dbda --- /dev/null +++ b/PkmnLib.Dynamic/Events/DialogEvent.cs @@ -0,0 +1,17 @@ +namespace PkmnLib.Dynamic.Events; + +public class DialogEvent : IEventData +{ + /// + public EventBatchId BatchId { get; init; } = new(); + + public DialogEvent(string message, Dictionary? parameters = null) + { + Message = message; + Parameters = parameters; + } + + public string Message { get; set; } + + public Dictionary? Parameters { get; set; } +} \ No newline at end of file diff --git a/PkmnLib.Dynamic/Models/Pokemon.cs b/PkmnLib.Dynamic/Models/Pokemon.cs index 149361c..2111bb7 100644 --- a/PkmnLib.Dynamic/Models/Pokemon.cs +++ b/PkmnLib.Dynamic/Models/Pokemon.cs @@ -93,7 +93,14 @@ public interface IPokemon : IScriptSource float WeightInKg { get; set; } /// - /// The height of the Pokemon in meters. + /// Sets the weight of the Pokémon in kilograms. Returns whether the weight was changed. + /// + /// The new weight in kilograms + /// + public bool ChangeWeightInKgBy(float weightInKg); + + /// + /// The height of the Pokémon in meters. /// float HeightInMeters { get; set; } @@ -543,6 +550,18 @@ public class PokemonImpl : ScriptSource, IPokemon /// public float WeightInKg { get; set; } + /// + public bool ChangeWeightInKgBy(float weightInKg) + { + if (WeightInKg <= 0.1f) + return false; + var newWeight = WeightInKg + weightInKg; + if (newWeight <= 0.1f) + newWeight = 0.1f; + WeightInKg = newWeight; + return true; + } + /// public float HeightInMeters { get; set; } diff --git a/PkmnLib.Dynamic/ScriptHandling/Registry/ScriptUtils.cs b/PkmnLib.Dynamic/ScriptHandling/Registry/ScriptUtils.cs index 10d6831..5673096 100644 --- a/PkmnLib.Dynamic/ScriptHandling/Registry/ScriptUtils.cs +++ b/PkmnLib.Dynamic/ScriptHandling/Registry/ScriptUtils.cs @@ -15,6 +15,8 @@ public static class ScriptUtils /// public static StringKey ResolveName(this Script script) => ResolveName(script.GetType()); + public static StringKey ResolveName() where T : Script => ResolveName(typeof(T)); + /// /// Resolve name from the of the given type. /// diff --git a/PkmnLib.Dynamic/ScriptHandling/Script.cs b/PkmnLib.Dynamic/ScriptHandling/Script.cs index 66aa2f6..b13cef2 100644 --- a/PkmnLib.Dynamic/ScriptHandling/Script.cs +++ b/PkmnLib.Dynamic/ScriptHandling/Script.cs @@ -14,8 +14,15 @@ namespace PkmnLib.Dynamic.ScriptHandling; /// public abstract class Script { + internal event Action