Update to latest version of pkmnLib.

This commit is contained in:
Deukhoofd 2021-11-27 11:27:19 +01:00
parent d542e75cd1
commit 382cbf2673
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
46 changed files with 642 additions and 342 deletions

View File

@ -106,10 +106,10 @@ namespace PkmnLibSharp.Battling
}
else
{
AbilityIndex = forme!.Abilities.IndexOf(Ability);
AbilityIndex = forme!.Abilities.IndexOf(ability => ability!.Name == Ability);
if (AbilityIndex == -1)
{
AbilityIndex = forme.HiddenAbilities.IndexOf(Ability);
AbilityIndex = forme.HiddenAbilities.IndexOf(ability => ability!.Name == Ability);
if (AbilityIndex == -1)
{
throw new Exception(

View File

@ -212,7 +212,7 @@ namespace Creaturelib.Generated
internal static extern byte GetRealTalentIndex(IntPtr p);
/// <param name="p">const Creature *</param>
/// <param name="out">const char * &</param>
/// <param name="out">const Talent * &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetActiveTalent")]
internal static extern byte GetActiveTalent(IntPtr p, ref IntPtr @out);

View File

@ -7,5 +7,6 @@ namespace Creaturelib
internal enum DamageSource : byte
{
AttackDamage = 0,
Misc = 1,
}
}

View File

@ -13,9 +13,10 @@ namespace Creaturelib.Generated
/// <param name="items">ItemLibrary *</param>
/// <param name="growthRates">GrowthRateLibrary *</param>
/// <param name="typeLibrary">TypeLibrary *</param>
/// <param name="talentLibrary">TalentLibrary *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_DataLibrary_Construct")]
internal static extern byte Construct(ref IntPtr @out, IntPtr settings, IntPtr species, IntPtr attacks, IntPtr items, IntPtr growthRates, IntPtr typeLibrary);
internal static extern byte Construct(ref IntPtr @out, IntPtr settings, IntPtr species, IntPtr attacks, IntPtr items, IntPtr growthRates, IntPtr typeLibrary, IntPtr talentLibrary);
/// <param name="p">const DataLibrary *</param>
/// <returns>void</returns>
@ -52,5 +53,10 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_DataLibrary_GetTypeLibrary")]
internal static extern IntPtr GetTypeLibrary(IntPtr p);
/// <param name="p">const DataLibrary *</param>
/// <returns>const TalentLibrary *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_DataLibrary_GetTalentLibrary")]
internal static extern IntPtr GetTalentLibrary(IntPtr p);
}
}

View File

@ -18,9 +18,9 @@ namespace Creaturelib.Generated
/// <param name="baseMagicalAttack">unsigned short</param>
/// <param name="baseMagicalDefense">unsigned short</param>
/// <param name="baseSpeed">unsigned short</param>
/// <param name="talents">const char * *</param>
/// <param name="talents">const Talent * *</param>
/// <param name="talentsLength">long unsigned int</param>
/// <param name="secretTalents">const char * *</param>
/// <param name="secretTalents">const Talent * *</param>
/// <param name="secretTalentsLength">long unsigned int</param>
/// <param name="attacks">const LearnableAttacks *</param>
/// <param name="flags">const char * *</param>
@ -84,7 +84,7 @@ namespace Creaturelib.Generated
/// <param name="p">SpeciesVariant *</param>
/// <param name="secret">bool</param>
/// <param name="index">unsigned char</param>
/// <param name="out">const char * &</param>
/// <param name="out">const Talent * &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_GetTalent")]
internal static extern byte GetTalent(IntPtr p, byte secret, byte index, ref IntPtr @out);

View File

@ -0,0 +1,33 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class Talent
{
/// <param name="name">const char *</param>
/// <param name="effect">const char *</param>
/// <param name="effectParameters">EffectParameter * *</param>
/// <param name="effectParameterCount">long unsigned int</param>
/// <returns>Talent *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Talent_Construct")]
internal static extern IntPtr Construct(IntPtr name, IntPtr effect, IntPtr effectParameters, ulong effectParameterCount);
/// <param name="p">const Talent *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Talent_Destruct")]
internal static extern void Destruct(IntPtr p);
/// <param name="talent">const Talent *</param>
/// <returns>const char *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Talent_GetName")]
internal static extern IntPtr GetName(IntPtr talent);
/// <param name="talent">const Talent *</param>
/// <returns>const char *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Talent_GetEffect")]
internal static extern IntPtr GetEffect(IntPtr talent);
}
}

View File

@ -0,0 +1,87 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class TalentLibrary
{
/// <param name="library">TalentLibrary * &</param>
/// <param name="initialCapacity">long unsigned int</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_Construct")]
internal static extern byte Construct(ref IntPtr library, ulong initialCapacity);
/// <param name="p">const TalentLibrary *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_Destruct")]
internal static extern void Destruct(IntPtr p);
/// <param name="p">TalentLibrary *</param>
/// <param name="name">const char *</param>
/// <param name="t">Talent *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_Insert")]
internal static extern byte Insert(IntPtr p, IntPtr name, IntPtr t);
/// <param name="p">TalentLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
/// <param name="t">Talent *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_InsertWithHash")]
internal static extern byte InsertWithHash(IntPtr p, uint hashedKey, IntPtr t);
/// <param name="p">TalentLibrary *</param>
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_Delete")]
internal static extern byte Delete(IntPtr p, IntPtr name);
/// <param name="p">TalentLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_DeleteWithHash")]
internal static extern byte DeleteWithHash(IntPtr p, uint hashedKey);
/// <param name="p">TalentLibrary *</param>
/// <param name="name">const char *</param>
/// <param name="out">const Talent * &</param>
/// <returns>bool</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_TryGet")]
internal static extern byte TryGet(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">TalentLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
/// <param name="out">const Talent * &</param>
/// <returns>bool</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_TryGetWithHash")]
internal static extern byte TryGetWithHash(IntPtr p, uint hashedKey, ref IntPtr @out);
/// <param name="p">TalentLibrary *</param>
/// <param name="name">const char *</param>
/// <param name="out">const Talent * &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_Get")]
internal static extern byte Get(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">TalentLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
/// <param name="out">const Talent * &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_GetWithHash")]
internal static extern byte GetWithHash(IntPtr p, uint hashedKey, ref IntPtr @out);
/// <param name="p">TalentLibrary *</param>
/// <returns>long unsigned int</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_GetCount")]
internal static extern ulong GetCount(IntPtr p);
/// <param name="p">TalentLibrary *</param>
/// <param name="index">long unsigned int</param>
/// <param name="out">const Talent * &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TalentLibrary_GetAtIndex")]
internal static extern byte GetAtIndex(IntPtr p, ulong index, ref IntPtr @out);
}
}

View File

@ -7,5 +7,6 @@ namespace Pkmnlib
internal enum DamageSource : byte
{
AttackDamage = 0,
Misc = 1,
}
}

View File

@ -1,15 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum METADATATYPE : int
{
MDT_TYPE = 1,
MDT_FUNC = 2,
MDT_VAR = 3,
MDT_VIRTPROP = 4,
MDT_FUNC_OR_VAR = 5,
}
}

View File

@ -6,6 +6,6 @@ namespace Pkmnlib
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum PkmnDamageSource : byte
{
Struggle = 1,
Struggle = 2,
}
}

View File

@ -18,9 +18,9 @@ namespace Pkmnlib.Generated
/// <param name="baseMagicalAttack">unsigned short</param>
/// <param name="baseMagicalDefense">unsigned short</param>
/// <param name="baseSpeed">unsigned short</param>
/// <param name="talents">const char * *</param>
/// <param name="talents">const Talent * *</param>
/// <param name="talentsLength">long unsigned int</param>
/// <param name="secretTalents">const char * *</param>
/// <param name="secretTalents">const Talent * *</param>
/// <param name="secretTalentsLength">long unsigned int</param>
/// <param name="attacks">const LearnableMoves *</param>
/// <param name="flags">const char * *</param>

View File

@ -13,10 +13,11 @@ namespace Pkmnlib.Generated
/// <param name="items">ItemLibrary *</param>
/// <param name="growthRates">GrowthRateLibrary *</param>
/// <param name="typeLibrary">TypeLibrary *</param>
/// <param name="talentLibrary">TalentLibrary *</param>
/// <param name="natures">NatureLibrary *</param>
/// <returns>unsigned char</returns>
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_PokemonLibrary_Construct")]
internal static extern byte Construct(ref IntPtr @out, IntPtr settings, IntPtr species, IntPtr moves, IntPtr items, IntPtr growthRates, IntPtr typeLibrary, IntPtr natures);
internal static extern byte Construct(ref IntPtr @out, IntPtr settings, IntPtr species, IntPtr moves, IntPtr items, IntPtr growthRates, IntPtr typeLibrary, IntPtr talentLibrary, IntPtr natures);
/// <param name="p">const PokemonLibrary *</param>
/// <returns>void</returns>

View File

@ -1,23 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum error_type : int
{
_S_error_collate = 0,
_S_error_ctype = 1,
_S_error_escape = 2,
_S_error_backref = 3,
_S_error_brack = 4,
_S_error_paren = 5,
_S_error_brace = 6,
_S_error_badbrace = 7,
_S_error_range = 8,
_S_error_space = 9,
_S_error_badrepeat = 10,
_S_error_complexity = 11,
_S_error_stack = 12,
}
}

View File

@ -1,20 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum file_type : byte
{
not_found = 255,
none = 0,
regular = 1,
directory = 2,
symlink = 3,
block = 4,
character = 5,
fifo = 6,
socket = 7,
unknown = 8,
}
}

View File

@ -1,13 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum format : byte
{
native_format = 0,
generic_format = 1,
auto_format = 2,
}
}

View File

@ -1,10 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum match_flag_type : int
{
}
}

View File

@ -1,29 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum perms : int
{
none = 0,
others_exec = 1,
others_write = 2,
others_read = 4,
others_all = 7,
group_exec = 8,
group_write = 16,
group_read = 32,
group_all = 56,
owner_exec = 64,
owner_write = 128,
owner_read = 256,
owner_all = 448,
all = 511,
sticky_bit = 512,
set_gid = 1024,
set_uid = 2048,
mask = 4095,
unknown = 65535,
}
}

View File

@ -1,10 +0,0 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System.Diagnostics.CodeAnalysis;
namespace Pkmnlib
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal enum syntax_option_type : int
{
}
}

View File

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
{
public class AbilityLibrary : PointerWrapper
{
private readonly Dictionary<string, Ability> _cache =
new Dictionary<string, Ability>(StringComparer.InvariantCultureIgnoreCase);
public ulong Count => Creaturelib.Generated.TalentLibrary.GetCount(Ptr);
public void Insert(string key, Ability ability)
{
Creaturelib.Generated.TalentLibrary.Insert(Ptr, key.ToPtr(), ability.Ptr).Assert();
_cache.Add(key, ability);
}
public void Delete(string key)
{
Creaturelib.Generated.TalentLibrary.Delete(Ptr, key.ToPtr()).Assert();
_cache.Remove(key);
}
public bool TryGet(string key, out Ability? ability)
{
if (_cache.TryGetValue(key, out ability))
return true;
var ptr = IntPtr.Zero;
if (Creaturelib.Generated.TalentLibrary.TryGet(Ptr, key.ToPtr(), ref ptr) != MarshalHelper.True)
return false;
if (TryResolvePointer(ptr, out ability))
{
_cache.Add(key, ability!);
return true;
}
ability = Constructor.Active.ConstructAbility(ptr)!;
_cache.Add(key, ability);
return true;
}
public Ability Get(string key)
{
if (_cache.TryGetValue(key, out var ability))
return ability;
var ptr = IntPtr.Zero;
Creaturelib.Generated.TalentLibrary.Get(Ptr, key.ToPtr(), ref ptr).Assert();
if (TryResolvePointer(ptr, out Ability? s))
{
_cache.Add(key, s!);
return s!;
}
ability = Constructor.Active.ConstructAbility(ptr)!;
_cache.Add(key, ability);
return ability;
}
public IEnumerable<Ability> GetEnumerator()
{
var count = Creaturelib.Generated.TalentLibrary.GetCount(Ptr);
var ptr = IntPtr.Zero;
for (ulong i = 0; i < count; i++)
{
Creaturelib.Generated.TalentLibrary.GetAtIndex(Ptr, i, ref ptr).Assert();
if (TryResolvePointer(ptr, out Ability? ability))
yield return ability!;
else
yield return Constructor.Active.ConstructAbility(ptr)!;
}
}
internal AbilityLibrary(IntPtr ptr) : base(ptr)
{
}
public AbilityLibrary(ulong initialCapacity) : base()
{
var ptr = IntPtr.Zero;
Creaturelib.Generated.TalentLibrary.Construct(ref ptr, initialCapacity).Assert();
Initialize(ptr);
}
protected override void DeletePtr()
{
Creaturelib.Generated.TalentLibrary.Destruct(Ptr);
}
protected internal override void MarkAsDeleted()
{
base.MarkAsDeleted();
foreach (var ability in _cache)
{
ability.Value.MarkAsDeleted();
}
}
}
}

View File

@ -99,6 +99,21 @@ namespace PkmnLibSharp.Library
}
}
private AbilityLibrary? _abilityLibrary;
public AbilityLibrary AbilityLibrary
{
get
{
if (_abilityLibrary != null) return _abilityLibrary;
var ptr = DataLibrary.GetTalentLibrary(Ptr);
if (TryResolvePointer(ptr, out _abilityLibrary))
return _abilityLibrary!;
_abilityLibrary = new AbilityLibrary(ptr);
return _abilityLibrary;
}
}
private NatureLibrary? _natureLibrary;
public NatureLibrary NatureLibrary
@ -119,13 +134,12 @@ namespace PkmnLibSharp.Library
{
}
public PokemonLibrary(LibrarySettings settings, SpeciesLibrary species, MoveLibrary moves,
ItemLibrary items,
GrowthRateLibrary growthRates, TypeLibrary types, NatureLibrary natures)
public PokemonLibrary(LibrarySettings settings, SpeciesLibrary species, MoveLibrary moves, ItemLibrary items,
GrowthRateLibrary growthRates, TypeLibrary types, AbilityLibrary abilityLibrary, NatureLibrary natures)
{
var ptr = IntPtr.Zero;
Pkmnlib.Generated.PokemonLibrary.Construct(ref ptr, settings.Ptr, species.Ptr, moves.Ptr, items.Ptr,
growthRates.Ptr, types.Ptr, natures.Ptr).Assert();
growthRates.Ptr, types.Ptr, abilityLibrary.Ptr, natures.Ptr).Assert();
Initialize(ptr);
_settings = settings;
_species = species;

View File

@ -0,0 +1,45 @@
using System.Linq;
using System.Runtime.InteropServices;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
{
public class Ability : PointerWrapper
{
public Ability(string name, string effect, EffectParameter[] parameters)
{
var pars = parameters.Select(x => x.Ptr).ToArray();
Initialize(Creaturelib.Generated.Talent.Construct(name.ToPtr(), effect.ToPtr(), pars.ArrayPtr(), (ulong)pars.Length));
foreach (var intPtr in pars)
Marshal.FreeHGlobal(intPtr);
}
private string? _name;
public string Name
{
get
{
if (_name != null) return _name;
_name = Creaturelib.Generated.Talent.GetName(Ptr).PtrString();
return _name!;
}
}
private string? _effect;
public string Effect
{
get
{
if (_effect != null) return _effect;
_effect = Creaturelib.Generated.Talent.GetEffect(Ptr).PtrString();
return _effect!;
}
}
protected override void DeletePtr()
{
Creaturelib.Generated.Talent.Destruct(Ptr);
}
}
}

View File

@ -11,32 +11,28 @@ namespace PkmnLibSharp.Library
{
public class Forme : PointerWrapper
{
private ReadOnlyArray<string>? _abilities;
private ReadOnlyArray<string>? _hiddenAbilities;
private ReadOnlyArray<Ability>? _abilities;
private ReadOnlyArray<Ability>? _hiddenAbilities;
private LearnableMoves? _moves;
private string? _name;
private ReadOnlyArray<byte>? _types;
public Forme(string name, float height, float weight, uint baseExperience, byte[] types,
ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseSpecialAttack,
ushort baseSpecialDefense, ushort baseSpeed, IReadOnlyCollection<string> abilities,
IReadOnlyCollection<string> hiddenAbilities, LearnableMoves moves, IReadOnlyCollection<string> tags)
public Forme(string name, float height, float weight, uint baseExperience, byte[] types, ushort baseHealth,
ushort baseAttack, ushort baseDefense, ushort baseSpecialAttack, ushort baseSpecialDefense,
ushort baseSpeed, IReadOnlyCollection<Ability> abilities, IReadOnlyCollection<Ability> hiddenAbilities,
LearnableMoves moves, IReadOnlyCollection<string> tags)
{
var abilitiesConverted = abilities.Select(x => x.ToPtr()).ToArray();
var hiddenAbilitiesConverted = hiddenAbilities.Select(x => x.ToPtr()).ToArray();
var abilitiesConverted = abilities.Select(x => x.Ptr).ToArray();
var hiddenAbilitiesConverted = hiddenAbilities.Select(x => x.Ptr).ToArray();
var tagsConverted = tags.Select(x => x.ToPtr()).ToArray();
var ab = abilitiesConverted.ArrayPtr();
var hab = hiddenAbilitiesConverted.ArrayPtr();
var tagsPtr = tagsConverted.ArrayPtr();
var ptr = PokemonForme.Construct(name.ToPtr(), height, weight, baseExperience, types.ArrayPtr(),
(ulong) types.Length, baseHealth, baseAttack, baseDefense, baseSpecialAttack,
baseSpecialDefense, baseSpeed, ab, (ulong) abilities.Count, hab,
(ulong) hiddenAbilities.Count, moves.Ptr, tagsPtr, (ulong) tags.Count);
foreach (var intPtr in abilitiesConverted)
Marshal.FreeHGlobal(intPtr);
foreach (var intPtr in hiddenAbilitiesConverted)
Marshal.FreeHGlobal(intPtr);
(ulong)types.Length, baseHealth, baseAttack, baseDefense, baseSpecialAttack, baseSpecialDefense,
baseSpeed, ab, (ulong)abilities.Count, hab, (ulong)hiddenAbilities.Count, moves.Ptr, tagsPtr,
(ulong)tags.Count);
Initialize(ptr);
}
@ -73,7 +69,7 @@ namespace PkmnLibSharp.Library
public uint BaseSpeed => SpeciesVariant.GetStatistic(Ptr, (Creaturelib.Statistic)Statistic.Speed);
public ReadOnlyArray<string> Abilities
public ReadOnlyArray<Ability> Abilities
{
get
{
@ -81,12 +77,12 @@ namespace PkmnLibSharp.Library
return _abilities;
var abilityCount = SpeciesVariant.GetTalentCount(Ptr);
var abilities = new string[abilityCount];
var abilities = new Ability[abilityCount];
for (byte i = 0; i < abilityCount; i++)
{
var s = IntPtr.Zero;
SpeciesVariant.GetTalent(Ptr, MarshalHelper.False, i, ref s).Assert();
abilities[i] = s.PtrString()!;
abilities[i] = Constructor.Active.ConstructAbility(s)!;
}
_abilities = abilities.ToReadOnly();
@ -94,7 +90,7 @@ namespace PkmnLibSharp.Library
}
}
public ReadOnlyArray<string> HiddenAbilities
public ReadOnlyArray<Ability> HiddenAbilities
{
get
{
@ -102,12 +98,12 @@ namespace PkmnLibSharp.Library
return _hiddenAbilities;
var abilityCount = SpeciesVariant.GetSecretTalentCount(Ptr);
var abilities = new string[abilityCount];
var abilities = new Ability[abilityCount];
for (byte i = 0; i < abilityCount; i++)
{
var s = IntPtr.Zero;
SpeciesVariant.GetTalent(Ptr, MarshalHelper.True, i, ref s).Assert();
abilities[i] = s.PtrString()!;
abilities[i] = Constructor.Active.ConstructAbility(s)!;
}
_hiddenAbilities = abilities.ToReadOnly();

BIN
PkmnLibSharp/Native/Linux/libArbutils.so (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
PkmnLibSharp/Native/Linux/libpkmnLib.so (Stored with Git LFS)

Binary file not shown.

BIN
PkmnLibSharp/Native/Linux/libpkmnlib_ai.so (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
PkmnLibSharp/Native/Windows/libpkmnLib.dll (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@ -20,6 +20,10 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(Filename)%(Extension)</Link>
</Content>
<Content Include="Native\Linux\*.so" Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' ">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(Filename)%(Extension)</Link>
</Content>
<Content Include="Native\Windows\*.dll.*" Condition=" '$(OS)' == 'Windows_NT' ">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(Filename)%(Extension)</Link>

View File

@ -14,21 +14,28 @@ namespace PkmnLibSharp.Utilities
public abstract class Constructor
{
public static Constructor Active { get; set; } =
new Constructor<
Species, Forme, MoveData, Item, LearnableMoves,
Pokemon, Battle, BattleParty, BattleSide, LearnedMove>();
new Constructor<Species, Forme, MoveData, Item, LearnableMoves, Pokemon, Battle, BattleParty, BattleSide,
LearnedMove, Ability>();
internal enum GenericType
{
Species, Forme, MoveData, Item, LearnableMoves, EvolutionData,
Pokemon, Battle,
Species,
Forme,
MoveData,
Item,
LearnableMoves,
EvolutionData,
Pokemon,
Battle,
BattleParty,
BattleSide,
LearnedMove
LearnedMove,
Ability
}
internal abstract Species? ConstructSpecies(IntPtr ptr);
internal abstract Ability? ConstructAbility(IntPtr ptr);
internal abstract Forme? ConstructForme(IntPtr ptr);
internal abstract MoveData? ConstructMove(IntPtr ptr);
internal abstract Item? ConstructItem(IntPtr ptr);
@ -66,26 +73,25 @@ namespace PkmnLibSharp.Utilities
}
public class Constructor<
TSpecies, TForme, TMoveData, TItem, TLearnableMoves,
TPokemon, TBattle, TBattleParty, TBattleSide, TLearnedMove>
: Constructor
where TSpecies : Species
TSpecies, TForme, TMoveData, TItem, TLearnableMoves, TPokemon, TBattle, TBattleParty, TBattleSide, TLearnedMove,
TAbility> : Constructor where TSpecies : Species
where TForme : Forme
where TMoveData : MoveData
where TItem : Item
where TLearnableMoves : LearnableMoves
where TPokemon : Pokemon
where TBattle : Battle
where TBattleParty : BattleParty
where TBattleSide : BattleSide
where TLearnedMove : LearnedMove
where TAbility : Ability
{
private readonly Type _speciesType = typeof(TSpecies);
private readonly Type _formeType = typeof(TForme);
private readonly Type _moveDataType = typeof(TMoveData);
private readonly Type _itemType = typeof(TItem);
private readonly Type _learnableMovesType = typeof(TLearnableMoves);
private readonly Type _abilityType = typeof(TAbility);
private readonly Type _pokemonType = typeof(TPokemon);
private readonly Type _battleType = typeof(TBattle);
@ -106,6 +112,11 @@ namespace PkmnLibSharp.Utilities
return Create<TSpecies>(ptr, _speciesType);
}
internal override Ability? ConstructAbility(IntPtr ptr)
{
return Create<TAbility>(ptr, _abilityType);
}
internal override Forme? ConstructForme(IntPtr ptr)
{
return Create<TForme>(ptr, _formeType);

View File

@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
@ -37,5 +38,19 @@ namespace PkmnLibSharp.Utilities
{
return _arr.IndexOf(item);
}
public int IndexOf(Func<T, bool> predicate)
{
for (var index = 0; index < _arr.Count; index++)
{
var a = _arr[index];
if (predicate(a))
{
return index;
}
}
return -1;
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,6 +23,12 @@ def write_enum(enum, enumNames):
return
if (enum["name"].startswith("as")):
return
if (enum["name"][0] >= 'a' and enum["name"][0] <= 'z'):
return
if (enum["name"] == "EPOLL_EVENTS"):
return;
if (enum["name"] == "METADATATYPE"):
return;
filename = "Generated/{}/{}.cs".format(clean_namespace(namespace), enum["name"])
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, "w") as f:

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"enums":[{"byteSize":4,"filename":"libpkmnlib_ai","name":"memory_order","values":{"0":"relaxed","1":"consume","2":"acquire","3":"release","4":"acq_rel","5":"seq_cst"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"launch","values":{"1":"async","2":"deferred"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"errc","values":{"1":"operation_not_permitted","10":"no_child_process","100":"network_down","101":"network_unreachable","102":"network_reset","103":"connection_aborted","104":"connection_reset","105":"no_buffer_space","106":"already_connected","107":"not_connected","11":"operation_would_block","110":"timed_out","111":"connection_refused","113":"host_unreachable","114":"connection_already_in_progress","115":"operation_in_progress","12":"not_enough_memory","125":"operation_canceled","13":"permission_denied","130":"owner_dead","131":"state_not_recoverable","14":"bad_address","16":"device_or_resource_busy","17":"file_exists","18":"cross_device_link","19":"no_such_device","2":"no_such_file_or_directory","20":"not_a_directory","21":"is_a_directory","22":"invalid_argument","23":"too_many_files_open_in_system","24":"too_many_files_open","25":"inappropriate_io_control_operation","26":"text_file_busy","27":"file_too_large","28":"no_space_on_device","29":"invalid_seek","3":"no_such_process","30":"read_only_file_system","31":"too_many_links","32":"broken_pipe","33":"argument_out_of_domain","34":"result_out_of_range","35":"resource_deadlock_would_occur","36":"filename_too_long","37":"no_lock_available","38":"function_not_supported","39":"directory_not_empty","4":"interrupted","40":"too_many_symbolic_link_levels","42":"no_message","43":"identifier_removed","5":"io_error","6":"no_such_device_or_address","60":"not_a_stream","61":"no_message_available","62":"stream_timeout","63":"no_stream_resources","67":"no_link","7":"argument_list_too_long","71":"protocol_error","74":"bad_message","75":"value_too_large","8":"executable_format_error","84":"illegal_byte_sequence","88":"not_a_socket","89":"destination_address_required","9":"bad_file_descriptor","90":"message_size","91":"wrong_protocol_type","92":"no_protocol_option","93":"protocol_not_supported","95":"not_supported","97":"address_family_not_supported","98":"address_in_use","99":"address_not_available"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"future_errc","values":{"1":"future_already_retrieved","2":"promise_already_satisfied","3":"no_state","4":"broken_promise"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"AttackTarget","values":{"0":"Adjacent","1":"AdjacentAlly","10":"RandomOpponent","11":"Self","2":"AdjacentAllySelf","3":"AdjacentOpponent","4":"All","5":"AllAdjacent","6":"AllAdjacentOpponent","7":"AllAlly","8":"AllOpponent","9":"Any"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"EffectParameterType","values":{"0":"None","1":"Bool","2":"Int","3":"Float","4":"String"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"Statistic","values":{"0":"Health","1":"PhysicalAttack","2":"PhysicalDefense","3":"MagicalAttack","4":"MagicalDefense","5":"Speed"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"TurnChoiceKind","values":{"0":"Pass","1":"Attack","2":"Item","3":"Switch","4":"Flee"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"ScriptCategory","values":{"0":"Attack","1":"Talent","2":"Status","3":"Creature","4":"Battle","5":"Side"}}],"functions":[{"filename":"libpkmnlib_ai","name":"pkmnlibai_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_C_GetLastExceptionStacktrace","parameters":[],"returns":"const char *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_PokemonAI_Delete","parameters":[{"name":"p","type":"PokemonAI *"}],"returns":"void"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_PokemonAI_GetChoice","parameters":[{"name":"out","type":"BaseTurnChoice * &"},{"name":"p","type":"PokemonAI *"},{"name":"battle","type":"Battle *"},{"name":"user","type":"Pokemon *"}],"returns":"unsigned char"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_RandomAI_Create","parameters":[],"returns":"RandomAI *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_NaiveAI_Create","parameters":[],"returns":"NaiveAI *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_DepthSearchAI_Create","parameters":[],"returns":"DepthSearchAI *"}]}
{"enums":[{"byteSize":4,"filename":"libpkmnlib_ai","name":"memory_order","values":{"0":"relaxed","1":"consume","2":"acquire","3":"release","4":"acq_rel","5":"seq_cst"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"launch","values":{"1":"async","2":"deferred"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"errc","values":{"1":"operation_not_permitted","10":"no_child_process","100":"network_down","101":"network_unreachable","102":"network_reset","103":"connection_aborted","104":"connection_reset","105":"no_buffer_space","106":"already_connected","107":"not_connected","11":"operation_would_block","110":"timed_out","111":"connection_refused","113":"host_unreachable","114":"connection_already_in_progress","115":"operation_in_progress","12":"not_enough_memory","125":"operation_canceled","13":"permission_denied","130":"owner_dead","131":"state_not_recoverable","14":"bad_address","16":"device_or_resource_busy","17":"file_exists","18":"cross_device_link","19":"no_such_device","2":"no_such_file_or_directory","20":"not_a_directory","21":"is_a_directory","22":"invalid_argument","23":"too_many_files_open_in_system","24":"too_many_files_open","25":"inappropriate_io_control_operation","26":"text_file_busy","27":"file_too_large","28":"no_space_on_device","29":"invalid_seek","3":"no_such_process","30":"read_only_file_system","31":"too_many_links","32":"broken_pipe","33":"argument_out_of_domain","34":"result_out_of_range","35":"resource_deadlock_would_occur","36":"filename_too_long","37":"no_lock_available","38":"function_not_supported","39":"directory_not_empty","4":"interrupted","40":"too_many_symbolic_link_levels","42":"no_message","43":"identifier_removed","5":"io_error","6":"no_such_device_or_address","60":"not_a_stream","61":"no_message_available","62":"stream_timeout","63":"no_stream_resources","67":"no_link","7":"argument_list_too_long","71":"protocol_error","74":"bad_message","75":"value_too_large","8":"executable_format_error","84":"illegal_byte_sequence","88":"not_a_socket","89":"destination_address_required","9":"bad_file_descriptor","90":"message_size","91":"wrong_protocol_type","92":"no_protocol_option","93":"protocol_not_supported","95":"not_supported","97":"address_family_not_supported","98":"address_in_use","99":"address_not_available"}},{"byteSize":4,"filename":"libpkmnlib_ai","name":"future_errc","values":{"1":"future_already_retrieved","2":"promise_already_satisfied","3":"no_state","4":"broken_promise"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"AttackTarget","values":{"0":"Adjacent","1":"AdjacentAlly","10":"RandomOpponent","11":"Self","2":"AdjacentAllySelf","3":"AdjacentOpponent","4":"All","5":"AllAdjacent","6":"AllAdjacentOpponent","7":"AllAlly","8":"AllOpponent","9":"Any"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"TurnChoiceKind","values":{"0":"Pass","1":"Attack","2":"Item","3":"Switch","4":"Flee"}},{"byteSize":1,"filename":"libpkmnlib_ai","name":"ScriptCategory","values":{"0":"Attack","1":"Talent","2":"Status","3":"Creature","4":"Battle","5":"Side"}}],"functions":[{"filename":"libpkmnlib_ai","name":"pkmnlibai_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_C_GetLastExceptionStacktrace","parameters":[],"returns":"const char *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_PokemonAI_Delete","parameters":[{"name":"p","type":"PokemonAI *"}],"returns":"void"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_PokemonAI_GetChoice","parameters":[{"name":"out","type":"BaseTurnChoice * &"},{"name":"p","type":"PokemonAI *"},{"name":"battle","type":"Battle *"},{"name":"user","type":"Pokemon *"}],"returns":"unsigned char"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_RandomAI_Create","parameters":[],"returns":"RandomAI *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_NaiveAI_Create","parameters":[],"returns":"NaiveAI *"},{"filename":"libpkmnlib_ai","name":"pkmnlibai_DepthSearchAI_Create","parameters":[],"returns":"DepthSearchAI *"}]}

View File

@ -1,3 +1,4 @@
using System;
using System.Linq;
using NUnit.Framework;
using PkmnLibSharp.Battling;
@ -23,8 +24,7 @@ namespace PkmnLibSharpTests.Battling
TestContext.WriteLine("Building battle library");
var scriptLibrary = new AngelScriptResolver();
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
new ExperienceLibrary(),
scriptLibrary, new MiscLibrary(GetTime));
new ExperienceLibrary(), scriptLibrary, new MiscLibrary(GetTime));
scriptLibrary.Initialize(_cache);
return _cache;
}
@ -39,33 +39,42 @@ namespace PkmnLibSharpTests.Battling
{
var settings = new LibrarySettings(100, 4, 4096);
var species = new SpeciesLibrary(10);
species.Insert("testSpecies", new Species(1, "testSpecies",
new Forme("default", 10f, 10f, 100, new byte[] {0, 1}, 100,
100, 100, 100, 100, 100, new[] {"testAbility", "testAbility2"},
new[] {"testHiddenAbility"}, new LearnableMoves(100), new string[0]), 0.5f, "growthRate",
20, 100, new[]{"testEggGroup"}, new string[0]));
var abilities = new AbilityLibrary(10);
var testAbility1 = new Ability("testAbility1", "", Array.Empty<EffectParameter>());
var testAbility2 = new Ability("testAbility2", "", Array.Empty<EffectParameter>());
var testHiddenAbility = new Ability("testHiddenAbility", "", Array.Empty<EffectParameter>());
abilities.Insert("testAbility1", testAbility1);
abilities.Insert("testAbility2", testAbility2);
abilities.Insert("testHiddenAbility", testHiddenAbility);
species.Insert("testSpecies",
new Species(1, "testSpecies",
new Forme("default", 10f, 10f, 100, new byte[] { 0, 1 }, 100, 100, 100, 100, 100, 100,
new[] { testAbility1, testAbility2 }, new[] { testHiddenAbility }, new LearnableMoves(100),
new string[0]), 0.5f, "growthRate", 20, 100, new[] { "testEggGroup" }, new string[0]));
var moves = new MoveLibrary(10);
moves.Insert("testMove", new MoveData("testMove", 0, MoveCategory.Physical, 100,
100, 20, MoveTarget.Any, 0, 0f, "",
moves.Insert("testMove",
new MoveData("testMove", 0, MoveCategory.Physical, 100, 100, 20, MoveTarget.Any, 0, 0f, "",
new EffectParameter[0], new string[0]));
moves.Insert("testMove2", new MoveData("testMove2", 0, MoveCategory.Physical, 100,
100, 20, MoveTarget.Any, 0, 0f, "",
moves.Insert("testMove2",
new MoveData("testMove2", 0, MoveCategory.Physical, 100, 100, 20, MoveTarget.Any, 0, 0f, "",
new EffectParameter[0], new string[0]));
var items = new ItemLibrary(10);
items.Insert("testItem", new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.None,
500, "", new EffectParameter[0], new string[] { }, 20));
items.Insert("testItem",
new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.None, 500, "", new EffectParameter[0],
new string[] { }, 20));
var gr = new GrowthRateLibrary(10);
gr.AddGrowthRate("growthRate",
new LookupGrowthRate(
Enumerable.Range(1, 100).Select(x => (uint)x * 100).ToArray()));
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 = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
return lib;
}
}

View File

@ -1,3 +1,4 @@
using System.Linq;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
@ -51,7 +52,9 @@ namespace PkmnLibSharpTests.Library
{
var p = new EffectParameter(10);
var ex = Assert.Throws<NativeException>(() => { p.AsString(); });
Assert.AreEqual("[CreatureLibLibrary] - '[CreatureLib_EffectParameter_AsString] [EffectParameter.hpp:50] Cast effect parameter to string, but was Int'", ex.Message);
Assert.AreEqual(
"[CreatureLibLibrary] - '[CreatureLib_EffectParameter_AsString] [EffectParameter.hpp:53] \"Cast effect parameter to string, but was Int\"'",
ex.Message.Split('\n').First());
p.Dispose();
}
}

View File

@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
@ -8,16 +9,20 @@ namespace PkmnLibSharpTests.Library
[Test]
public void ConstructDestruct()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
forme.Dispose();
}
[Test]
public void GetName()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual("foo", forme.Name);
forme.Dispose();
}
@ -25,8 +30,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetHeight()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(1f, forme.Height);
forme.Dispose();
}
@ -34,8 +41,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetWeight()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(2f, forme.Weight);
forme.Dispose();
}
@ -43,8 +52,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetBaseExperience()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(100, forme.BaseExperience);
forme.Dispose();
}
@ -52,13 +63,15 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetTypes()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(0, forme.GetPkmnType(0));
forme.Dispose();
forme = new Forme("foo", 1, 2, 100, new byte[] {0, 1}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
forme = new Forme("foo", 1, 2, 100, new byte[] { 0, 1 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(0, forme.GetPkmnType(0));
Assert.AreEqual(1, forme.GetPkmnType(1));
forme.Dispose();
@ -67,8 +80,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetStats()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 20, 30, 40, 50, 60, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 20, 30, 40, 50, 60, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(10, forme.BaseHealth);
Assert.AreEqual(20, forme.BaseAttack);
Assert.AreEqual(30, forme.BaseDefense);
@ -81,20 +96,23 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetAbilities()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
Assert.AreEqual("foo", forme.Abilities[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), Array.Empty<string>());
Assert.AreEqual("foo", forme.Abilities[0].Name);
forme.Dispose();
}
[Test]
public void GetHiddenAbilities()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
Assert.AreEqual("bar", forme.HiddenAbilities[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual("bar", forme.HiddenAbilities[0].Name);
forme.Dispose();
}
}
}

View File

@ -17,9 +17,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
lib.Dispose();
}
@ -32,9 +33,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var s = lib.SpeciesLibrary;
Assert.AreEqual(species, s);
lib.Dispose();
@ -49,9 +51,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var s = lib.Settings;
Assert.AreEqual(settings, s);
lib.Dispose();
@ -66,9 +69,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var m = lib.MoveLibrary;
Assert.AreEqual(moves, m);
lib.Dispose();
@ -83,9 +87,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var i = lib.ItemLibrary;
Assert.AreEqual(items, i);
lib.Dispose();
@ -100,9 +105,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var g = lib.GrowthRateLibrary;
Assert.AreEqual(gr, g);
lib.Dispose();
@ -117,9 +123,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var t = lib.TypeLibrary;
Assert.AreEqual(types, t);
lib.Dispose();
@ -134,13 +141,32 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var n = lib.NatureLibrary;
Assert.AreEqual(natures, n);
lib.Dispose();
}
[Test]
public void GetAbilityLibrary()
{
var settings = new LibrarySettings(100, 4, 4096);
var species = new SpeciesLibrary(10);
var moves = new MoveLibrary(10);
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var a = lib.AbilityLibrary;
Assert.AreEqual(abilities, a);
lib.Dispose();
}
}
}

View File

@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
@ -16,9 +17,13 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Insert()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
@ -28,9 +33,12 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Delete()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
@ -42,27 +50,30 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Get()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
var m = library.Get("foobar");
Assert.AreEqual(m.Name, "testSpecies");
Assert.Throws<NativeException>(() =>
{
library.Get("barfoo");
});
Assert.Throws<NativeException>(() => { library.Get("barfoo"); });
library.Dispose();
}
[Test]
public void TryGet()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
@ -71,6 +82,5 @@ namespace PkmnLibSharpTests.Library
Assert.False(library.TryGet("barfoo", out species));
library.Dispose();
}
}
}

View File

@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
@ -9,105 +10,138 @@ namespace PkmnLibSharpTests.Library
[Test]
public void ConstructDestruct()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
species.Dispose();
}
[Test]
public void GetId()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.AreEqual(10, species.Id);
species.Dispose();
}
[Test]
public void GetGenderRate()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.AreEqual(0.5f, species.GenderRate);
species.Dispose();
}
[Test]
public void GetCaptureRate()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.AreEqual(100, species.CaptureRate);
species.Dispose();
}
[Test]
public void GetName()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.AreEqual("testSpecies", species.Name);
species.Dispose();
}
[Test]
public void GetGrowthRate()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.AreEqual("exponential", species.GrowthRate);
species.Dispose();
}
[Test]
public void HasForme()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.True(species.HasForme("default"));
species.Dispose();
}
[Test]
public void SetForme()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.True(species.HasForme("default"));
forme = new Forme("bar", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
forme = new Forme("bar", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
species.SetForme("bar", forme);
Assert.True(species.HasForme("bar"));
species.Dispose();
}
[Test]
public void GetForme()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
var f = species.GetForme("default");
Assert.AreEqual(forme, f);
Assert.Throws<NativeException>(() =>
{
species.GetForme("non-existing");
});
Assert.Throws<NativeException>(() => { species.GetForme("non-existing"); });
species.Dispose();
}
[Test]
public void TrGetForme()
public void TryGetForme()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
new string[0]);
Assert.True(species.TryGetForme("default", out var f));
Assert.AreEqual(forme, f);
Assert.False(species.TryGetForme("non-existing", out f));
species.Dispose();
}
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
@ -11,9 +11,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="nunit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>