Additional functionality.
This commit is contained in:
parent
12ed340643
commit
e4f8e46102
|
@ -1,11 +1,13 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling
|
||||
{
|
||||
public class PokemonParty : PointerWrapper
|
||||
public class PokemonParty : PointerWrapper, IEnumerable<Pokemon>
|
||||
{
|
||||
private ReadOnlyNativePtrArray<Pokemon>? _party;
|
||||
private ReadOnlyNativePtrArray<Pokemon?>? _party;
|
||||
|
||||
internal PokemonParty(IntPtr ptr) : base(ptr){}
|
||||
|
||||
|
@ -15,6 +17,8 @@ namespace PkmnLibSharp.Battling
|
|||
public PokemonParty(Pokemon[] pokemon) : base(
|
||||
Creaturelib.Generated.CreatureParty.ConstructFromArray(pokemon.ArrayPtr(), (ulong) pokemon.Length))
|
||||
{}
|
||||
|
||||
public virtual Pokemon this[int i] => GetAtIndex((ulong) i);
|
||||
|
||||
public Pokemon GetAtIndex(ulong index)
|
||||
{
|
||||
|
@ -41,19 +45,34 @@ namespace PkmnLibSharp.Battling
|
|||
return Creaturelib.Generated.CreatureParty.HasAvailableCreatures(Ptr) == 1;
|
||||
}
|
||||
|
||||
public ReadOnlyNativePtrArray<Pokemon> Party
|
||||
public ReadOnlyNativePtrArray<Pokemon?> Party
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_party != null) return _party;
|
||||
var ptr = Creaturelib.Generated.CreatureParty.GetParty(Ptr);
|
||||
_party = new ReadOnlyNativePtrArray<Pokemon>(ptr, (int) Length);
|
||||
_party = new ReadOnlyNativePtrArray<Pokemon?>(ptr, (int) Length);
|
||||
return _party;
|
||||
}
|
||||
}
|
||||
|
||||
public ulong Length => Creaturelib.Generated.CreatureParty.GetLength(Ptr);
|
||||
|
||||
public void PackParty()
|
||||
{
|
||||
Creaturelib.Generated.CreatureParty.PackParty(Ptr);
|
||||
}
|
||||
|
||||
public IEnumerator<Pokemon?> GetEnumerator()
|
||||
{
|
||||
return Party.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Creaturelib.Generated.CreatureParty.Destruct(Ptr);
|
||||
|
@ -64,8 +83,11 @@ namespace PkmnLibSharp.Battling
|
|||
base.MarkAsDeleted();
|
||||
foreach (var pokemon in Party)
|
||||
{
|
||||
pokemon.MarkAsDeleted();
|
||||
pokemon?.MarkAsDeleted();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -76,5 +76,12 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackLibrary_GetCount")]
|
||||
internal static extern ulong GetCount(IntPtr p);
|
||||
|
||||
/// <param name="p">AttackLibrary *</param>
|
||||
/// <param name="index">long unsigned int</param>
|
||||
/// <param name="out">const AttackData * &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackLibrary_GetAtIndex")]
|
||||
internal static extern byte GetAtIndex(IntPtr p, ulong index, ref IntPtr @out);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureParty_Switch")]
|
||||
internal static extern byte Switch(IntPtr p, ulong a, ulong b);
|
||||
|
||||
/// <param name="p">CreatureParty *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureParty_PackParty")]
|
||||
internal static extern byte PackParty(IntPtr p);
|
||||
|
||||
/// <param name="p">CreatureParty *</param>
|
||||
/// <param name="index">long unsigned int</param>
|
||||
/// <param name="creature">Creature *</param>
|
||||
|
|
|
@ -13,9 +13,11 @@ namespace Creaturelib.Generated
|
|||
/// <param name="genderRatio">float</param>
|
||||
/// <param name="growthRate">const char *</param>
|
||||
/// <param name="captureRate">unsigned char</param>
|
||||
/// <param name="flags">const char * *</param>
|
||||
/// <param name="flagsCount">long unsigned int</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_Construct")]
|
||||
internal static extern byte Construct(ref IntPtr @out, ushort id, IntPtr name, IntPtr defaultVariant, float genderRatio, IntPtr growthRate, byte captureRate);
|
||||
internal static extern byte Construct(ref IntPtr @out, ushort id, IntPtr name, IntPtr defaultVariant, float genderRatio, IntPtr growthRate, byte captureRate, IntPtr flags, ulong flagsCount);
|
||||
|
||||
/// <param name="p">const CreatureSpecies *</param>
|
||||
/// <returns>void</returns>
|
||||
|
@ -110,5 +112,11 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_GetVariants")]
|
||||
internal static extern IntPtr GetVariants(IntPtr p);
|
||||
|
||||
/// <param name="p">const CreatureSpecies *</param>
|
||||
/// <param name="key">const char *</param>
|
||||
/// <returns>bool</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_HasFlag")]
|
||||
internal static extern byte HasFlag(IntPtr p, IntPtr key);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,5 +75,12 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemLibrary_GetCount")]
|
||||
internal static extern ulong GetCount(IntPtr p);
|
||||
|
||||
/// <param name="p">ItemLibrary *</param>
|
||||
/// <param name="index">long unsigned int</param>
|
||||
/// <param name="out">const Item * &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemLibrary_GetAtIndex")]
|
||||
internal static extern byte GetAtIndex(IntPtr p, ulong index, ref IntPtr @out);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,5 +75,12 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesLibrary_GetCount")]
|
||||
internal static extern ulong GetCount(IntPtr p);
|
||||
|
||||
/// <param name="p">SpeciesLibrary *</param>
|
||||
/// <param name="index">long unsigned int</param>
|
||||
/// <param name="out">const CreatureSpecies * &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesLibrary_GetAtIndex")]
|
||||
internal static extern byte GetAtIndex(IntPtr p, ulong index, ref IntPtr @out);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,11 @@ namespace Creaturelib.Generated
|
|||
/// <param name="secretTalents">const char * *</param>
|
||||
/// <param name="secretTalentsLength">long unsigned int</param>
|
||||
/// <param name="attacks">const LearnableAttacks *</param>
|
||||
/// <param name="flags">const char * *</param>
|
||||
/// <param name="flagsCount">long unsigned int</param>
|
||||
/// <returns>SpeciesVariant *</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_Construct")]
|
||||
internal static extern IntPtr Construct(IntPtr name, float height, float weight, uint baseExperience, IntPtr types, ulong typeLength, ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseMagicalAttack, ushort baseMagicalDefense, ushort baseSpeed, IntPtr talents, ulong talentsLength, IntPtr secretTalents, ulong secretTalentsLength, IntPtr attacks);
|
||||
internal static extern IntPtr Construct(IntPtr name, float height, float weight, uint baseExperience, IntPtr types, ulong typeLength, ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseMagicalAttack, ushort baseMagicalDefense, ushort baseSpeed, IntPtr talents, ulong talentsLength, IntPtr secretTalents, ulong secretTalentsLength, IntPtr attacks, IntPtr flags, ulong flagsCount);
|
||||
|
||||
/// <param name="p">SpeciesVariant *</param>
|
||||
/// <returns>void</returns>
|
||||
|
@ -98,5 +100,11 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_GetRandomTalent")]
|
||||
internal static extern byte GetRandomTalent(IntPtr p, IntPtr rand);
|
||||
|
||||
/// <param name="p">const SpeciesVariant *</param>
|
||||
/// <param name="key">const char *</param>
|
||||
/// <returns>bool</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_HasFlag")]
|
||||
internal static extern byte HasFlag(IntPtr p, IntPtr key);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,11 @@ namespace Pkmnlib.Generated
|
|||
/// <param name="baseHappiness">unsigned char</param>
|
||||
/// <param name="eggGroupsRaw">const const char * *</param>
|
||||
/// <param name="eggGroupsLength">long unsigned int</param>
|
||||
/// <param name="flags">const char * *</param>
|
||||
/// <param name="flagsCount">long unsigned int</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_PokemonSpecies_Construct")]
|
||||
internal static extern byte Construct(ref IntPtr @out, ushort id, IntPtr name, IntPtr defaultForme, float genderRatio, IntPtr growthRate, byte captureRate, byte baseHappiness, IntPtr eggGroupsRaw, ulong eggGroupsLength);
|
||||
internal static extern byte Construct(ref IntPtr @out, ushort id, IntPtr name, IntPtr defaultForme, float genderRatio, IntPtr growthRate, byte captureRate, byte baseHappiness, IntPtr eggGroupsRaw, ulong eggGroupsLength, IntPtr flags, ulong flagsCount);
|
||||
|
||||
/// <param name="p">const PokemonSpecies *</param>
|
||||
/// <returns>void</returns>
|
||||
|
|
|
@ -66,6 +66,19 @@ namespace PkmnLibSharp.Library.Items
|
|||
_cache.Add(key, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public IEnumerable<Item> GetEnumerator()
|
||||
{
|
||||
var count = Creaturelib.Generated.ItemLibrary.GetCount(Ptr);
|
||||
var ptr = IntPtr.Zero;
|
||||
for (ulong i = 0; i < count; i++)
|
||||
{
|
||||
Creaturelib.Generated.ItemLibrary.GetAtIndex(Ptr, i, ref ptr).Assert();
|
||||
if (TryResolvePointer(ptr, out Item? item))
|
||||
yield return item!;
|
||||
yield return new Item(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override void MarkAsDeleted()
|
||||
{
|
||||
|
|
|
@ -69,6 +69,19 @@ namespace PkmnLibSharp.Library.Moves
|
|||
AttackLibrary.Construct(ref ptr, defaultCapacity).Assert();
|
||||
Initialize(ptr);
|
||||
}
|
||||
|
||||
public IEnumerable<MoveData> GetEnumerator()
|
||||
{
|
||||
var count = AttackLibrary.GetCount(Ptr);
|
||||
var ptr = IntPtr.Zero;
|
||||
for (ulong i = 0; i < count; i++)
|
||||
{
|
||||
AttackLibrary.GetAtIndex(Ptr, i, ref ptr).Assert();
|
||||
if (TryResolvePointer(ptr, out MoveData? move))
|
||||
yield return move!;
|
||||
yield return new MoveData(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override void MarkAsDeleted()
|
||||
{
|
||||
|
|
|
@ -19,17 +19,19 @@ namespace PkmnLibSharp.Library
|
|||
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> hiddenAbilities, LearnableMoves moves, IReadOnlyCollection<string> tags)
|
||||
{
|
||||
var abilitiesConverted = abilities.Select(x => x.ToPtr()).ToArray();
|
||||
var hiddenAbilitiesConverted = hiddenAbilities.Select(x => x.ToPtr()).ToArray();
|
||||
var tagsConverted = tags.Select(x => x.ToPtr()).ToArray();
|
||||
var ab = abilitiesConverted.ArrayPtr();
|
||||
var hab = hiddenAbilitiesConverted.ArrayPtr();
|
||||
var tagsPtr = tagsConverted.ArrayPtr();
|
||||
|
||||
var ptr = SpeciesVariant.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);
|
||||
(ulong) hiddenAbilities.Count, moves.Ptr, tagsPtr, (ulong) tags.Count);
|
||||
foreach (var intPtr in abilitiesConverted)
|
||||
Marshal.FreeHGlobal(intPtr);
|
||||
foreach (var intPtr in hiddenAbilitiesConverted)
|
||||
|
@ -129,7 +131,7 @@ namespace PkmnLibSharp.Library
|
|||
}
|
||||
}
|
||||
|
||||
public int GetPkmnType(int index)
|
||||
public byte GetPkmnType(int index)
|
||||
{
|
||||
return Types[index];
|
||||
}
|
||||
|
@ -139,6 +141,11 @@ namespace PkmnLibSharp.Library
|
|||
return SpeciesVariant.GetRandomTalent(Ptr, rand.Ptr);
|
||||
}
|
||||
|
||||
public bool HasFlag(string flag)
|
||||
{
|
||||
return SpeciesVariant.HasFlag(Ptr, flag.ToPtr()) == 1;
|
||||
}
|
||||
|
||||
protected internal override void MarkAsDeleted()
|
||||
{
|
||||
base.MarkAsDeleted();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Creaturelib.Generated;
|
||||
using Pkmnlib.Generated;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
@ -15,12 +16,17 @@ namespace PkmnLibSharp.Library
|
|||
}
|
||||
|
||||
public Species(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate,
|
||||
byte captureRate, byte baseHappiness, string[] eggGroups)
|
||||
byte captureRate, byte baseHappiness, IReadOnlyCollection<string> eggGroups, IReadOnlyCollection<string> tags)
|
||||
{
|
||||
var ptr = IntPtr.Zero;
|
||||
var eggGroupsPtr = eggGroups.ArrayPtr();
|
||||
var tagsConverted = tags.Select(x => x.ToPtr()).ToArray();
|
||||
var eggGroupsConverted = eggGroups.Select(x => x.ToPtr()).ToArray();
|
||||
var eggGroupsPtr = eggGroupsConverted.ArrayPtr();
|
||||
var tagsPtr = tagsConverted.ArrayPtr();
|
||||
|
||||
PokemonSpecies.Construct(ref ptr, id, name.ToPtr(), defaultForme.Ptr, genderRatio,
|
||||
growthRate.ToPtr(), captureRate, baseHappiness, eggGroupsPtr, (ulong) eggGroups.Length).Assert();
|
||||
growthRate.ToPtr(), captureRate, baseHappiness, eggGroupsPtr, (ulong) eggGroups.Count,
|
||||
tagsPtr, (ulong) tags.Count).Assert();
|
||||
_formeCache.Add("default", defaultForme);
|
||||
Initialize(ptr);
|
||||
}
|
||||
|
@ -31,6 +37,21 @@ namespace PkmnLibSharp.Library
|
|||
public string Name => _name ??= CreatureSpecies.GetName(Ptr).PtrString()!;
|
||||
public string GrowthRate => _growthRate ??= CreatureSpecies.GetGrowthRate(Ptr).PtrString()!;
|
||||
|
||||
public string[] EggGroups
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_eggGroups != null) return _eggGroups;
|
||||
var count = Pkmnlib.Generated.PokemonSpecies.GetEggGroupCount(Ptr);
|
||||
_eggGroups = new string[count];
|
||||
for (ulong i = 0; i < count; i++)
|
||||
{
|
||||
_eggGroups[i] = PokemonSpecies.GetEggGroup(Ptr, i).PtrString()!;
|
||||
}
|
||||
return _eggGroups;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyNativePtrArray<Forme> Formes
|
||||
{
|
||||
get
|
||||
|
@ -114,6 +135,11 @@ namespace PkmnLibSharp.Library
|
|||
Pkmnlib.Generated.PokemonSpecies.AddEvolution(Ptr, evolutionData.Ptr);
|
||||
}
|
||||
|
||||
public bool HasFlag(string flag)
|
||||
{
|
||||
return CreatureSpecies.HasFlag(Ptr, flag.ToPtr()) == 1;
|
||||
}
|
||||
|
||||
private string? _name;
|
||||
private string? _growthRate;
|
||||
|
||||
|
@ -122,6 +148,7 @@ namespace PkmnLibSharp.Library
|
|||
|
||||
private ReadOnlyNativePtrArray<EvolutionData>? _evolutions;
|
||||
private ReadOnlyNativePtrArray<Forme>? _formes;
|
||||
private string[]? _eggGroups;
|
||||
|
||||
protected internal override void MarkAsDeleted()
|
||||
{
|
||||
|
|
|
@ -54,6 +54,19 @@ namespace PkmnLibSharp.Library
|
|||
return species;
|
||||
}
|
||||
|
||||
public IEnumerable<Species> GetEnumerator()
|
||||
{
|
||||
var count = Creaturelib.Generated.SpeciesLibrary.GetCount(Ptr);
|
||||
var ptr = IntPtr.Zero;
|
||||
for (ulong i = 0; i < count; i++)
|
||||
{
|
||||
Creaturelib.Generated.SpeciesLibrary.GetAtIndex(Ptr, i, ref ptr).Assert();
|
||||
if (TryResolvePointer(ptr, out Species? species))
|
||||
yield return species!;
|
||||
yield return new Species(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
internal SpeciesLibrary(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
|
BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)
Binary file not shown.
|
@ -88,6 +88,16 @@ namespace PkmnLibSharp.Utilities
|
|||
Cached.TryRemove(_ptr, out _);
|
||||
}
|
||||
|
||||
public static bool operator ==(PointerWrapper? a, PointerWrapper? b)
|
||||
{
|
||||
return a?._ptr == b?._ptr;
|
||||
}
|
||||
|
||||
public static bool operator !=(PointerWrapper? a, PointerWrapper? b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
protected bool Equals(PointerWrapper other)
|
||||
{
|
||||
return _ptr.Equals(other._ptr);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -28,8 +28,8 @@ namespace PkmnLibSharpTests.Battling
|
|||
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)), 0.5f, "growthRate",
|
||||
20, 100, new[]{"testEggGroup"}));
|
||||
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,
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual("foo", forme.Name);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual(1f, forme.Height);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual(2f, forme.Weight);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual(100, forme.BaseExperience);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
@ -53,12 +53,12 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, 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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual(0, forme.GetPkmnType(0));
|
||||
Assert.AreEqual(1, forme.GetPkmnType(1));
|
||||
forme.Dispose();
|
||||
|
@ -68,7 +68,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual(10, forme.BaseHealth);
|
||||
Assert.AreEqual(20, forme.BaseAttack);
|
||||
Assert.AreEqual(30, forme.BaseDefense);
|
||||
|
@ -82,7 +82,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual("foo", forme.Abilities[0]);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace PkmnLibSharpTests.Library
|
|||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
Assert.AreEqual("bar", forme.HiddenAbilities[0]);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
var library = new SpeciesLibrary(100);
|
||||
library.Insert("foobar", species);
|
||||
Assert.AreEqual(1, library.Count);
|
||||
|
@ -29,8 +29,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
var library = new SpeciesLibrary(100);
|
||||
library.Insert("foobar", species);
|
||||
Assert.AreEqual(1, library.Count);
|
||||
|
@ -43,8 +43,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
var library = new SpeciesLibrary(100);
|
||||
library.Insert("foobar", species);
|
||||
Assert.AreEqual(1, library.Count);
|
||||
|
@ -61,8 +61,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
var library = new SpeciesLibrary(100);
|
||||
library.Insert("foobar", species);
|
||||
Assert.AreEqual(1, library.Count);
|
||||
|
|
|
@ -10,8 +10,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
species.Dispose();
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.AreEqual(10, species.Id);
|
||||
species.Dispose();
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.AreEqual(0.5f, species.GenderRate);
|
||||
species.Dispose();
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.AreEqual(100, species.CaptureRate);
|
||||
species.Dispose();
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.AreEqual("testSpecies", species.Name);
|
||||
species.Dispose();
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.AreEqual("exponential", species.GrowthRate);
|
||||
species.Dispose();
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.True(species.HasForme("default"));
|
||||
species.Dispose();
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
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[] {"bar"}, new LearnableMoves(100), new string[0]);
|
||||
species.SetForme("bar", forme);
|
||||
Assert.True(species.HasForme("bar"));
|
||||
species.Dispose();
|
||||
|
@ -86,8 +86,8 @@ namespace PkmnLibSharpTests.Library
|
|||
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));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
var f = species.GetForme("default");
|
||||
Assert.AreEqual(forme, f);
|
||||
Assert.Throws<NativeException>(() =>
|
||||
|
@ -100,8 +100,8 @@ namespace PkmnLibSharpTests.Library
|
|||
public void TrGetForme()
|
||||
{
|
||||
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"}, new LearnableMoves(100));
|
||||
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"});
|
||||
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]);
|
||||
Assert.True(species.TryGetForme("default", out var f));
|
||||
Assert.AreEqual(forme, f);
|
||||
Assert.False(species.TryGetForme("non-existing", out f));
|
||||
|
|
Loading…
Reference in New Issue