Update to latest CreatureLib, more work on battle tests.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Battling;
|
||||
using PkmnLibSharp.Library;
|
||||
using PkmnLibSharp.Library.GrowthRates;
|
||||
@@ -47,6 +48,8 @@ namespace PkmnLibSharpTests.Battling
|
||||
new LookupGrowthRate(
|
||||
Enumerable.Range(1, 100).Select(x => (uint)x * 100).ToArray()));
|
||||
var types = new TypeLibrary(10);
|
||||
types.RegisterType("normal");
|
||||
types.RegisterType("fighting");
|
||||
var natures = new NatureLibrary(10);
|
||||
natures.LoadNature("testNature", new Nature());
|
||||
var lib = PokemonLibrary.Create(settings, species, moves, items, gr, types, natures);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Battling;
|
||||
using PkmnLibSharp.Battling.ChoiceTurn;
|
||||
|
||||
namespace PkmnLibSharpTests.Battling.BattleTests
|
||||
{
|
||||
@@ -21,7 +22,10 @@ namespace PkmnLibSharpTests.Battling.BattleTests
|
||||
private static PokemonParty BuildTestParty(BattleLibrary lib)
|
||||
{
|
||||
var party = new PokemonParty();
|
||||
party.SwapInto(0, new PokemonBuilder(lib, "testSpecies", 50).Build());
|
||||
party.SwapInto(0,
|
||||
new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.LearnMove("testMove", MoveLearnMethod.Unknown)
|
||||
.Build());
|
||||
return party;
|
||||
}
|
||||
|
||||
@@ -29,17 +33,42 @@ namespace PkmnLibSharpTests.Battling.BattleTests
|
||||
public void InitializeBattleWithParties()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var p1 = BuildTestParty(lib);
|
||||
var p2 = BuildTestParty(lib);
|
||||
var battle =
|
||||
new BattleBuilder(lib, true, 2, 1)
|
||||
.WithPartyOnPositions(BuildTestParty(lib), new BattlePosition(0, 0))
|
||||
.WithPartyOnPositions(BuildTestParty(lib), new BattlePosition(1, 0))
|
||||
.WithPartyOnPositions(p1, new BattlePosition(0, 0))
|
||||
.WithPartyOnPositions(p2, new BattlePosition(1, 0))
|
||||
.Build();
|
||||
Assert.AreEqual(lib, battle.Library);
|
||||
Assert.AreEqual(true, battle.CanFlee);
|
||||
Assert.AreEqual(2, battle.SidesCount);
|
||||
Assert.AreEqual(false, battle.HasEnded);
|
||||
Assert.AreEqual(2, battle.PartiesCount);
|
||||
Assert.AreEqual(p1, battle.Parties[0].Party);
|
||||
Assert.AreEqual(p2, battle.Parties[1].Party);
|
||||
battle.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RunTurn()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var p1 = BuildTestParty(lib);
|
||||
var p2 = BuildTestParty(lib);
|
||||
var battle =
|
||||
new BattleBuilder(lib, true, 2, 1)
|
||||
.WithPartyOnPositions(p1, new BattlePosition(0, 0))
|
||||
.WithPartyOnPositions(p2, new BattlePosition(1, 0))
|
||||
.Build();
|
||||
|
||||
battle.SwitchPokemon(0, 0, p1.GetAtIndex(0));
|
||||
battle.SwitchPokemon(1, 0, p2.GetAtIndex(0));
|
||||
|
||||
var moveTurn1 = new MoveTurnChoice(p1.GetAtIndex(0), p1.GetAtIndex(0).Moves[0], 1, 0 );
|
||||
var moveTurn2 = new MoveTurnChoice(p2.GetAtIndex(0), p2.GetAtIndex(0).Moves[0], 0, 0 );
|
||||
|
||||
Assert.That(battle.TrySetChoice(moveTurn1));
|
||||
Assert.That(battle.TrySetChoice(moveTurn2));
|
||||
|
||||
battle.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace PkmnLibSharpTests.Library
|
||||
{
|
||||
var p = new EffectParameter(10);
|
||||
var ex = Assert.Throws<NativeException>(() => { p.AsString(); });
|
||||
Assert.AreEqual("[CreatureLib] - 'Cast effect parameter to string, but was Int'", ex.Message);
|
||||
Assert.AreEqual("[CreatureLibLibrary] - '[CreatureLib_EffectParameter_AsString] [EffectParameter.hpp:54] Cast effect parameter to string, but was Int'", ex.Message);
|
||||
p.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharpTests.Library
|
||||
{
|
||||
public class SpeciesTests
|
||||
public class SpeciesTests
|
||||
{
|
||||
[Test]
|
||||
public void ConstructDestruct()
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<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="System.Runtime.Loader" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
18
PkmnLibSharpTests/TestClass.cs
Normal file
18
PkmnLibSharpTests/TestClass.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace PkmnLibSharpTests
|
||||
{
|
||||
[SetUpFixture]
|
||||
public sealed class TestClass
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public void Init()
|
||||
{
|
||||
NativeLibrary.Load("Arbutils", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
|
||||
NativeLibrary.Load("CreatureLib", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
|
||||
NativeLibrary.Load("pkmnLib", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user