Support for Pokemon building.
This commit is contained in:
49
PkmnLibSharpTests/Battling/BattleLibraryHelper.cs
Normal file
49
PkmnLibSharpTests/Battling/BattleLibraryHelper.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Linq;
|
||||
using PkmnLibSharp.Battling;
|
||||
using PkmnLibSharp.Library;
|
||||
using PkmnLibSharp.Library.GrowthRates;
|
||||
using PkmnLibSharp.Library.Items;
|
||||
using PkmnLibSharp.Library.Moves;
|
||||
|
||||
namespace PkmnLibSharpTests.Battling
|
||||
{
|
||||
public static class BattleLibraryHelper
|
||||
{
|
||||
private static BattleLibrary _cache;
|
||||
|
||||
public static BattleLibrary GetLibrary()
|
||||
{
|
||||
if (_cache != null) return _cache;
|
||||
|
||||
_cache = BattleLibrary.Create(BuildStatic(), new StatCalculator(), new DamageLibrary(),
|
||||
new ExperienceLibrary(),
|
||||
new AngelScriptResolver(), new MiscLibrary());
|
||||
return _cache;
|
||||
}
|
||||
|
||||
private static PokemonLibrary BuildStatic()
|
||||
{
|
||||
var settings = new LibrarySettings(100, 4, 4096);
|
||||
var species = new SpeciesLibrary(10);
|
||||
species.Insert("testSpecies", Species.Create(1, "testSpecies",
|
||||
Forme.Create("default", 10f, 10f, 100, new byte[] {0, 1}, 100,
|
||||
100, 100, 100, 100, 100, new[] {"testAbility", "testAbility2"},
|
||||
new[] {"testHiddenAbility"}, LearnableMoves.Create(100)), 0.5f, "growthRate",
|
||||
20, 100));
|
||||
|
||||
var moves = MoveLibrary.Create(10);
|
||||
var items = new ItemLibrary(10);
|
||||
items.Insert("testItem", Item.Create("testItem", ItemCategory.MiscItem, BattleItemCategory.None,
|
||||
500, new string[] { }, 20));
|
||||
var gr = new GrowthRateLibrary(10);
|
||||
gr.AddGrowthRate("growthRate",
|
||||
new LookupGrowthRate(
|
||||
Enumerable.Range(1, 100).Select(x => (uint)x * 100).ToArray()));
|
||||
var types = new TypeLibrary(10);
|
||||
var natures = new NatureLibrary(10);
|
||||
natures.LoadNature("testNature", new Nature());
|
||||
var lib = PokemonLibrary.Create(settings, species, moves, items, gr, types, natures);
|
||||
return lib;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
PkmnLibSharpTests/Battling/PokemonBuilderTests.cs
Normal file
40
PkmnLibSharpTests/Battling/PokemonBuilderTests.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Battling;
|
||||
|
||||
namespace PkmnLibSharpTests.Battling
|
||||
{
|
||||
public class PokemonBuilderTests
|
||||
{
|
||||
[Test]
|
||||
public void SimpleBuildPokemon()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var pokemon = new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.Build();
|
||||
Assert.AreEqual("testSpecies", pokemon.Species.Name);
|
||||
Assert.AreEqual(50, pokemon.Level);
|
||||
Assert.AreEqual("default", pokemon.Forme.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPokemonWithNickname()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var pokemon = new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.WithNickname("cuteNickname")
|
||||
.Build();
|
||||
Assert.AreEqual("cuteNickname", pokemon.Nickname);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPokemonWithGender()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var pokemon = new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.WithGender(Gender.Female)
|
||||
.Build();
|
||||
Assert.AreEqual(Gender.Female, pokemon.Gender);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,10 @@
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
|
||||
<Platforms>x86_64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -16,8 +20,4 @@
|
||||
<ProjectReference Include="..\PkmnLibSharp\PkmnLibSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Battling" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user