Updates to latest pkmnlib, fixes issues.

This commit is contained in:
2020-12-23 12:27:58 +01:00
parent 506f10b085
commit 8d5f7f318f
22 changed files with 80 additions and 44 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq;
using NUnit.Framework;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.GrowthRates;
@@ -10,15 +11,23 @@ namespace PkmnLibSharpTests.Battling
public static class BattleLibraryHelper
{
private static BattleLibrary _cache;
private static readonly object Lock = new object();
public static BattleLibrary GetLibrary()
{
if (_cache != null) return _cache;
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
new ExperienceLibrary(),
new AngelScriptResolver(), new MiscLibrary());
return _cache;
lock (Lock)
{
if (_cache != null)
return _cache;
TestContext.WriteLine("Building battle library");
var scriptLibrary = new AngelScriptResolver();
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
new ExperienceLibrary(),
scriptLibrary, new MiscLibrary());
scriptLibrary.Initialize(_cache);
return _cache;
}
}
private static PokemonLibrary BuildStatic()

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Library;
@@ -15,7 +16,7 @@ namespace PkmnLibSharpTests.Battling
protected override Pokemon Finalize(Species species, Forme forme, Item? heldItem, IReadOnlyCollection<LearnedMove> moves, Nature nature)
{
var pkmn = new Pokemon(Library, species, forme!, Level, Experience, Uid, Gender, Coloring,
var pkmn = new Pokemon(Library, species, forme, Level, Experience, Uid, Gender, Coloring,
heldItem, Nickname, HiddenAbility, (byte) AbilityIndex, moves, IVs, EVs, nature);
return pkmn;
}

View File

@@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Library;

View File

@@ -7,13 +7,13 @@
<Configurations>Debug</Configurations>
<Platforms>AnyCPU</Platforms>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>

View File

@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
using NUnit.Framework;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Utilities;
using PkmnLibSharpTests.Battling;
namespace PkmnLibSharpTests
{
@@ -15,8 +16,9 @@ namespace PkmnLibSharpTests
{
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);
LogHandler.RegisterListener((level, s) =>
{
Console.WriteLine($"[{level.ToString().ToUpperInvariant()}] {s}");
@@ -24,5 +26,6 @@ namespace PkmnLibSharpTests
SignalHandler.SetSignalListener(s => throw new Exception("Encountered a catastrophic signal. \n" + s));
}
}
}