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