Document all undocumented methods and properties
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Deukhoofd 2025-05-16 13:59:36 +02:00
parent 810cdbb15a
commit fdfca99e71
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
27 changed files with 384 additions and 39 deletions

View File

@ -8,6 +8,9 @@ using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
/// <summary>
/// Loads ability data from a JSON file.
/// </summary>
public static class AbilityDataLoader
{
private static Dictionary<string, SerializedAbility> LoadAbilitiesData(Stream stream)
@ -26,6 +29,9 @@ public static class AbilityDataLoader
return objects;
}
/// <summary>
/// Loads the ability library from a JSON file.
/// </summary>
public static AbilityLibrary LoadAbilities(Stream stream,
Action<Dictionary<string, SerializedAbility>>? action = null)
{

View File

@ -4,8 +4,14 @@ using PkmnLib.Static.Libraries;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
/// <summary>
/// Loads growth rate data from a JSON file.
/// </summary>
public static class GrowthRateDataLoader
{
/// <summary>
/// Loads the growth rate library from a JSON file.
/// </summary>
public static GrowthRateLibrary LoadGrowthRates(Stream stream, Action<List<IGrowthRate>>? action = null)
{
var objects = JsonSerializer.Deserialize<Dictionary<string, uint[]>>(stream, JsonOptions.DefaultOptions)!;

View File

@ -9,8 +9,14 @@ using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
/// <summary>
/// Loads item data from a JSON file.
/// </summary>
public static class ItemDataLoader
{
/// <summary>
/// Loads the item library from a JSON file.
/// </summary>
public static ItemLibrary LoadItems(Stream stream, Action<List<SerializedItem>>? onAfterLoad = null)
{
var library = new ItemLibrary();
@ -24,10 +30,16 @@ public static class ItemDataLoader
return library;
}
/// <summary>
/// Factory delegate for creating items.
/// </summary>
public delegate IItem ItemFactoryDelegate(SerializedItem serialized, StringKey name, ItemCategory type,
BattleItemCategory battleType, int price, ImmutableHashSet<StringKey> flags, ISecondaryEffect? effect,
ISecondaryEffect? battleTriggerEffect, Dictionary<StringKey, object?> additionalData);
/// <summary>
/// The item constructor. This is used to create items from the JSON data.
/// </summary>
[PublicAPI]
public static ItemFactoryDelegate ItemConstructor { get; set; } =
(_, name, type, battleType, price, flags, effect, battleTriggerEffect, additionalData) => new ItemImpl(name,

View File

@ -1,10 +1,22 @@
using System.Text.Json.Nodes;
// ReSharper disable CollectionNeverUpdated.Global
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
/// <summary>
/// Represents a serialized ability.
/// </summary>
public class SerializedAbility
{
/// <inheritdoc cref="PkmnLib.Static.Species.IAbility.Effect"/>
public string? Effect { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.IAbility.Parameters"/>
public Dictionary<string, JsonNode> Parameters { get; set; } = new();
/// <summary>
/// A collection of arbitrary flags that can be used to mark the ability with specific properties.
/// </summary>
public string[] Flags { get; set; } = [];
}

View File

@ -4,17 +4,38 @@ using System.Text.Json.Serialization;
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
/// <summary>
/// Represents a serialized item.
/// </summary>
public class SerializedItem
{
/// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name" />
public string Name { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.IItem.Category" />
public string ItemType { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.IItem.BattleCategory" />
public string BattleType { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.IItem.Flags" />
public string[] Flags { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.IItem.Price" />
public int Price { get; set; }
/// <inheritdoc cref="PkmnLib.Static.IItem.Effect" />
public SerializedMoveEffect? Effect { get; set; }
/// <inheritdoc cref="PkmnLib.Static.IItem.BattleEffect" />
public SerializedMoveEffect? BattleEffect { get; set; }
/// <inheritdoc cref="PkmnLib.Static.IItem.AdditionalData" />
public Dictionary<string, JsonNode>? AdditionalData { get; set; } = null!;
[JsonExtensionData] public Dictionary<string, JsonElement>? ExtensionData { get; set; }
/// <summary>
/// A collection of non-standard data that can be set on the item.
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}

View File

@ -4,30 +4,72 @@ using System.Text.Json.Serialization;
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
/// <summary>
/// A wrapper class for serialized move data.
/// </summary>
public class SerializedMoveDataWrapper
{
public SerializedMove[] Data { get; set; } = null!;
/// <summary>
/// The name of the move data file.
/// </summary>
public List<SerializedMove> Data { get; set; } = null!;
}
/// <summary>
/// A class representing a serialized move.
/// </summary>
public class SerializedMove
{
/// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name" />
public string Name { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.MoveType" />
public string Type { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.BasePower" />
public byte Power { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.BaseUsages" />
public byte PP { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Accuracy" />
public byte Accuracy { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Priority" />
public sbyte Priority { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Target" />
public string Target { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Category" />
public string Category { get; set; } = null!;
/// <summary>
/// Arbitrary flags that can be applied to the move.
/// </summary>
public string[] Flags { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.SecondaryEffect" />
public SerializedMoveEffect? Effect { get; set; }
[JsonExtensionData] public Dictionary<string, JsonElement>? ExtensionData { get; set; }
/// <summary>
/// Additional non-standard data that can be added to the move.
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}
/// <summary>
/// A class representing a serialized move effect.
/// </summary>
public class SerializedMoveEffect
{
/// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Name" />
public string Name { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Chance" />
public float? Chance { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Parameters" />
public Dictionary<string, JsonNode>? Parameters { get; set; } = null!;
}

View File

@ -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;
/// <summary>
/// Represents a serialized species.
/// </summary>
public class SerializedSpecies
{
/// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name"/>
public string Species { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.Id"/>
public ushort Id { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.GenderRate"/>
public float GenderRatio { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.GrowthRate"/>
public string GrowthRate { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.BaseHappiness"/>
public byte BaseHappiness { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.CaptureRate"/>
public byte CatchRate { get; set; }
/// <summary>
/// The color of the Pokémon, used for Pokédex sorting.
/// </summary>
public string Color { get; set; } = null!;
/// <summary>
/// Whether the Pokémon has a different form per gender
/// </summary>
public bool GenderDifference { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.EggGroups"/>
public string[] EggGroups { get; set; } = null!;
/// <summary>
/// The number of steps required to hatch the Pokémon's egg, in cycles (1 cycle = 255 steps).
/// </summary>
public int EggCycles { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.Flags"/>
public string[] Flags { get; set; } = [];
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.Forms"/>
public Dictionary<string, SerializedForm> Formes { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.EvolutionData"/>
public SerializedEvolution[] Evolutions { get; set; } = [];
[JsonExtensionData] public Dictionary<string, JsonElement>? ExtensionData { get; set; }
/// <summary>
/// Additional data that is not part of the standard species data.
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}
/// <summary>
/// Represents a serialized form of a Pokémon species.
/// </summary>
public class SerializedForm
{
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Abilities"/>
public string[] Abilities { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.HiddenAbilities"/>
public string[] HiddenAbilities { get; set; } = [];
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.BaseStats"/>
public SerializedStats BaseStats { get; set; } = null!;
/// <summary>
/// The Pokémon's EV yield. This is the number of EVs gained when defeating a Pokémon of this species.
/// </summary>
public SerializedStats EVReward { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Types"/>
public string[] Types { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Height"/>
public float Height { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Weight"/>
public float Weight { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.BaseExperience"/>
public uint BaseExp { get; set; }
/// <summary>
/// Whether the form is a Mega Evolution.
/// </summary>
public bool IsMega { get; set; }
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Moves"/>
public SerializedMoves Moves { get; set; } = null!;
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Flags"/>
public string[] Flags { get; set; } = [];
[JsonExtensionData] public Dictionary<string, JsonElement>? ExtensionData { get; set; }
/// <summary>
/// Additional data that is not part of the standard form data.
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}
/// <summary>
/// Represents a serialized evolution of a Pokémon species.
/// </summary>
public class SerializedEvolution
{
/// <inheritdoc cref="PkmnLib.Static.Species.IEvolution.ToSpecies"/>
public string Species { get; set; } = null!;
/// <summary>
/// The method of evolution.
/// </summary>
public string Method { get; set; } = null!;
/// <summary>
/// Additional data for the evolution method.
/// </summary>
public JsonNode Data { get; set; } = null!;
}
public class SerializedStats
/// <summary>
/// Represents the base stats of a Pokémon species.
/// </summary>
public record SerializedStats
{
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Hp"/>
public ushort Hp { get; set; }
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Attack"/>
public ushort Attack { get; set; }
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Defense"/>
public ushort Defense { get; set; }
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.SpecialAttack"/>
public ushort SpecialAttack { get; set; }
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.SpecialDefense"/>
public ushort SpecialDefense { get; set; }
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Speed"/>
public ushort Speed { get; set; }
}
/// <summary>
/// Represents a serialized level move.
/// </summary>
public class SerializedLevelMove
{
/// <summary>
/// The name of the move.
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// The level at which the move is learned.
/// </summary>
public uint Level { get; set; }
}
/// <summary>
/// Represents a serialized set of moves a Pokémon can learn.
/// </summary>
public class SerializedMoves
{
/// <summary>
/// The moves the Pokémon can learn by leveling up.
/// </summary>
public SerializedLevelMove[]? LevelMoves { get; set; } = null!;
/// <summary>
/// The moves the Pokémon can learn by breeding.
/// </summary>
public string[]? EggMoves { get; set; } = null!;
/// <summary>
/// The moves the Pokémon can learn by tutoring.
/// </summary>
public string[]? TutorMoves { get; set; } = null!;
/// <summary>
/// The moves the Pokémon can learn by TM.
/// </summary>
public string[]? Machine { get; set; } = null!;
}

View File

@ -9,8 +9,14 @@ using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
/// <summary>
/// Loads move data from a JSON file.
/// </summary>
public static class MoveDataLoader
{
/// <summary>
/// Loads move data from a stream.
/// </summary>
public static MoveLibrary LoadMoves(Stream stream, TypeLibrary typeLibrary,
Action<SerializedMoveDataWrapper>? onAfterLoad = null)
{
@ -25,11 +31,17 @@ public static class MoveDataLoader
return library;
}
[PublicAPI]
public static
Func<SerializedMove, StringKey, TypeIdentifier, MoveCategory, byte, byte, byte, MoveTarget, sbyte,
ISecondaryEffect?
, IEnumerable<StringKey>, MoveDataImpl> MoveConstructor =
/// <summary>
/// Factory delegate for creating moves.
/// </summary>
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<StringKey> flags);
/// <summary>
/// The move constructor. This is used to create moves from the JSON data.
/// </summary>
[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);

View File

@ -3,10 +3,16 @@ using PkmnLib.Static.Libraries;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
/// <summary>
/// Loads nature data from a CSV file.
/// </summary>
public static class NatureDataLoader
{
private static readonly char[] CommonCsvDelimiters = ['|', ','];
/// <summary>
/// Loads the nature library from a CSV file.
/// </summary>
public static NatureLibrary LoadNatureLibrary(Stream stream)
{
var library = new NatureLibrary();

View File

@ -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;
/// <summary>
/// Loads species data from a JSON file.
/// </summary>
public static class SpeciesDataLoader
{
private static Dictionary<string, SerializedSpecies> LoadSpeciesData(Stream stream)
@ -20,6 +24,9 @@ public static class SpeciesDataLoader
x => x.Value.Deserialize<SerializedSpecies>(JsonOptions.DefaultOptions))!;
}
/// <summary>
/// Loads the species library from a JSON file.
/// </summary>
public static SpeciesLibrary LoadSpecies(Stream stream, IReadOnlyTypeLibrary typeLibrary,
Action<Dictionary<string, SerializedSpecies>>? action = null)
{
@ -34,14 +41,21 @@ public static class SpeciesDataLoader
return library;
}
public static
Func<SerializedSpecies, ushort, StringKey, float, StringKey, byte, byte, IReadOnlyDictionary<StringKey, IForm>,
IEnumerable<StringKey>, IReadOnlyList<IEvolution>, IEnumerable<StringKey>, SpeciesImpl> SpeciesConstructor =
/// <summary>
/// Factory delegate for creating species.
/// </summary>
public delegate SpeciesImpl SpeciesFactoryDelegate(SerializedSpecies serialized, ushort id, StringKey name,
float genderRate, StringKey growthRate, byte captureRate, byte baseHappiness,
IReadOnlyDictionary<StringKey, IForm> forms, IEnumerable<StringKey> flags,
IReadOnlyList<IEvolution> evolutionData, IEnumerable<StringKey> eggGroups);
/// <summary>
/// The species constructor. This is used to create species from the JSON data.
/// </summary>
[PublicAPI] public static SpeciesFactoryDelegate SpeciesConstructor =
(_, id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, evolutionData, eggGroups) =>
{
return new SpeciesImpl(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)
{

View File

@ -2,10 +2,16 @@ using PkmnLib.Static.Libraries;
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
/// <summary>
/// Loads type data from a CSV file.
/// </summary>
public static class TypeDataLoader
{
private static readonly char[] CommonCsvDelimiters = ['|', ','];
/// <summary>
/// Loads the type library from a CSV file.
/// </summary>
public static TypeLibrary LoadTypeLibrary(Stream stream)
{
var library = new TypeLibrary();

View File

@ -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,

View File

@ -5,10 +5,19 @@ using PkmnLib.Static.Libraries;
namespace PkmnLib.Dynamic.Libraries;
/// <summary>
/// Helper class for building data from plugins.
/// </summary>
public static class LibraryLoader
{
public record LoadResult(ScriptRegistry registry, ScriptResolver resolver, IStaticLibrary staticLibrary);
/// <summary>
/// Result of loading plugins.
/// </summary>
public record LoadResult(ScriptRegistry Registry, ScriptResolver Resolver, IStaticLibrary StaticLibrary);
/// <summary>
/// Loads plugins and creates a static library from them.
/// </summary>
public static LoadResult LoadPlugins(IEnumerable<Plugin> plugins)
{
var registry = new ScriptRegistry();

View File

@ -132,6 +132,9 @@ public class BattleChoiceQueue : IDeepCloneable
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) =>
_choices.Skip(_currentIndex).WhereNotNull().FirstOrDefault(predicate);
/// <summary>
/// This returns all upcoming choices that match the predicate.
/// </summary>
public IEnumerable<ITurnChoice> Where(Func<ITurnChoice, bool> predicate) =>
_choices.Skip(_currentIndex).WhereNotNull().Where(predicate);

View File

@ -7,6 +7,9 @@ using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Models.BattleFlow;
/// <summary>
/// Helper class for executing moves.
/// </summary>
public static class MoveTurnExecutor
{
internal static void ExecuteMoveChoice(IBattle battle, IMoveChoice moveChoice)
@ -88,6 +91,10 @@ public static class MoveTurnExecutor
}
}
/// <summary>
/// Executes the move for its targets.
/// </summary>
/// <param name="executingMove"></param>
public static void ExecuteMove(IExecutingMove executingMove)
{
var stopped = false;

View File

@ -3,11 +3,33 @@ using PkmnLib.Static;
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
/// <summary>
/// Interface for plugins that can mutate data.
/// </summary>
public interface IPluginDataMutator
{
/// <summary>
/// Mutates move data after it has been loaded, before it is used to convert to a static library.
/// </summary>
void MutateMoveData(SerializedMoveDataWrapper data);
/// <summary>
/// Mutates item data after it has been loaded, before it is used to convert to a static library.
/// </summary>
void MutateItemData(List<SerializedItem> data);
/// <summary>
/// Mutates ability data after it has been loaded, before it is used to convert to a static library.
/// </summary>
void MutateAbilityData(Dictionary<string, SerializedAbility> data);
/// <summary>
/// Mutates growth rate data after it has been loaded, before it is used to convert to a static library.
/// </summary>
void MutateGrowthRateData(List<IGrowthRate> data);
/// <summary>
/// Mutates species data after it has been loaded, before it is used to convert to a static library.
/// </summary>
void MutateSpeciesData(Dictionary<string, SerializedSpecies> data);
}

View File

@ -2,27 +2,64 @@ using PkmnLib.Static.Libraries;
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
/// <summary>
/// Interface for plugins that provide resources.
/// </summary>
public interface IResourceProvider
{
/// <summary>
/// The settings for the library. This is used to configure the library and its resources.
/// </summary>
LibrarySettings? Settings { get; }
/// <summary>
/// Gets the resource for the given type. This is used to load resources from the plugin.
/// </summary>
Stream? GetResource(ResourceFileType request);
}
/// <summary>
/// Enum for the different types of resources that can be loaded.
/// </summary>
public enum ResourceFileType
{
/// <summary>
/// Unknown type. This is used for errors and should not be used in normal code.
/// </summary>
Unknown,
/// <summary>
/// The type for the types of Pokémon. This includes the type effectiveness chart and the type names.
/// </summary>
Types,
/// <summary>
/// The type for the natures of Pokémon. This includes the nature names and the nature effects.
/// </summary>
Natures,
/// <summary>
/// The type for the moves of Pokémon. This includes the move names and the move effects.
/// </summary>
Moves,
/// <summary>
/// The type for the items of Pokémon. This includes the item names and the item effects.
/// </summary>
Items,
/// <summary>
/// The type for the abilities of Pokémon. This includes the ability names and the ability effects.
/// </summary>
Abilities,
/// <summary>
/// The type for the growth rates of Pokémon. This includes the growth rate names and the growth rate effects.
/// </summary>
GrowthRates,
/// <summary>
/// The type for the species of Pokémon. This includes the species names and the species effects.
/// </summary>
Species,
}

View File

@ -97,6 +97,9 @@ public abstract class Script : IDeepCloneable
{
}
/// <summary>
/// This function is ran when this script is added to a parent.
/// </summary>
public virtual void OnAddedToParent(IScriptSource source)
{
}
@ -690,14 +693,26 @@ public abstract class Script : IDeepCloneable
{
}
/// <summary>
/// This function allows a script to prevent a Pokemon from being affected by a status condition.
/// </summary>
public virtual void PreventStatusChange(IPokemon pokemonImpl, StringKey status, ref bool preventStatus)
{
}
/// <summary>
/// This function allows a script to prevent a Pokémon from being affected by a volatile status condition.
/// </summary>
public virtual void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
{
}
/// <summary>
/// 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.
/// </summary>
/// <param name="pokemon"></param>
/// <param name="isFloating"></param>
public virtual void IsFloating(IPokemon pokemon, ref bool isFloating)
{
}

View File

@ -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<ScriptContainer> _scripts = [];
/// <inheritdoc cref="IScriptSet"/>
public ScriptSet(IScriptSource source)
{
_source = source;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
}
/// <inheritdoc />
public LibrarySettings? Settings => new()
public LibrarySettings Settings => new()
{
MaxLevel = 100,
ShinyRate = 4096,

View File

@ -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");

View File

@ -18,7 +18,6 @@ public class Spite : Script
if (!lastMoveChoiceByTarget.ChosenMove.ReduceUses(4))
{
move.GetHitData(target, hit).Fail();
return;
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Side;

View File

@ -8,7 +8,6 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Status;
public class Sleep : Script
{
public int Turns { get; set; }
private IPokemon? _owner;
/// <inheritdoc />
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)
{