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;