Make moveflags of gen 7 plugin shared statically
This commit is contained in:
@@ -4,7 +4,9 @@ using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Plugins;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Plugin.Gen7.Common;
|
||||
using PkmnLib.Static.Moves;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Tests.DataTests;
|
||||
|
||||
@@ -89,6 +91,26 @@ public class MoveDataTests
|
||||
await Assert.That(test.Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out _)).IsTrue();
|
||||
}
|
||||
|
||||
public static IEnumerable<Func<StringKey>> AllMoveFlagsAreIncludedInMoveFlagsData()
|
||||
{
|
||||
var library = LibraryHelpers.LoadLibrary();
|
||||
var moveLibrary = library.StaticLibrary.Moves;
|
||||
foreach (var flag in moveLibrary.SelectMany(x => x.Flags).Distinct())
|
||||
{
|
||||
yield return () => flag;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly HashSet<StringKey> CompileTimeMoveFlags = typeof(MoveFlags).GetFields()
|
||||
.Where(x => x is { IsStatic: true, IsPublic: true } && x.FieldType == typeof(StringKey))
|
||||
.Select(x => (StringKey)x.GetValue(null)!).ToHashSet();
|
||||
|
||||
[Test, MethodDataSource(nameof(AllMoveFlagsAreIncludedInMoveFlagsData))]
|
||||
public async Task AllMoveFlagsAreIncludedInMoveFlagsClass(StringKey flag)
|
||||
{
|
||||
await Assert.That(CompileTimeMoveFlags.Contains(flag)).IsTrue();
|
||||
}
|
||||
|
||||
public record HasEitherEffectOrComment(string MoveName, bool HasEffect, bool HasComment)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Plugin.Gen7.Common;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
using PkmnLib.Static;
|
||||
@@ -20,7 +21,7 @@ public class MegaLauncherTests
|
||||
var user = Substitute.For<IPokemon>();
|
||||
move.User.Returns(user);
|
||||
move.UseMove.Category.Returns(MoveCategory.Special);
|
||||
move.UseMove.HasFlag("pulse").Returns(true);
|
||||
move.UseMove.HasFlag(MoveFlags.Pulse).Returns(true);
|
||||
var megaLauncher = new ScriptContainer(new MegaLauncher());
|
||||
move.User.AbilityScript.Returns(megaLauncher);
|
||||
move.GetScripts().Returns(new ScriptIterator([megaLauncher]));
|
||||
|
||||
Reference in New Issue
Block a user