129 lines
4.9 KiB
C#
129 lines
4.9 KiB
C#
using System;
|
|
using NUnit.Framework;
|
|
using PkmnLibSharp.DynamicData;
|
|
using PkmnLibSharp.DynamicData.Libraries;
|
|
using PkmnLibSharp.StaticData;
|
|
using PkmnLibSharp.StaticData.Libraries;
|
|
|
|
namespace PkmnLibRSharpTests.DynamicData
|
|
{
|
|
public class PokemonTests
|
|
{
|
|
[Test]
|
|
public void Pokemon_GetLibrary()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(library, pokemon.Library);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetSpecies()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"], pokemon.Species);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetForm()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"].DefaultForm, pokemon.Form);
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void Pokemon_GetDisplaySpecies()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"], pokemon.Species);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetDisplayForm()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"].DefaultForm, pokemon.Form);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetLevel()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(100, pokemon.Level);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetExperience()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
|
Assert.AreEqual(library.StaticData.GrowthRateLibrary.CalculateExperience("testGrowthrate", 100),
|
|
pokemon.Experience);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetUniqueIdentifier()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).WithIdentifier(1000).Build();
|
|
Assert.AreEqual(1000, pokemon.UniqueIdentifier);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetGender()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).WithGender(Gender.Male).Build();
|
|
Assert.AreEqual(Gender.Male, pokemon.Gender);
|
|
}
|
|
|
|
[Test]
|
|
public void Pokemon_GetColoring()
|
|
{
|
|
var library = GetLibrary();
|
|
var pokemon = new PokemonBuilder(library, "testSpecies", 100).ForceShiny(true).Build();
|
|
Assert.AreEqual(1, pokemon.Coloring);
|
|
}
|
|
|
|
private static DynamicLibrary GetLibrary()
|
|
{
|
|
var settings = LibrarySettings.Create(100, 4096);
|
|
var speciesLibrary = SpeciesLibrary.Create(0);
|
|
FillSpeciesLibrary(speciesLibrary);
|
|
var moves = MoveLibrary.Create(0);
|
|
var items = ItemLibrary.Create(0);
|
|
var growthRates = GrowthRateLibrary.Create(0);
|
|
var gr = CommonGrowthRates.Erratic(100);
|
|
growthRates.AddGrowthRate("testGrowthrate", gr);
|
|
var types = TypeLibrary.Create(0);
|
|
var natures = NatureLibrary.Create(0);
|
|
natures.LoadNature("testNature", Nature.NeutralNature());
|
|
var abilities = AbilityLibrary.Create(0);
|
|
var library = PkmnLibSharp.StaticData.Libraries.StaticData.Create(settings, speciesLibrary, moves, items,
|
|
growthRates, types, natures, abilities);
|
|
|
|
var statCalc = Gen7BattleStatCalculator.Create();
|
|
var damageLib = Gen7DamageLibrary.Create(false);
|
|
var miscLib = Gen7MiscLibrary.Create();
|
|
var scriptResolver = WasmScriptResolver.Create();
|
|
|
|
return DynamicLibrary.Create(library, statCalc, damageLib, miscLib, scriptResolver);
|
|
}
|
|
|
|
private static void FillSpeciesLibrary(SpeciesLibrary speciesLibrary)
|
|
{
|
|
var stats = StaticStatisticSet<ushort>.Create(5, 10, 30, 20, 2, 0);
|
|
var moves = LearnableMoves.Create();
|
|
var form = Form.Create("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
|
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
|
var species = Species.Create(10, "testSpecies", 0.2f, "testGrowthrate", 120, form, Array.Empty<string>());
|
|
speciesLibrary.Add(species.Name, species);
|
|
}
|
|
}
|
|
} |