Document all undocumented methods and properties
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
810cdbb15a
commit
fdfca99e71
@ -8,6 +8,9 @@ using PkmnLib.Static.Utils;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads ability data from a JSON file.
|
||||||
|
/// </summary>
|
||||||
public static class AbilityDataLoader
|
public static class AbilityDataLoader
|
||||||
{
|
{
|
||||||
private static Dictionary<string, SerializedAbility> LoadAbilitiesData(Stream stream)
|
private static Dictionary<string, SerializedAbility> LoadAbilitiesData(Stream stream)
|
||||||
@ -26,6 +29,9 @@ public static class AbilityDataLoader
|
|||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the ability library from a JSON file.
|
||||||
|
/// </summary>
|
||||||
public static AbilityLibrary LoadAbilities(Stream stream,
|
public static AbilityLibrary LoadAbilities(Stream stream,
|
||||||
Action<Dictionary<string, SerializedAbility>>? action = null)
|
Action<Dictionary<string, SerializedAbility>>? action = null)
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,14 @@ using PkmnLib.Static.Libraries;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads growth rate data from a JSON file.
|
||||||
|
/// </summary>
|
||||||
public static class GrowthRateDataLoader
|
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)
|
public static GrowthRateLibrary LoadGrowthRates(Stream stream, Action<List<IGrowthRate>>? action = null)
|
||||||
{
|
{
|
||||||
var objects = JsonSerializer.Deserialize<Dictionary<string, uint[]>>(stream, JsonOptions.DefaultOptions)!;
|
var objects = JsonSerializer.Deserialize<Dictionary<string, uint[]>>(stream, JsonOptions.DefaultOptions)!;
|
||||||
|
@ -9,8 +9,14 @@ using PkmnLib.Static.Utils;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads item data from a JSON file.
|
||||||
|
/// </summary>
|
||||||
public static class ItemDataLoader
|
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)
|
public static ItemLibrary LoadItems(Stream stream, Action<List<SerializedItem>>? onAfterLoad = null)
|
||||||
{
|
{
|
||||||
var library = new ItemLibrary();
|
var library = new ItemLibrary();
|
||||||
@ -24,10 +30,16 @@ public static class ItemDataLoader
|
|||||||
return library;
|
return library;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Factory delegate for creating items.
|
||||||
|
/// </summary>
|
||||||
public delegate IItem ItemFactoryDelegate(SerializedItem serialized, StringKey name, ItemCategory type,
|
public delegate IItem ItemFactoryDelegate(SerializedItem serialized, StringKey name, ItemCategory type,
|
||||||
BattleItemCategory battleType, int price, ImmutableHashSet<StringKey> flags, ISecondaryEffect? effect,
|
BattleItemCategory battleType, int price, ImmutableHashSet<StringKey> flags, ISecondaryEffect? effect,
|
||||||
ISecondaryEffect? battleTriggerEffect, Dictionary<StringKey, object?> additionalData);
|
ISecondaryEffect? battleTriggerEffect, Dictionary<StringKey, object?> additionalData);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The item constructor. This is used to create items from the JSON data.
|
||||||
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static ItemFactoryDelegate ItemConstructor { get; set; } =
|
public static ItemFactoryDelegate ItemConstructor { get; set; } =
|
||||||
(_, name, type, battleType, price, flags, effect, battleTriggerEffect, additionalData) => new ItemImpl(name,
|
(_, name, type, battleType, price, flags, effect, battleTriggerEffect, additionalData) => new ItemImpl(name,
|
||||||
|
@ -1,10 +1,22 @@
|
|||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
// ReSharper disable CollectionNeverUpdated.Global
|
||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a serialized ability.
|
||||||
|
/// </summary>
|
||||||
public class SerializedAbility
|
public class SerializedAbility
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IAbility.Effect"/>
|
||||||
public string? Effect { get; set; }
|
public string? Effect { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IAbility.Parameters"/>
|
||||||
public Dictionary<string, JsonNode> Parameters { get; set; } = new();
|
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; } = [];
|
public string[] Flags { get; set; } = [];
|
||||||
}
|
}
|
@ -4,17 +4,38 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a serialized item.
|
||||||
|
/// </summary>
|
||||||
public class SerializedItem
|
public class SerializedItem
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name" />
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.Category" />
|
||||||
public string ItemType { get; set; } = null!;
|
public string ItemType { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.BattleCategory" />
|
||||||
public string BattleType { get; set; } = null!;
|
public string BattleType { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.Flags" />
|
||||||
public string[] Flags { get; set; } = null!;
|
public string[] Flags { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.Price" />
|
||||||
public int Price { get; set; }
|
public int Price { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.Effect" />
|
||||||
public SerializedMoveEffect? Effect { get; set; }
|
public SerializedMoveEffect? Effect { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.BattleEffect" />
|
||||||
public SerializedMoveEffect? BattleEffect { get; set; }
|
public SerializedMoveEffect? BattleEffect { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.IItem.AdditionalData" />
|
||||||
public Dictionary<string, JsonNode>? AdditionalData { get; set; } = null!;
|
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; }
|
||||||
}
|
}
|
@ -4,30 +4,72 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A wrapper class for serialized move data.
|
||||||
|
/// </summary>
|
||||||
public class SerializedMoveDataWrapper
|
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
|
public class SerializedMove
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name" />
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.MoveType" />
|
||||||
public string Type { get; set; } = null!;
|
public string Type { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.BasePower" />
|
||||||
public byte Power { get; set; }
|
public byte Power { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.BaseUsages" />
|
||||||
public byte PP { get; set; }
|
public byte PP { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Accuracy" />
|
||||||
public byte Accuracy { get; set; }
|
public byte Accuracy { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Priority" />
|
||||||
public sbyte Priority { get; set; }
|
public sbyte Priority { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Target" />
|
||||||
public string Target { get; set; } = null!;
|
public string Target { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Category" />
|
||||||
public string Category { get; set; } = null!;
|
public string Category { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Arbitrary flags that can be applied to the move.
|
||||||
|
/// </summary>
|
||||||
public string[] Flags { get; set; } = null!;
|
public string[] Flags { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.SecondaryEffect" />
|
||||||
public SerializedMoveEffect? Effect { get; set; }
|
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
|
public class SerializedMoveEffect
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Name" />
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Chance" />
|
||||||
public float? Chance { get; set; }
|
public float? Chance { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Parameters" />
|
||||||
public Dictionary<string, JsonNode>? Parameters { get; set; } = null!;
|
public Dictionary<string, JsonNode>? Parameters { get; set; } = null!;
|
||||||
}
|
}
|
@ -2,71 +2,198 @@ using System.Text.Json;
|
|||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
// ReSharper disable PropertyCanBeMadeInitOnly.Global
|
||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a serialized species.
|
||||||
|
/// </summary>
|
||||||
public class SerializedSpecies
|
public class SerializedSpecies
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name"/>
|
||||||
public string Species { get; set; } = null!;
|
public string Species { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.Id"/>
|
||||||
public ushort Id { get; set; }
|
public ushort Id { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.GenderRate"/>
|
||||||
public float GenderRatio { get; set; }
|
public float GenderRatio { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.GrowthRate"/>
|
||||||
public string GrowthRate { get; set; } = null!;
|
public string GrowthRate { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.BaseHappiness"/>
|
||||||
public byte BaseHappiness { get; set; }
|
public byte BaseHappiness { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.CaptureRate"/>
|
||||||
public byte CatchRate { get; set; }
|
public byte CatchRate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The color of the Pokémon, used for Pokédex sorting.
|
||||||
|
/// </summary>
|
||||||
public string Color { get; set; } = null!;
|
public string Color { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the Pokémon has a different form per gender
|
||||||
|
/// </summary>
|
||||||
public bool GenderDifference { get; set; }
|
public bool GenderDifference { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.EggGroups"/>
|
||||||
public string[] EggGroups { get; set; } = null!;
|
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; }
|
public int EggCycles { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.Flags"/>
|
||||||
public string[] Flags { get; set; } = [];
|
public string[] Flags { get; set; } = [];
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.Forms"/>
|
||||||
public Dictionary<string, SerializedForm> Formes { get; set; } = null!;
|
public Dictionary<string, SerializedForm> Formes { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.ISpecies.EvolutionData"/>
|
||||||
public SerializedEvolution[] Evolutions { get; set; } = [];
|
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
|
public class SerializedForm
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Abilities"/>
|
||||||
public string[] Abilities { get; set; } = null!;
|
public string[] Abilities { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.HiddenAbilities"/>
|
||||||
public string[] HiddenAbilities { get; set; } = [];
|
public string[] HiddenAbilities { get; set; } = [];
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.BaseStats"/>
|
||||||
public SerializedStats BaseStats { get; set; } = null!;
|
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!;
|
public SerializedStats EVReward { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Types"/>
|
||||||
public string[] Types { get; set; } = null!;
|
public string[] Types { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Height"/>
|
||||||
public float Height { get; set; }
|
public float Height { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Weight"/>
|
||||||
public float Weight { get; set; }
|
public float Weight { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.BaseExperience"/>
|
||||||
public uint BaseExp { get; set; }
|
public uint BaseExp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the form is a Mega Evolution.
|
||||||
|
/// </summary>
|
||||||
public bool IsMega { get; set; }
|
public bool IsMega { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Moves"/>
|
||||||
public SerializedMoves Moves { get; set; } = null!;
|
public SerializedMoves Moves { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IForm.Flags"/>
|
||||||
public string[] Flags { get; set; } = [];
|
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
|
public class SerializedEvolution
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.Species.IEvolution.ToSpecies"/>
|
||||||
public string Species { get; set; } = null!;
|
public string Species { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The method of evolution.
|
||||||
|
/// </summary>
|
||||||
public string Method { get; set; } = null!;
|
public string Method { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Additional data for the evolution method.
|
||||||
|
/// </summary>
|
||||||
public JsonNode Data { get; set; } = null!;
|
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; }
|
public ushort Hp { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Attack"/>
|
||||||
public ushort Attack { get; set; }
|
public ushort Attack { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Defense"/>
|
||||||
public ushort Defense { get; set; }
|
public ushort Defense { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.SpecialAttack"/>
|
||||||
public ushort SpecialAttack { get; set; }
|
public ushort SpecialAttack { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.SpecialDefense"/>
|
||||||
public ushort SpecialDefense { get; set; }
|
public ushort SpecialDefense { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="PkmnLib.Static.ImmutableStatisticSet{T}.Speed"/>
|
||||||
public ushort Speed { get; set; }
|
public ushort Speed { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a serialized level move.
|
||||||
|
/// </summary>
|
||||||
public class SerializedLevelMove
|
public class SerializedLevelMove
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the move.
|
||||||
|
/// </summary>
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The level at which the move is learned.
|
||||||
|
/// </summary>
|
||||||
public uint Level { get; set; }
|
public uint Level { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a serialized set of moves a Pokémon can learn.
|
||||||
|
/// </summary>
|
||||||
public class SerializedMoves
|
public class SerializedMoves
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The moves the Pokémon can learn by leveling up.
|
||||||
|
/// </summary>
|
||||||
public SerializedLevelMove[]? LevelMoves { get; set; } = null!;
|
public SerializedLevelMove[]? LevelMoves { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The moves the Pokémon can learn by breeding.
|
||||||
|
/// </summary>
|
||||||
public string[]? EggMoves { get; set; } = null!;
|
public string[]? EggMoves { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The moves the Pokémon can learn by tutoring.
|
||||||
|
/// </summary>
|
||||||
public string[]? TutorMoves { get; set; } = null!;
|
public string[]? TutorMoves { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The moves the Pokémon can learn by TM.
|
||||||
|
/// </summary>
|
||||||
public string[]? Machine { get; set; } = null!;
|
public string[]? Machine { get; set; } = null!;
|
||||||
}
|
}
|
@ -9,8 +9,14 @@ using PkmnLib.Static.Utils;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads move data from a JSON file.
|
||||||
|
/// </summary>
|
||||||
public static class MoveDataLoader
|
public static class MoveDataLoader
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Loads move data from a stream.
|
||||||
|
/// </summary>
|
||||||
public static MoveLibrary LoadMoves(Stream stream, TypeLibrary typeLibrary,
|
public static MoveLibrary LoadMoves(Stream stream, TypeLibrary typeLibrary,
|
||||||
Action<SerializedMoveDataWrapper>? onAfterLoad = null)
|
Action<SerializedMoveDataWrapper>? onAfterLoad = null)
|
||||||
{
|
{
|
||||||
@ -25,14 +31,20 @@ public static class MoveDataLoader
|
|||||||
return library;
|
return library;
|
||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
/// <summary>
|
||||||
public static
|
/// Factory delegate for creating moves.
|
||||||
Func<SerializedMove, StringKey, TypeIdentifier, MoveCategory, byte, byte, byte, MoveTarget, sbyte,
|
/// </summary>
|
||||||
ISecondaryEffect?
|
public delegate MoveDataImpl MoveFactoryDelegate(SerializedMove serialized, StringKey name, TypeIdentifier type,
|
||||||
, IEnumerable<StringKey>, MoveDataImpl> MoveConstructor =
|
MoveCategory category, byte basePower, byte accuracy, byte pp, MoveTarget target, sbyte priority,
|
||||||
(_, name, moveType, category, basePower, accuracy, baseUsages, target, priority, secondaryEffect, flags) =>
|
ISecondaryEffect? secondaryEffect, IEnumerable<StringKey> flags);
|
||||||
new MoveDataImpl(name, moveType, category, basePower, accuracy, baseUsages, target, priority,
|
|
||||||
secondaryEffect, 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);
|
||||||
|
|
||||||
private static MoveDataImpl DeserializeMove(SerializedMove serialized, TypeLibrary typeLibrary)
|
private static MoveDataImpl DeserializeMove(SerializedMove serialized, TypeLibrary typeLibrary)
|
||||||
{
|
{
|
||||||
|
@ -3,10 +3,16 @@ using PkmnLib.Static.Libraries;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads nature data from a CSV file.
|
||||||
|
/// </summary>
|
||||||
public static class NatureDataLoader
|
public static class NatureDataLoader
|
||||||
{
|
{
|
||||||
private static readonly char[] CommonCsvDelimiters = ['|', ','];
|
private static readonly char[] CommonCsvDelimiters = ['|', ','];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the nature library from a CSV file.
|
||||||
|
/// </summary>
|
||||||
public static NatureLibrary LoadNatureLibrary(Stream stream)
|
public static NatureLibrary LoadNatureLibrary(Stream stream)
|
||||||
{
|
{
|
||||||
var library = new NatureLibrary();
|
var library = new NatureLibrary();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
using PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||||
using PkmnLib.Static;
|
using PkmnLib.Static;
|
||||||
using PkmnLib.Static.Libraries;
|
using PkmnLib.Static.Libraries;
|
||||||
@ -9,6 +10,9 @@ using PkmnLib.Static.Utils;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads species data from a JSON file.
|
||||||
|
/// </summary>
|
||||||
public static class SpeciesDataLoader
|
public static class SpeciesDataLoader
|
||||||
{
|
{
|
||||||
private static Dictionary<string, SerializedSpecies> LoadSpeciesData(Stream stream)
|
private static Dictionary<string, SerializedSpecies> LoadSpeciesData(Stream stream)
|
||||||
@ -20,6 +24,9 @@ public static class SpeciesDataLoader
|
|||||||
x => x.Value.Deserialize<SerializedSpecies>(JsonOptions.DefaultOptions))!;
|
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,
|
public static SpeciesLibrary LoadSpecies(Stream stream, IReadOnlyTypeLibrary typeLibrary,
|
||||||
Action<Dictionary<string, SerializedSpecies>>? action = null)
|
Action<Dictionary<string, SerializedSpecies>>? action = null)
|
||||||
{
|
{
|
||||||
@ -34,14 +41,21 @@ public static class SpeciesDataLoader
|
|||||||
return library;
|
return library;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static
|
/// <summary>
|
||||||
Func<SerializedSpecies, ushort, StringKey, float, StringKey, byte, byte, IReadOnlyDictionary<StringKey, IForm>,
|
/// Factory delegate for creating species.
|
||||||
IEnumerable<StringKey>, IReadOnlyList<IEvolution>, IEnumerable<StringKey>, SpeciesImpl> SpeciesConstructor =
|
/// </summary>
|
||||||
(_, id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, evolutionData, eggGroups) =>
|
public delegate SpeciesImpl SpeciesFactoryDelegate(SerializedSpecies serialized, ushort id, StringKey name,
|
||||||
{
|
float genderRate, StringKey growthRate, byte captureRate, byte baseHappiness,
|
||||||
return new SpeciesImpl(id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags,
|
IReadOnlyDictionary<StringKey, IForm> forms, IEnumerable<StringKey> flags,
|
||||||
evolutionData, eggGroups);
|
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) =>
|
||||||
|
new SpeciesImpl(id, name, genderRate, growthRate, captureRate, baseHappiness, forms, flags, evolutionData,
|
||||||
|
eggGroups);
|
||||||
|
|
||||||
private static SpeciesImpl DeserializeSpecies(SerializedSpecies serialized, IReadOnlyTypeLibrary typeLibrary)
|
private static SpeciesImpl DeserializeSpecies(SerializedSpecies serialized, IReadOnlyTypeLibrary typeLibrary)
|
||||||
{
|
{
|
||||||
|
@ -2,10 +2,16 @@ using PkmnLib.Static.Libraries;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
namespace PkmnLib.Dynamic.Libraries.DataLoaders;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads type data from a CSV file.
|
||||||
|
/// </summary>
|
||||||
public static class TypeDataLoader
|
public static class TypeDataLoader
|
||||||
{
|
{
|
||||||
private static readonly char[] CommonCsvDelimiters = ['|', ','];
|
private static readonly char[] CommonCsvDelimiters = ['|', ','];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the type library from a CSV file.
|
||||||
|
/// </summary>
|
||||||
public static TypeLibrary LoadTypeLibrary(Stream stream)
|
public static TypeLibrary LoadTypeLibrary(Stream stream)
|
||||||
{
|
{
|
||||||
var library = new TypeLibrary();
|
var library = new TypeLibrary();
|
||||||
|
@ -54,8 +54,8 @@ public class DynamicLibraryImpl : IDynamicLibrary
|
|||||||
{
|
{
|
||||||
var load = LibraryLoader.LoadPlugins(plugins);
|
var load = LibraryLoader.LoadPlugins(plugins);
|
||||||
|
|
||||||
return new DynamicLibraryImpl(load.staticLibrary, load.registry.BattleStatCalculator!,
|
return new DynamicLibraryImpl(load.StaticLibrary, load.Registry.BattleStatCalculator!,
|
||||||
load.registry.DamageCalculator!, load.registry.MiscLibrary!, load.registry.CaptureLibrary!, load.resolver);
|
load.Registry.DamageCalculator!, load.Registry.MiscLibrary!, load.Registry.CaptureLibrary!, load.Resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamicLibraryImpl(IStaticLibrary staticLibrary, IBattleStatCalculator statCalculator,
|
private DynamicLibraryImpl(IStaticLibrary staticLibrary, IBattleStatCalculator statCalculator,
|
||||||
|
@ -5,10 +5,19 @@ using PkmnLib.Static.Libraries;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Libraries;
|
namespace PkmnLib.Dynamic.Libraries;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for building data from plugins.
|
||||||
|
/// </summary>
|
||||||
public static class LibraryLoader
|
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)
|
public static LoadResult LoadPlugins(IEnumerable<Plugin> plugins)
|
||||||
{
|
{
|
||||||
var registry = new ScriptRegistry();
|
var registry = new ScriptRegistry();
|
||||||
|
@ -132,6 +132,9 @@ public class BattleChoiceQueue : IDeepCloneable
|
|||||||
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) =>
|
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) =>
|
||||||
_choices.Skip(_currentIndex).WhereNotNull().FirstOrDefault(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) =>
|
public IEnumerable<ITurnChoice> Where(Func<ITurnChoice, bool> predicate) =>
|
||||||
_choices.Skip(_currentIndex).WhereNotNull().Where(predicate);
|
_choices.Skip(_currentIndex).WhereNotNull().Where(predicate);
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ using PkmnLib.Static.Utils;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.Models.BattleFlow;
|
namespace PkmnLib.Dynamic.Models.BattleFlow;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for executing moves.
|
||||||
|
/// </summary>
|
||||||
public static class MoveTurnExecutor
|
public static class MoveTurnExecutor
|
||||||
{
|
{
|
||||||
internal static void ExecuteMoveChoice(IBattle battle, IMoveChoice moveChoice)
|
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)
|
public static void ExecuteMove(IExecutingMove executingMove)
|
||||||
{
|
{
|
||||||
var stopped = false;
|
var stopped = false;
|
||||||
|
@ -3,11 +3,33 @@ using PkmnLib.Static;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for plugins that can mutate data.
|
||||||
|
/// </summary>
|
||||||
public interface IPluginDataMutator
|
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);
|
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);
|
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);
|
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);
|
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);
|
void MutateSpeciesData(Dictionary<string, SerializedSpecies> data);
|
||||||
}
|
}
|
@ -2,27 +2,64 @@ using PkmnLib.Static.Libraries;
|
|||||||
|
|
||||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for plugins that provide resources.
|
||||||
|
/// </summary>
|
||||||
public interface IResourceProvider
|
public interface IResourceProvider
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The settings for the library. This is used to configure the library and its resources.
|
||||||
|
/// </summary>
|
||||||
LibrarySettings? Settings { get; }
|
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);
|
Stream? GetResource(ResourceFileType request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enum for the different types of resources that can be loaded.
|
||||||
|
/// </summary>
|
||||||
public enum ResourceFileType
|
public enum ResourceFileType
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Unknown type. This is used for errors and should not be used in normal code.
|
||||||
|
/// </summary>
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the types of Pokémon. This includes the type effectiveness chart and the type names.
|
||||||
|
/// </summary>
|
||||||
Types,
|
Types,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the natures of Pokémon. This includes the nature names and the nature effects.
|
||||||
|
/// </summary>
|
||||||
Natures,
|
Natures,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the moves of Pokémon. This includes the move names and the move effects.
|
||||||
|
/// </summary>
|
||||||
Moves,
|
Moves,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the items of Pokémon. This includes the item names and the item effects.
|
||||||
|
/// </summary>
|
||||||
Items,
|
Items,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the abilities of Pokémon. This includes the ability names and the ability effects.
|
||||||
|
/// </summary>
|
||||||
Abilities,
|
Abilities,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the growth rates of Pokémon. This includes the growth rate names and the growth rate effects.
|
||||||
|
/// </summary>
|
||||||
GrowthRates,
|
GrowthRates,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type for the species of Pokémon. This includes the species names and the species effects.
|
||||||
|
/// </summary>
|
||||||
Species,
|
Species,
|
||||||
}
|
}
|
@ -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)
|
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)
|
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)
|
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)
|
public virtual void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||||
using PkmnLib.Static.Utils;
|
using PkmnLib.Static.Utils;
|
||||||
|
|
||||||
@ -85,6 +84,7 @@ public class ScriptSet : IScriptSet
|
|||||||
|
|
||||||
private readonly List<ScriptContainer> _scripts = [];
|
private readonly List<ScriptContainer> _scripts = [];
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IScriptSet"/>
|
||||||
public ScriptSet(IScriptSource source)
|
public ScriptSet(IScriptSource source)
|
||||||
{
|
{
|
||||||
_source = source;
|
_source = source;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using System.Text.Json.Nodes;
|
|
||||||
using PkmnLib.Dynamic.Libraries;
|
using PkmnLib.Dynamic.Libraries;
|
||||||
using PkmnLib.Dynamic.ScriptHandling;
|
using PkmnLib.Dynamic.ScriptHandling;
|
||||||
using PkmnLib.Static.Moves;
|
using PkmnLib.Static.Moves;
|
||||||
using PkmnLib.Tests.Integration;
|
using PkmnLib.Tests.Integration;
|
||||||
using TUnit.Core.Logging;
|
|
||||||
|
|
||||||
namespace PkmnLib.Tests.DataTests;
|
namespace PkmnLib.Tests.DataTests;
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using PkmnLib.Dynamic.Libraries;
|
using PkmnLib.Dynamic.Libraries;
|
||||||
using PkmnLib.Dynamic.Libraries.DataLoaders;
|
|
||||||
using PkmnLib.Plugin.Gen7;
|
using PkmnLib.Plugin.Gen7;
|
||||||
using PkmnLib.Static.Libraries;
|
|
||||||
|
|
||||||
namespace PkmnLib.Tests.Integration;
|
namespace PkmnLib.Tests.Integration;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using PkmnLib.Dynamic.Models;
|
using PkmnLib.Dynamic.Models;
|
||||||
using PkmnLib.Dynamic.ScriptHandling;
|
using PkmnLib.Dynamic.ScriptHandling;
|
||||||
using PkmnLib.Plugin.Gen7.Libraries;
|
|
||||||
using PkmnLib.Plugin.Gen7.Libraries.Battling;
|
using PkmnLib.Plugin.Gen7.Libraries.Battling;
|
||||||
using PkmnLib.Static;
|
using PkmnLib.Static;
|
||||||
using PkmnLib.Static.Moves;
|
using PkmnLib.Static.Moves;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using PkmnLib.Plugin.Gen7.Libraries;
|
|
||||||
using PkmnLib.Plugin.Gen7.Libraries.Battling;
|
using PkmnLib.Plugin.Gen7.Libraries.Battling;
|
||||||
using PkmnLib.Static.Libraries;
|
using PkmnLib.Static.Libraries;
|
||||||
|
|
||||||
@ -44,7 +42,7 @@ public class Gen7Plugin : Dynamic.ScriptHandling.Registry.Plugin, IResourceProvi
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public LibrarySettings? Settings => new()
|
public LibrarySettings Settings => new()
|
||||||
{
|
{
|
||||||
MaxLevel = 100,
|
MaxLevel = 100,
|
||||||
ShinyRate = 4096,
|
ShinyRate = 4096,
|
||||||
|
@ -28,7 +28,6 @@ public class FlameWheel : Script
|
|||||||
move.User.ClearStatus();
|
move.User.ClearStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
var burnChance = _burnChance;
|
|
||||||
if (move.Battle.Random.EffectChance(_burnChance, move, target, hit))
|
if (move.Battle.Random.EffectChance(_burnChance, move, target, hit))
|
||||||
{
|
{
|
||||||
target.SetStatus("burned");
|
target.SetStatus("burned");
|
||||||
|
@ -18,7 +18,6 @@ public class Spite : Script
|
|||||||
if (!lastMoveChoiceByTarget.ChosenMove.ReduceUses(4))
|
if (!lastMoveChoiceByTarget.ChosenMove.ReduceUses(4))
|
||||||
{
|
{
|
||||||
move.GetHitData(target, hit).Fail();
|
move.GetHitData(target, hit).Fail();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using PkmnLib.Static.Utils;
|
|
||||||
|
|
||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Status;
|
|||||||
public class Sleep : Script
|
public class Sleep : Script
|
||||||
{
|
{
|
||||||
public int Turns { get; set; }
|
public int Turns { get; set; }
|
||||||
private IPokemon? _owner;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAddedToParent(IScriptSource source)
|
public override void OnAddedToParent(IScriptSource source)
|
||||||
@ -18,7 +17,6 @@ public class Sleep : Script
|
|||||||
return;
|
return;
|
||||||
if (source is not IPokemon pokemon)
|
if (source is not IPokemon pokemon)
|
||||||
throw new InvalidOperationException("Sleep script can only be added to a Pokemon.");
|
throw new InvalidOperationException("Sleep script can only be added to a Pokemon.");
|
||||||
_owner = pokemon;
|
|
||||||
var battleData = pokemon.BattleData;
|
var battleData = pokemon.BattleData;
|
||||||
if (battleData != null)
|
if (battleData != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user