Update PkmnLib to new functionality with capture mechanics
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-03-26 16:46:07 +01:00
parent cb3d3c74a1
commit 36b39ba3c4
28 changed files with 220 additions and 39 deletions

View File

@@ -24,7 +24,7 @@ namespace PkmnLibSharpTests.Battling
TestContext.WriteLine("Building battle library");
var scriptLibrary = new AngelScriptResolver();
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
new ExperienceLibrary(), scriptLibrary, new MiscLibrary(GetTime));
new ExperienceLibrary(), scriptLibrary, new MiscLibrary(GetTime), new CaptureLibrary());
scriptLibrary.Initialize(_cache);
return _cache;
}

View File

@@ -1,6 +1,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using NUnit.Framework;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Utilities;
@@ -14,10 +17,10 @@ namespace PkmnLibSharpTests
[OneTimeSetUp]
public void Init()
{
NativeLibrary.Load("Arbutils", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
NativeLibrary.Load("CreatureLib", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
NativeLibrary.Load("libangelscript.so.2.35.0", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
NativeLibrary.Load("pkmnLib", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
NativeLibrary.SetDllImportResolver(assembly, ImportResolver);
}
LogHandler.RegisterListener((level, s) =>
{
@@ -26,6 +29,14 @@ namespace PkmnLibSharpTests
SignalHandler.SetSignalListener(s => throw new Exception("Encountered a catastrophic signal. \n" + s));
}
private IntPtr ImportResolver(string libraryname, Assembly assembly, DllImportSearchPath? searchpath)
{
var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var assemblyFile = Environment.OSVersion.Platform == PlatformID.Unix
? Path.Join(directory, libraryname + ".so")
: Path.Join(directory, libraryname + ".dll");
return NativeLibrary.Load(assemblyFile);
}
}
}