diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/AbilityDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/AbilityDataLoader.cs index 3a72510..94a24df 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/AbilityDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/AbilityDataLoader.cs @@ -8,6 +8,9 @@ using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads ability data from a JSON file. +/// public static class AbilityDataLoader { private static Dictionary LoadAbilitiesData(Stream stream) @@ -26,6 +29,9 @@ public static class AbilityDataLoader return objects; } + /// + /// Loads the ability library from a JSON file. + /// public static AbilityLibrary LoadAbilities(Stream stream, Action>? action = null) { diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/GrowthRateDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/GrowthRateDataLoader.cs index 014940a..5cc0992 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/GrowthRateDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/GrowthRateDataLoader.cs @@ -4,8 +4,14 @@ using PkmnLib.Static.Libraries; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads growth rate data from a JSON file. +/// public static class GrowthRateDataLoader { + /// + /// Loads the growth rate library from a JSON file. + /// public static GrowthRateLibrary LoadGrowthRates(Stream stream, Action>? action = null) { var objects = JsonSerializer.Deserialize>(stream, JsonOptions.DefaultOptions)!; diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/ItemDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/ItemDataLoader.cs index b86a580..4a86f65 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/ItemDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/ItemDataLoader.cs @@ -9,8 +9,14 @@ using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads item data from a JSON file. +/// public static class ItemDataLoader { + /// + /// Loads the item library from a JSON file. + /// public static ItemLibrary LoadItems(Stream stream, Action>? onAfterLoad = null) { var library = new ItemLibrary(); @@ -24,10 +30,16 @@ public static class ItemDataLoader return library; } + /// + /// Factory delegate for creating items. + /// public delegate IItem ItemFactoryDelegate(SerializedItem serialized, StringKey name, ItemCategory type, BattleItemCategory battleType, int price, ImmutableHashSet flags, ISecondaryEffect? effect, ISecondaryEffect? battleTriggerEffect, Dictionary additionalData); + /// + /// The item constructor. This is used to create items from the JSON data. + /// [PublicAPI] public static ItemFactoryDelegate ItemConstructor { get; set; } = (_, name, type, battleType, price, flags, effect, battleTriggerEffect, additionalData) => new ItemImpl(name, diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs index 4195a40..a090166 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedAbility.cs @@ -1,10 +1,22 @@ using System.Text.Json.Nodes; +// ReSharper disable CollectionNeverUpdated.Global + namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models; +/// +/// Represents a serialized ability. +/// public class SerializedAbility { + /// public string? Effect { get; set; } + + /// public Dictionary Parameters { get; set; } = new(); + + /// + /// A collection of arbitrary flags that can be used to mark the ability with specific properties. + /// public string[] Flags { get; set; } = []; } \ No newline at end of file diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedItem.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedItem.cs index 09c3a6f..f5c4e68 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedItem.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedItem.cs @@ -4,17 +4,38 @@ using System.Text.Json.Serialization; namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models; +/// +/// Represents a serialized item. +/// public class SerializedItem { + /// public string Name { get; set; } = null!; + + /// public string ItemType { get; set; } = null!; + + /// public string BattleType { get; set; } = null!; + + /// public string[] Flags { get; set; } = null!; + + /// public int Price { get; set; } + + /// public SerializedMoveEffect? Effect { get; set; } + + /// public SerializedMoveEffect? BattleEffect { get; set; } + /// public Dictionary? AdditionalData { get; set; } = null!; - [JsonExtensionData] public Dictionary? ExtensionData { get; set; } + /// + /// A collection of non-standard data that can be set on the item. + /// + [JsonExtensionData] + public Dictionary? ExtensionData { get; set; } } \ No newline at end of file diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedMove.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedMove.cs index d093935..54e8a44 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedMove.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedMove.cs @@ -4,30 +4,72 @@ using System.Text.Json.Serialization; namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models; +/// +/// A wrapper class for serialized move data. +/// public class SerializedMoveDataWrapper { - public SerializedMove[] Data { get; set; } = null!; + /// + /// The name of the move data file. + /// + public List Data { get; set; } = null!; } +/// +/// A class representing a serialized move. +/// public class SerializedMove { + /// public string Name { get; set; } = null!; + + /// public string Type { get; set; } = null!; + + /// public byte Power { get; set; } + + /// public byte PP { get; set; } + + /// public byte Accuracy { get; set; } + + /// public sbyte Priority { get; set; } + + /// public string Target { get; set; } = null!; + + /// public string Category { get; set; } = null!; + + /// + /// Arbitrary flags that can be applied to the move. + /// public string[] Flags { get; set; } = null!; + + /// public SerializedMoveEffect? Effect { get; set; } - [JsonExtensionData] public Dictionary? ExtensionData { get; set; } + /// + /// Additional non-standard data that can be added to the move. + /// + [JsonExtensionData] + public Dictionary? ExtensionData { get; set; } } +/// +/// A class representing a serialized move effect. +/// public class SerializedMoveEffect { + /// public string Name { get; set; } = null!; + + /// public float? Chance { get; set; } + + /// public Dictionary? Parameters { get; set; } = null!; } \ No newline at end of file diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedSpecies.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedSpecies.cs index 38ddf5c..fedd9e2 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedSpecies.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/Models/SerializedSpecies.cs @@ -2,71 +2,198 @@ using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable PropertyCanBeMadeInitOnly.Global + namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models; +/// +/// Represents a serialized species. +/// public class SerializedSpecies { + /// public string Species { get; set; } = null!; + + /// public ushort Id { get; set; } + + /// public float GenderRatio { get; set; } + + /// public string GrowthRate { get; set; } = null!; + + /// public byte BaseHappiness { get; set; } + + /// public byte CatchRate { get; set; } + + /// + /// The color of the Pokémon, used for Pokédex sorting. + /// public string Color { get; set; } = null!; + + /// + /// Whether the Pokémon has a different form per gender + /// public bool GenderDifference { get; set; } + + /// public string[] EggGroups { get; set; } = null!; + + /// + /// The number of steps required to hatch the Pokémon's egg, in cycles (1 cycle = 255 steps). + /// public int EggCycles { get; set; } + + /// public string[] Flags { get; set; } = []; + + /// public Dictionary Formes { get; set; } = null!; + + /// public SerializedEvolution[] Evolutions { get; set; } = []; - [JsonExtensionData] public Dictionary? ExtensionData { get; set; } + /// + /// Additional data that is not part of the standard species data. + /// + [JsonExtensionData] + public Dictionary? ExtensionData { get; set; } } +/// +/// Represents a serialized form of a Pokémon species. +/// public class SerializedForm { + /// public string[] Abilities { get; set; } = null!; + + /// public string[] HiddenAbilities { get; set; } = []; + + /// public SerializedStats BaseStats { get; set; } = null!; + + /// + /// The Pokémon's EV yield. This is the number of EVs gained when defeating a Pokémon of this species. + /// public SerializedStats EVReward { get; set; } = null!; + + /// public string[] Types { get; set; } = null!; + + /// public float Height { get; set; } + + /// public float Weight { get; set; } + + /// public uint BaseExp { get; set; } + + /// + /// Whether the form is a Mega Evolution. + /// public bool IsMega { get; set; } + + /// public SerializedMoves Moves { get; set; } = null!; + + /// public string[] Flags { get; set; } = []; - [JsonExtensionData] public Dictionary? ExtensionData { get; set; } + /// + /// Additional data that is not part of the standard form data. + /// + [JsonExtensionData] + public Dictionary? ExtensionData { get; set; } } +/// +/// Represents a serialized evolution of a Pokémon species. +/// public class SerializedEvolution { + /// public string Species { get; set; } = null!; + + /// + /// The method of evolution. + /// public string Method { get; set; } = null!; + + /// + /// Additional data for the evolution method. + /// public JsonNode Data { get; set; } = null!; } -public class SerializedStats +/// +/// Represents the base stats of a Pokémon species. +/// +public record SerializedStats { + /// public ushort Hp { get; set; } + + /// public ushort Attack { get; set; } + + /// public ushort Defense { get; set; } + + /// public ushort SpecialAttack { get; set; } + + /// public ushort SpecialDefense { get; set; } + + /// public ushort Speed { get; set; } } +/// +/// Represents a serialized level move. +/// public class SerializedLevelMove { + /// + /// The name of the move. + /// public string Name { get; set; } = null!; + + /// + /// The level at which the move is learned. + /// public uint Level { get; set; } } +/// +/// Represents a serialized set of moves a Pokémon can learn. +/// public class SerializedMoves { + /// + /// The moves the Pokémon can learn by leveling up. + /// public SerializedLevelMove[]? LevelMoves { get; set; } = null!; + + /// + /// The moves the Pokémon can learn by breeding. + /// public string[]? EggMoves { get; set; } = null!; + + /// + /// The moves the Pokémon can learn by tutoring. + /// public string[]? TutorMoves { get; set; } = null!; + + /// + /// The moves the Pokémon can learn by TM. + /// public string[]? Machine { get; set; } = null!; } \ No newline at end of file diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/MoveDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/MoveDataLoader.cs index 8caf862..7f382ca 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/MoveDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/MoveDataLoader.cs @@ -9,8 +9,14 @@ using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads move data from a JSON file. +/// public static class MoveDataLoader { + /// + /// Loads move data from a stream. + /// public static MoveLibrary LoadMoves(Stream stream, TypeLibrary typeLibrary, Action? onAfterLoad = null) { @@ -25,14 +31,20 @@ public static class MoveDataLoader return library; } - [PublicAPI] - public static - Func, MoveDataImpl> MoveConstructor = - (_, name, moveType, category, basePower, accuracy, baseUsages, target, priority, secondaryEffect, flags) => - new MoveDataImpl(name, moveType, category, basePower, accuracy, baseUsages, target, priority, - secondaryEffect, flags); + /// + /// Factory delegate for creating moves. + /// + public delegate MoveDataImpl MoveFactoryDelegate(SerializedMove serialized, StringKey name, TypeIdentifier type, + MoveCategory category, byte basePower, byte accuracy, byte pp, MoveTarget target, sbyte priority, + ISecondaryEffect? secondaryEffect, IEnumerable flags); + + /// + /// The move constructor. This is used to create moves from the JSON data. + /// + [PublicAPI] public static MoveFactoryDelegate MoveConstructor = + (_, name, moveType, category, basePower, accuracy, baseUsages, target, priority, secondaryEffect, flags) => + new MoveDataImpl(name, moveType, category, basePower, accuracy, baseUsages, target, priority, + secondaryEffect, flags); private static MoveDataImpl DeserializeMove(SerializedMove serialized, TypeLibrary typeLibrary) { diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/NatureDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/NatureDataLoader.cs index 17d802b..1b39256 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/NatureDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/NatureDataLoader.cs @@ -3,10 +3,16 @@ using PkmnLib.Static.Libraries; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads nature data from a CSV file. +/// public static class NatureDataLoader { private static readonly char[] CommonCsvDelimiters = ['|', ',']; + /// + /// Loads the nature library from a CSV file. + /// public static NatureLibrary LoadNatureLibrary(Stream stream) { var library = new NatureLibrary(); diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/SpeciesDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/SpeciesDataLoader.cs index 3eef1ba..497530d 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/SpeciesDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/SpeciesDataLoader.cs @@ -1,6 +1,7 @@ using System.Collections.Immutable; using System.Text.Json; using System.Text.Json.Nodes; +using JetBrains.Annotations; using PkmnLib.Dynamic.Libraries.DataLoaders.Models; using PkmnLib.Static; using PkmnLib.Static.Libraries; @@ -9,6 +10,9 @@ using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads species data from a JSON file. +/// public static class SpeciesDataLoader { private static Dictionary LoadSpeciesData(Stream stream) @@ -20,6 +24,9 @@ public static class SpeciesDataLoader x => x.Value.Deserialize(JsonOptions.DefaultOptions))!; } + /// + /// Loads the species library from a JSON file. + /// public static SpeciesLibrary LoadSpecies(Stream stream, IReadOnlyTypeLibrary typeLibrary, Action>? action = null) { @@ -34,14 +41,21 @@ public static class SpeciesDataLoader return library; } - public static - Func, - IEnumerable, IReadOnlyList, IEnumerable, SpeciesImpl> SpeciesConstructor = - (_, id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, evolutionData, eggGroups) => - { - return new SpeciesImpl(id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, - evolutionData, eggGroups); - }; + /// + /// Factory delegate for creating species. + /// + public delegate SpeciesImpl SpeciesFactoryDelegate(SerializedSpecies serialized, ushort id, StringKey name, + float genderRate, StringKey growthRate, byte captureRate, byte baseHappiness, + IReadOnlyDictionary forms, IEnumerable flags, + IReadOnlyList evolutionData, IEnumerable eggGroups); + + /// + /// The species constructor. This is used to create species from the JSON data. + /// + [PublicAPI] public static SpeciesFactoryDelegate SpeciesConstructor = + (_, id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, evolutionData, eggGroups) => + new SpeciesImpl(id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, evolutionData, + eggGroups); private static SpeciesImpl DeserializeSpecies(SerializedSpecies serialized, IReadOnlyTypeLibrary typeLibrary) { diff --git a/PkmnLib.Dynamic/Libraries/DataLoaders/TypeDataLoader.cs b/PkmnLib.Dynamic/Libraries/DataLoaders/TypeDataLoader.cs index 2e9671e..0d57085 100644 --- a/PkmnLib.Dynamic/Libraries/DataLoaders/TypeDataLoader.cs +++ b/PkmnLib.Dynamic/Libraries/DataLoaders/TypeDataLoader.cs @@ -2,10 +2,16 @@ using PkmnLib.Static.Libraries; namespace PkmnLib.Dynamic.Libraries.DataLoaders; +/// +/// Loads type data from a CSV file. +/// public static class TypeDataLoader { private static readonly char[] CommonCsvDelimiters = ['|', ',']; + /// + /// Loads the type library from a CSV file. + /// public static TypeLibrary LoadTypeLibrary(Stream stream) { var library = new TypeLibrary(); diff --git a/PkmnLib.Dynamic/Libraries/DynamicLibrary.cs b/PkmnLib.Dynamic/Libraries/DynamicLibrary.cs index 980f0d1..970dc20 100644 --- a/PkmnLib.Dynamic/Libraries/DynamicLibrary.cs +++ b/PkmnLib.Dynamic/Libraries/DynamicLibrary.cs @@ -54,8 +54,8 @@ public class DynamicLibraryImpl : IDynamicLibrary { var load = LibraryLoader.LoadPlugins(plugins); - return new DynamicLibraryImpl(load.staticLibrary, load.registry.BattleStatCalculator!, - load.registry.DamageCalculator!, load.registry.MiscLibrary!, load.registry.CaptureLibrary!, load.resolver); + return new DynamicLibraryImpl(load.StaticLibrary, load.Registry.BattleStatCalculator!, + load.Registry.DamageCalculator!, load.Registry.MiscLibrary!, load.Registry.CaptureLibrary!, load.Resolver); } private DynamicLibraryImpl(IStaticLibrary staticLibrary, IBattleStatCalculator statCalculator, diff --git a/PkmnLib.Dynamic/Libraries/LibraryLoader.cs b/PkmnLib.Dynamic/Libraries/LibraryLoader.cs index 0d7e911..d39f0c8 100644 --- a/PkmnLib.Dynamic/Libraries/LibraryLoader.cs +++ b/PkmnLib.Dynamic/Libraries/LibraryLoader.cs @@ -5,10 +5,19 @@ using PkmnLib.Static.Libraries; namespace PkmnLib.Dynamic.Libraries; +/// +/// Helper class for building data from plugins. +/// public static class LibraryLoader { - public record LoadResult(ScriptRegistry registry, ScriptResolver resolver, IStaticLibrary staticLibrary); + /// + /// Result of loading plugins. + /// + public record LoadResult(ScriptRegistry Registry, ScriptResolver Resolver, IStaticLibrary StaticLibrary); + /// + /// Loads plugins and creates a static library from them. + /// public static LoadResult LoadPlugins(IEnumerable plugins) { var registry = new ScriptRegistry(); diff --git a/PkmnLib.Dynamic/Models/BattleChoiceQueue.cs b/PkmnLib.Dynamic/Models/BattleChoiceQueue.cs index 1cc8c48..3533185 100644 --- a/PkmnLib.Dynamic/Models/BattleChoiceQueue.cs +++ b/PkmnLib.Dynamic/Models/BattleChoiceQueue.cs @@ -132,6 +132,9 @@ public class BattleChoiceQueue : IDeepCloneable public ITurnChoice? FirstOrDefault(Func predicate) => _choices.Skip(_currentIndex).WhereNotNull().FirstOrDefault(predicate); + /// + /// This returns all upcoming choices that match the predicate. + /// public IEnumerable Where(Func predicate) => _choices.Skip(_currentIndex).WhereNotNull().Where(predicate); diff --git a/PkmnLib.Dynamic/Models/BattleFlow/MoveTurnExecutor.cs b/PkmnLib.Dynamic/Models/BattleFlow/MoveTurnExecutor.cs index 48c3575..811b14b 100644 --- a/PkmnLib.Dynamic/Models/BattleFlow/MoveTurnExecutor.cs +++ b/PkmnLib.Dynamic/Models/BattleFlow/MoveTurnExecutor.cs @@ -7,6 +7,9 @@ using PkmnLib.Static.Utils; namespace PkmnLib.Dynamic.Models.BattleFlow; +/// +/// Helper class for executing moves. +/// public static class MoveTurnExecutor { internal static void ExecuteMoveChoice(IBattle battle, IMoveChoice moveChoice) @@ -88,6 +91,10 @@ public static class MoveTurnExecutor } } + /// + /// Executes the move for its targets. + /// + /// public static void ExecuteMove(IExecutingMove executingMove) { var stopped = false; diff --git a/PkmnLib.Dynamic/ScriptHandling/Registry/PluginDataMutator.cs b/PkmnLib.Dynamic/ScriptHandling/Registry/PluginDataMutator.cs index be9e89e..4f62e9f 100644 --- a/PkmnLib.Dynamic/ScriptHandling/Registry/PluginDataMutator.cs +++ b/PkmnLib.Dynamic/ScriptHandling/Registry/PluginDataMutator.cs @@ -3,11 +3,33 @@ using PkmnLib.Static; namespace PkmnLib.Dynamic.ScriptHandling.Registry; +/// +/// Interface for plugins that can mutate data. +/// public interface IPluginDataMutator { + /// + /// Mutates move data after it has been loaded, before it is used to convert to a static library. + /// void MutateMoveData(SerializedMoveDataWrapper data); + + /// + /// Mutates item data after it has been loaded, before it is used to convert to a static library. + /// void MutateItemData(List data); + + /// + /// Mutates ability data after it has been loaded, before it is used to convert to a static library. + /// void MutateAbilityData(Dictionary data); + + /// + /// Mutates growth rate data after it has been loaded, before it is used to convert to a static library. + /// void MutateGrowthRateData(List data); + + /// + /// Mutates species data after it has been loaded, before it is used to convert to a static library. + /// void MutateSpeciesData(Dictionary data); } \ No newline at end of file diff --git a/PkmnLib.Dynamic/ScriptHandling/Registry/ResourceProvider.cs b/PkmnLib.Dynamic/ScriptHandling/Registry/ResourceProvider.cs index b802b12..09faf6c 100644 --- a/PkmnLib.Dynamic/ScriptHandling/Registry/ResourceProvider.cs +++ b/PkmnLib.Dynamic/ScriptHandling/Registry/ResourceProvider.cs @@ -2,27 +2,64 @@ using PkmnLib.Static.Libraries; namespace PkmnLib.Dynamic.ScriptHandling.Registry; +/// +/// Interface for plugins that provide resources. +/// public interface IResourceProvider { + /// + /// The settings for the library. This is used to configure the library and its resources. + /// LibrarySettings? Settings { get; } + + /// + /// Gets the resource for the given type. This is used to load resources from the plugin. + /// Stream? GetResource(ResourceFileType request); } +/// +/// Enum for the different types of resources that can be loaded. +/// public enum ResourceFileType { + /// + /// Unknown type. This is used for errors and should not be used in normal code. + /// Unknown, + /// + /// The type for the types of Pokémon. This includes the type effectiveness chart and the type names. + /// Types, + /// + /// The type for the natures of Pokémon. This includes the nature names and the nature effects. + /// Natures, + /// + /// The type for the moves of Pokémon. This includes the move names and the move effects. + /// Moves, + /// + /// The type for the items of Pokémon. This includes the item names and the item effects. + /// Items, + /// + /// The type for the abilities of Pokémon. This includes the ability names and the ability effects. + /// Abilities, + /// + /// The type for the growth rates of Pokémon. This includes the growth rate names and the growth rate effects. + /// GrowthRates, + /// + /// The type for the species of Pokémon. This includes the species names and the species effects. + /// Species, } \ No newline at end of file diff --git a/PkmnLib.Dynamic/ScriptHandling/Script.cs b/PkmnLib.Dynamic/ScriptHandling/Script.cs index 9f6f29c..740afa9 100644 --- a/PkmnLib.Dynamic/ScriptHandling/Script.cs +++ b/PkmnLib.Dynamic/ScriptHandling/Script.cs @@ -97,6 +97,9 @@ public abstract class Script : IDeepCloneable { } + /// + /// This function is ran when this script is added to a parent. + /// public virtual void OnAddedToParent(IScriptSource source) { } @@ -690,14 +693,26 @@ public abstract class Script : IDeepCloneable { } + /// + /// This function allows a script to prevent a Pokemon from being affected by a status condition. + /// public virtual void PreventStatusChange(IPokemon pokemonImpl, StringKey status, ref bool preventStatus) { } + /// + /// This function allows a script to prevent a Pokémon from being affected by a volatile status condition. + /// public virtual void PreventVolatileAdd(Script script, ref bool preventVolatileAdd) { } + /// + /// This function allows a script to make the Pokémon it is attached to float. This is used for moves + /// such as levitate, and allows for moves such as earthquake to not hit the Pokémon. + /// + /// + /// public virtual void IsFloating(IPokemon pokemon, ref bool isFloating) { } diff --git a/PkmnLib.Dynamic/ScriptHandling/ScriptSet.cs b/PkmnLib.Dynamic/ScriptHandling/ScriptSet.cs index 7781123..089fe64 100644 --- a/PkmnLib.Dynamic/ScriptHandling/ScriptSet.cs +++ b/PkmnLib.Dynamic/ScriptHandling/ScriptSet.cs @@ -1,5 +1,4 @@ using System.Collections; -using System.Diagnostics.CodeAnalysis; using PkmnLib.Dynamic.ScriptHandling.Registry; using PkmnLib.Static.Utils; @@ -85,6 +84,7 @@ public class ScriptSet : IScriptSet private readonly List _scripts = []; + /// public ScriptSet(IScriptSource source) { _source = source; diff --git a/PkmnLib.Tests/DataTests/MoveDataTests.cs b/PkmnLib.Tests/DataTests/MoveDataTests.cs index a62cf8b..d6f2f14 100644 --- a/PkmnLib.Tests/DataTests/MoveDataTests.cs +++ b/PkmnLib.Tests/DataTests/MoveDataTests.cs @@ -1,9 +1,7 @@ -using System.Text.Json.Nodes; using PkmnLib.Dynamic.Libraries; using PkmnLib.Dynamic.ScriptHandling; using PkmnLib.Static.Moves; using PkmnLib.Tests.Integration; -using TUnit.Core.Logging; namespace PkmnLib.Tests.DataTests; diff --git a/PkmnLib.Tests/Integration/LibraryHelpers.cs b/PkmnLib.Tests/Integration/LibraryHelpers.cs index 77e8864..0871d10 100644 --- a/PkmnLib.Tests/Integration/LibraryHelpers.cs +++ b/PkmnLib.Tests/Integration/LibraryHelpers.cs @@ -1,7 +1,5 @@ using PkmnLib.Dynamic.Libraries; -using PkmnLib.Dynamic.Libraries.DataLoaders; using PkmnLib.Plugin.Gen7; -using PkmnLib.Static.Libraries; namespace PkmnLib.Tests.Integration; diff --git a/Plugins/PkmnLib.Plugin.Gen7.Tests/DamageCalculatorTests.cs b/Plugins/PkmnLib.Plugin.Gen7.Tests/DamageCalculatorTests.cs index 8e35336..85884c4 100644 --- a/Plugins/PkmnLib.Plugin.Gen7.Tests/DamageCalculatorTests.cs +++ b/Plugins/PkmnLib.Plugin.Gen7.Tests/DamageCalculatorTests.cs @@ -1,6 +1,5 @@ using PkmnLib.Dynamic.Models; using PkmnLib.Dynamic.ScriptHandling; -using PkmnLib.Plugin.Gen7.Libraries; using PkmnLib.Plugin.Gen7.Libraries.Battling; using PkmnLib.Static; using PkmnLib.Static.Moves; diff --git a/Plugins/PkmnLib.Plugin.Gen7/Gen7Plugin.cs b/Plugins/PkmnLib.Plugin.Gen7/Gen7Plugin.cs index 0ef9fe9..f865384 100644 --- a/Plugins/PkmnLib.Plugin.Gen7/Gen7Plugin.cs +++ b/Plugins/PkmnLib.Plugin.Gen7/Gen7Plugin.cs @@ -1,7 +1,5 @@ using System; -using System.ComponentModel; using System.IO; -using PkmnLib.Plugin.Gen7.Libraries; using PkmnLib.Plugin.Gen7.Libraries.Battling; using PkmnLib.Static.Libraries; @@ -44,7 +42,7 @@ public class Gen7Plugin : Dynamic.ScriptHandling.Registry.Plugin, IResourceProvi } /// - public LibrarySettings? Settings => new() + public LibrarySettings Settings => new() { MaxLevel = 100, ShinyRate = 4096, diff --git a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/FlameWheel.cs b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/FlameWheel.cs index 4a7c3ec..239fb4a 100644 --- a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/FlameWheel.cs +++ b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/FlameWheel.cs @@ -28,7 +28,6 @@ public class FlameWheel : Script move.User.ClearStatus(); } - var burnChance = _burnChance; if (move.Battle.Random.EffectChance(_burnChance, move, target, hit)) { target.SetStatus("burned"); diff --git a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Spite.cs b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Spite.cs index 81ba5fd..775a775 100644 --- a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Spite.cs +++ b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Spite.cs @@ -18,7 +18,6 @@ public class Spite : Script if (!lastMoveChoiceByTarget.ChosenMove.ReduceUses(4)) { move.GetHitData(target, hit).Fail(); - return; } } } \ No newline at end of file diff --git a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs index 7178ddb..ce85cbb 100644 --- a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs +++ b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using PkmnLib.Static.Utils; namespace PkmnLib.Plugin.Gen7.Scripts.Side; diff --git a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Status/Sleep.cs b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Status/Sleep.cs index 4ba78af..8cd6757 100644 --- a/Plugins/PkmnLib.Plugin.Gen7/Scripts/Status/Sleep.cs +++ b/Plugins/PkmnLib.Plugin.Gen7/Scripts/Status/Sleep.cs @@ -8,7 +8,6 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Status; public class Sleep : Script { public int Turns { get; set; } - private IPokemon? _owner; /// public override void OnAddedToParent(IScriptSource source) @@ -18,7 +17,6 @@ public class Sleep : Script return; if (source is not IPokemon pokemon) throw new InvalidOperationException("Sleep script can only be added to a Pokemon."); - _owner = pokemon; var battleData = pokemon.BattleData; if (battleData != null) {