Many fixes

This commit is contained in:
Deukhoofd 2020-05-03 16:26:14 +02:00
parent 640451e6d5
commit 8ce1db668e
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
8 changed files with 42 additions and 1827 deletions

View File

@ -4,10 +4,11 @@ name: default
type: docker type: docker
steps: steps:
- name: Build - name: Build
image: mcr.microsoft.com/dotnet/core/sdk:3.1 image: deukhoofd/dotnet-builder
commands: commands:
- dotnet build -c Release - dotnet build -c Release
- name: Tests - name: Tests
image: mcr.microsoft.com/dotnet/core/sdk:3.1 image: deukhoofd/dotnet-builder
commands: commands:
- export LD_LIBRARY_PATH=.
- dotnet test -v n - dotnet test -v n

View File

@ -6,6 +6,7 @@ namespace Pkmnlib.Generated
{ {
internal static class PokemonSpecies internal static class PokemonSpecies
{ {
/// <param name="out">const PokemonSpecies *&</param>
/// <param name="id">unsigned short</param> /// <param name="id">unsigned short</param>
/// <param name="name">const char *</param> /// <param name="name">const char *</param>
/// <param name="defaultForme">const PokemonForme *</param> /// <param name="defaultForme">const PokemonForme *</param>
@ -13,9 +14,9 @@ namespace Pkmnlib.Generated
/// <param name="growthRate">const char *</param> /// <param name="growthRate">const char *</param>
/// <param name="captureRate">unsigned char</param> /// <param name="captureRate">unsigned char</param>
/// <param name="baseHappiness">unsigned char</param> /// <param name="baseHappiness">unsigned char</param>
/// <returns>const PokemonSpecies *</returns> /// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_PokemonSpecies_Construct")] [DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_PokemonSpecies_Construct")]
internal static extern IntPtr Construct(ushort id, IntPtr name, IntPtr defaultForme, float genderRatio, IntPtr growthRate, byte captureRate, byte baseHappiness); internal static extern byte Construct(ref IntPtr @out, ushort id, IntPtr name, IntPtr defaultForme, float genderRatio, IntPtr growthRate, byte captureRate, byte baseHappiness);
/// <param name="p">const PokemonSpecies *</param> /// <param name="p">const PokemonSpecies *</param>
/// <returns>void</returns> /// <returns>void</returns>

View File

@ -1,3 +1,4 @@
using System;
using Pkmnlib.Generated; using Pkmnlib.Generated;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
@ -6,15 +7,22 @@ namespace PkmnLibSharp.Library
public class Species : PointerWrapper public class Species : PointerWrapper
{ {
// ReSharper disable once SuggestBaseTypeForParameter // ReSharper disable once SuggestBaseTypeForParameter
public Species(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate, private Species(IntPtr ptr) : base(ptr)
byte captureRate, byte baseHappiness) : base(PokemonSpecies.Construct(id, name.ToPtr(), defaultForme.Ptr, genderRatio,
growthRate.ToPtr(), captureRate, baseHappiness))
{ {
} }
public static Species Create(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate,
byte captureRate, byte baseHappiness)
{
var ptr = IntPtr.Zero;
PokemonSpecies.Construct(ref ptr, id, name.ToPtr(), defaultForme.Ptr, genderRatio,
growthRate.ToPtr(), captureRate, baseHappiness).Assert();
return new Species(ptr);
}
internal override void DeletePtr() internal override void DeletePtr()
{ {
Pokemon.Destruct(Ptr); PokemonSpecies.Destruct(Ptr);
} }
} }
} }

Binary file not shown.

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

Binary file not shown.

View File

@ -12,14 +12,14 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include="Native\libArbutils.so" CopyToOutputDirectory="Always" Link="libArbutils.so" /> <Content Include="Native/*.so.*" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Link="%(Filename)%(Extension)"></Content>
<Content Include="Native\libCreatureLibLibrary.so" CopyToOutputDirectory="Always" Link="libCreatureLibLibrary.so" />
<Content Include="Native\libCreatureLibBattling.so" CopyToOutputDirectory="Always" Link="libCreatureLibBattling.so" />
<Content Include="Native\libpkmnLib.so" CopyToOutputDirectory="Always" Link="libpkmnLib.so" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System.Collections.Immutable, Version=1.2.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <Reference Include="System.Collections.Immutable, Version=1.2.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\..\..\..\..\..\usr\share\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Collections.Immutable.dll</HintPath> <HintPath>..\..\..\..\..\..\usr\share\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Collections.Immutable.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
</ItemGroup>
</Project> </Project>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,17 @@
using NUnit.Framework;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class SpeciesTests
{
[Test]
public void ConstructDestruct()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, LearnableMoves.Create(100));
var species = Species.Create(0, "testSpecies", forme, 0.5f, "exponential", 100, 80);
species.Dispose();
}
}
}