Support for Pokemon building.
This commit is contained in:
parent
049eb480c0
commit
c143235495
|
@ -10,13 +10,9 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4CB6DA3C-017B-4AE0-B889-3DFE6B969CD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4CB6DA3C-017B-4AE0-B889-3DFE6B969CD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4CB6DA3C-017B-4AE0-B889-3DFE6B969CD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4CB6DA3C-017B-4AE0-B889-3DFE6B969CD0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D15FD33-1AEA-44F4-8211-AA8AF97EA534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D15FD33-1AEA-44F4-8211-AA8AF97EA534}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D15FD33-1AEA-44F4-8211-AA8AF97EA534}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D15FD33-1AEA-44F4-8211-AA8AF97EA534}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4CB6DA3C-017B-4AE0-B889-3DFE6B969CD0}.Debug|Any CPU.ActiveCfg = Release|x86_64
|
||||
{4CB6DA3C-017B-4AE0-B889-3DFE6B969CD0}.Debug|Any CPU.Build.0 = Release|x86_64
|
||||
{0D15FD33-1AEA-44F4-8211-AA8AF97EA534}.Debug|Any CPU.ActiveCfg = Debug|x86_64
|
||||
{0D15FD33-1AEA-44F4-8211-AA8AF97EA534}.Debug|Any CPU.Build.0 = Debug|x86_64
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using PkmnLibSharp.Library;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
@ -9,19 +11,79 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
public class Pokemon : PointerWrapper
|
||||
{
|
||||
public Pokemon(BattleLibrary library, Species species, Forme forme, byte level, uint experience, uint uid,
|
||||
Gender gender, byte coloring, Item heldItem, string nickname, bool hiddenAbility, byte abilityIndex,
|
||||
IReadOnlyCollection<LearnedMove> moves, StatisticSet<byte> ivs, StatisticSet<byte> evs, Nature nature) :
|
||||
base(Pkmnlib.Generated.Pokemon.Construct(library.Ptr, species.Ptr, forme.Ptr, level, experience,
|
||||
uid, (Pkmnlib.Gender) gender, coloring, heldItem.Ptr, nickname.ToPtr(), hiddenAbility.ToNative(),
|
||||
abilityIndex,
|
||||
moves.Select(x => x.Ptr).ToArray().ArrayPtr(),
|
||||
public Pokemon([NotNull] BattleLibrary library, [NotNull] Species species, [NotNull] Forme forme,
|
||||
byte level, uint experience, uint uid,
|
||||
Gender gender, byte coloring, [MaybeNull] Item heldItem, [MaybeNull] string nickname, bool hiddenAbility, byte abilityIndex,
|
||||
[NotNull] IReadOnlyCollection<LearnedMove> moves, StatisticSet<byte> ivs, StatisticSet<byte> evs, [NotNull] Nature nature)
|
||||
: base(Pkmnlib.Generated.Pokemon.Construct(
|
||||
library.Ptr, species.Ptr, forme.Ptr, level, experience,
|
||||
uid, (Pkmnlib.Gender) gender, coloring, heldItem?.Ptr ?? IntPtr.Zero, nickname.ToPtr(),
|
||||
hiddenAbility.ToNative(), abilityIndex,
|
||||
moves.Select(x => x?.Ptr ?? IntPtr.Zero).ToArray().ArrayPtr(),
|
||||
(ulong) moves.Count,
|
||||
ivs.HP, ivs.Attack, ivs.Defense, ivs.SpecialAttack,
|
||||
ivs.SpecialDefense, ivs.Speed, evs.HP, evs.Attack, evs.Defense,
|
||||
evs.SpecialAttack, evs.SpecialDefense, evs.Speed, nature.Ptr))
|
||||
{}
|
||||
|
||||
public Species Species
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_species != null) return _species;
|
||||
var ptr = Creaturelibbattling.Generated.Creature.GetSpecies(Ptr);
|
||||
if (TryResolvePointer(ptr, out _species))
|
||||
return _species;
|
||||
_species = new Species(ptr);
|
||||
return _species;
|
||||
}
|
||||
}
|
||||
public Forme Forme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_forme != null) return _forme;
|
||||
var ptr = Creaturelibbattling.Generated.Creature.GetVariant(Ptr);
|
||||
if (TryResolvePointer(ptr, out _forme))
|
||||
return _forme;
|
||||
_forme = new Forme(ptr);
|
||||
return _forme;
|
||||
}
|
||||
}
|
||||
public byte Level => Creaturelibbattling.Generated.Creature.GetLevel(Ptr);
|
||||
public uint Experience => Creaturelibbattling.Generated.Creature.GetExperience(Ptr);
|
||||
public Gender Gender => (Gender) Creaturelibbattling.Generated.Creature.GetGender(Ptr);
|
||||
public byte Coloring => Creaturelibbattling.Generated.Creature.GetColoring(Ptr);
|
||||
public bool IsShiny => Coloring == 1;
|
||||
|
||||
public string Nickname
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nickname != null) return _nickname;
|
||||
_nickname = Creaturelibbattling.Generated.Creature.GetNickname(Ptr).PtrString();
|
||||
return _nickname;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeForme(Forme forme)
|
||||
{
|
||||
_forme = null;
|
||||
Creaturelibbattling.Generated.Creature.ChangeVariant(Ptr, forme.Ptr);
|
||||
}
|
||||
|
||||
public bool HasHeldItem(string itemName)
|
||||
{
|
||||
return Creaturelibbattling.Generated.Creature.HasHeldItem(Ptr, itemName.ToPtr()) == 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Species _species;
|
||||
private Forme _forme;
|
||||
private string _nickname;
|
||||
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Pkmnlib.Generated.Pokemon.Destruct(Ptr);
|
||||
|
|
|
@ -58,6 +58,12 @@ namespace PkmnLibSharp.Battling
|
|||
return this;
|
||||
}
|
||||
|
||||
public PokemonBuilder WithNickname(string nickname)
|
||||
{
|
||||
Nickname = nickname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PokemonBuilder LearnMove(string moveName, MoveLearnMethod moveLearnMethod)
|
||||
{
|
||||
if (LearnedMoves.Count > _library.StaticLibrary.Settings.MaximalMoves)
|
||||
|
@ -107,7 +113,7 @@ namespace PkmnLibSharp.Battling
|
|||
}
|
||||
}
|
||||
|
||||
byte abilityIndex = 0;
|
||||
var abilityIndex = 0;
|
||||
var isHiddenAbility = false;
|
||||
if (string.IsNullOrEmpty(Ability))
|
||||
{
|
||||
|
@ -115,10 +121,10 @@ namespace PkmnLibSharp.Battling
|
|||
}
|
||||
else
|
||||
{
|
||||
abilityIndex = (byte) forme.Abilities.IndexOf(Ability);
|
||||
abilityIndex = forme.Abilities.IndexOf(Ability);
|
||||
if (abilityIndex == -1)
|
||||
{
|
||||
abilityIndex = (byte) forme.HiddenAbilities.IndexOf(Ability);
|
||||
abilityIndex = forme.HiddenAbilities.IndexOf(Ability);
|
||||
if (abilityIndex == -1)
|
||||
{
|
||||
throw new Exception(
|
||||
|
@ -148,7 +154,7 @@ namespace PkmnLibSharp.Battling
|
|||
var nature = _library.StaticLibrary.NatureLibrary.GetNature(Nature);
|
||||
|
||||
return new Pokemon(_library, species, forme, Level, experience, uid, Gender, coloring, heldItem, Nickname,
|
||||
isHiddenAbility, abilityIndex, moves, IVs, EVs, nature);
|
||||
isHiddenAbility, (byte) abilityIndex, moves, IVs, EVs, nature);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// AUTOMATICALLY GENERATED, DO NOT EDIT
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Arbutils.Generated
|
||||
{
|
||||
internal static class C
|
||||
{
|
||||
/// <returns>const char *</returns>
|
||||
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_GetLastException")]
|
||||
internal static extern IntPtr GetLastException();
|
||||
|
||||
}
|
||||
}
|
|
@ -37,16 +37,18 @@ namespace Arbutils.Generated
|
|||
|
||||
/// <param name="p">Random *</param>
|
||||
/// <param name="max">int</param>
|
||||
/// <returns>int</returns>
|
||||
/// <param name="out">int &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_Random_GetWithMax")]
|
||||
internal static extern int GetWithMax(IntPtr p, int max);
|
||||
internal static extern byte GetWithMax(IntPtr p, int max, ref int @out);
|
||||
|
||||
/// <param name="p">Random *</param>
|
||||
/// <param name="min">int</param>
|
||||
/// <param name="max">int</param>
|
||||
/// <returns>int</returns>
|
||||
/// <param name="out">int &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_Random_GetInLimits")]
|
||||
internal static extern int GetInLimits(IntPtr p, int min, int max);
|
||||
internal static extern byte GetInLimits(IntPtr p, int min, int max, ref int @out);
|
||||
|
||||
/// <param name="p">Random *</param>
|
||||
/// <returns>unsigned int</returns>
|
||||
|
@ -55,16 +57,18 @@ namespace Arbutils.Generated
|
|||
|
||||
/// <param name="p">Random *</param>
|
||||
/// <param name="max">unsigned int</param>
|
||||
/// <returns>unsigned int</returns>
|
||||
/// <param name="out">unsigned int &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_Random_GetUnsignedWithMax")]
|
||||
internal static extern uint GetUnsignedWithMax(IntPtr p, uint max);
|
||||
internal static extern byte GetUnsignedWithMax(IntPtr p, uint max, ref uint @out);
|
||||
|
||||
/// <param name="p">Random *</param>
|
||||
/// <param name="min">unsigned int</param>
|
||||
/// <param name="max">unsigned int</param>
|
||||
/// <returns>unsigned int</returns>
|
||||
/// <param name="out">unsigned int &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_Random_GetUnsignedInLimits")]
|
||||
internal static extern uint GetUnsignedInLimits(IntPtr p, uint min, uint max);
|
||||
internal static extern byte GetUnsignedInLimits(IntPtr p, uint min, uint max, ref uint @out);
|
||||
|
||||
/// <param name="p">Random *</param>
|
||||
/// <returns>long unsigned int</returns>
|
||||
|
|
|
@ -32,9 +32,10 @@ namespace Pkmnlib.Generated
|
|||
|
||||
/// <param name="p">NatureLibrary *</param>
|
||||
/// <param name="rand">Random *</param>
|
||||
/// <returns>const char *</returns>
|
||||
/// <param name="out">const char * &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetRandomNatureName")]
|
||||
internal static extern IntPtr GetRandomNatureName(IntPtr p, IntPtr rand);
|
||||
internal static extern byte GetRandomNatureName(IntPtr p, IntPtr rand, ref IntPtr @out);
|
||||
|
||||
/// <param name="p">NatureLibrary *</param>
|
||||
/// <param name="nature">const Nature *</param>
|
||||
|
|
|
@ -120,10 +120,10 @@ namespace PkmnLibSharp.Library
|
|||
var abilitiesConverted = abilities.Select(x => x.ToPtr()).ToArray();
|
||||
var hiddenAbilitiesConverted = hiddenAbilities.Select(x => x.ToPtr()).ToArray();
|
||||
var ab = abilitiesConverted.ArrayPtr();
|
||||
var hab = abilitiesConverted.ArrayPtr();
|
||||
var hab = hiddenAbilitiesConverted.ArrayPtr();
|
||||
var ptr = SpeciesVariant.Construct(name.ToPtr(), height, weight, baseExperience, types.ArrayPtr(),
|
||||
(ulong) types.Length, baseHealth, baseAttack, baseDefense, baseSpecialAttack,
|
||||
baseSpecialDefense, baseSpeed, (IntPtr) ab, (ulong) abilities.Length, (IntPtr) hab,
|
||||
baseSpecialDefense, baseSpeed, (IntPtr) ab, (ulong) abilities.Length, hab,
|
||||
(ulong) hiddenAbilities.Length, moves.Ptr);
|
||||
var f = new Forme(ptr);
|
||||
foreach (var intPtr in abilitiesConverted)
|
||||
|
|
|
@ -57,7 +57,9 @@ namespace PkmnLibSharp.Library
|
|||
|
||||
public string GetRandomNatureName(Random random)
|
||||
{
|
||||
return Pkmnlib.Generated.NatureLibrary.GetRandomNatureName(Ptr, random.Ptr).PtrString();
|
||||
IntPtr val = IntPtr.Zero;
|
||||
Pkmnlib.Generated.NatureLibrary.GetRandomNatureName(Ptr, random.Ptr, ref val).Assert();
|
||||
return val.PtrString();
|
||||
}
|
||||
|
||||
protected override void DeletePtr()
|
||||
|
|
|
@ -2,7 +2,7 @@ using System;
|
|||
|
||||
namespace PkmnLibSharp.Library
|
||||
{
|
||||
public class StatisticSet<T> where T : IComparable<T>
|
||||
public struct StatisticSet<T> where T : IComparable<T>
|
||||
{
|
||||
public T HP { get; set; }
|
||||
public T Attack { get; set; }
|
||||
|
|
BIN
PkmnLibSharp/Native/libArbutils.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libArbutils.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libArubtils.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libArubtils.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libCreatureLibBattling.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libCreatureLibBattling.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libCreatureLibLibrary.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libCreatureLibLibrary.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.
|
@ -2,23 +2,12 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Configurations>Release;Debug</Configurations>
|
||||
<Platforms>x86_64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Native/*.so.*" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Link="%(Filename)%(Extension)"></Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -8,12 +8,14 @@ namespace PkmnLibSharp.Utilities
|
|||
{
|
||||
internal static IntPtr ToPtr(this string s)
|
||||
{
|
||||
return Marshal.StringToHGlobalAuto(s);
|
||||
if (s == null) return IntPtr.Zero;
|
||||
return Marshal.StringToHGlobalAnsi(s);
|
||||
}
|
||||
|
||||
internal static string PtrString(this IntPtr i)
|
||||
{
|
||||
return Marshal.PtrToStringAuto(i);
|
||||
if (i == IntPtr.Zero) return null;
|
||||
return Marshal.PtrToStringAnsi(i);
|
||||
}
|
||||
|
||||
internal static IntPtr ArrayPtr(this Array a)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace PkmnLibSharp.Utilities
|
||||
{
|
||||
public class Random : PointerWrapper
|
||||
|
@ -27,12 +29,16 @@ namespace PkmnLibSharp.Utilities
|
|||
|
||||
public int Get(int max)
|
||||
{
|
||||
return Arbutils.Generated.Random.GetWithMax(Ptr, max);
|
||||
int val = 0;
|
||||
Arbutils.Generated.Random.GetWithMax(Ptr, max, ref val).Assert();
|
||||
return val;
|
||||
}
|
||||
|
||||
public int Get(int min, int max)
|
||||
{
|
||||
return Arbutils.Generated.Random.GetInLimits(Ptr, min, max);
|
||||
int val = 0;
|
||||
Arbutils.Generated.Random.GetInLimits(Ptr, min, max, ref val).Assert();
|
||||
return val;
|
||||
}
|
||||
|
||||
public uint GetUnsigned()
|
||||
|
@ -42,12 +48,16 @@ namespace PkmnLibSharp.Utilities
|
|||
|
||||
public uint GetUnsigned(uint max)
|
||||
{
|
||||
return Arbutils.Generated.Random.GetUnsignedWithMax(Ptr, max);
|
||||
uint val = 0;
|
||||
Arbutils.Generated.Random.GetUnsignedWithMax(Ptr, max, ref val).Assert();
|
||||
return val;
|
||||
}
|
||||
|
||||
public uint GetUnsigned(uint min, uint max)
|
||||
{
|
||||
return Arbutils.Generated.Random.GetUnsignedInLimits(Ptr, min, max);
|
||||
uint val = 0;
|
||||
Arbutils.Generated.Random.GetUnsignedInLimits(Ptr, min, max, ref val).Assert();
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,14 +6,16 @@ namespace PkmnLibSharp.Utilities
|
|||
{
|
||||
internal static void Assert(this byte result)
|
||||
{
|
||||
if (result == 0) return;
|
||||
if (result == 1)
|
||||
{
|
||||
throw new NativeException("CreatureLib", Creatureliblibrary.Generated.C.GetLastException().PtrString());
|
||||
}
|
||||
if (result == 2)
|
||||
switch (result)
|
||||
{
|
||||
case 0: return;
|
||||
case 1:
|
||||
throw new NativeException("CreatureLib",
|
||||
Creatureliblibrary.Generated.C.GetLastException().PtrString());
|
||||
case 2:
|
||||
throw new NativeException("PkmnLib", Pkmnlib.Generated.C.GetLastException().PtrString());
|
||||
case 3:
|
||||
throw new NativeException("Arbutils", Arbutils.Generated.C.GetLastException().PtrString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"enums":[],"functions":[{"filename":"Arbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"Arbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"Arbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"Arbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"Arbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"}],"returns":"int"},{"filename":"Arbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"}],"returns":"int"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"}],"returns":"unsigned int"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"}],"returns":"unsigned int"},{"filename":"Arbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}
|
||||
{"enums":[],"functions":[{"filename":"Arbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"Arbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"Arbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"Arbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"Arbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"Arbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,49 @@
|
|||
using System.Linq;
|
||||
using PkmnLibSharp.Battling;
|
||||
using PkmnLibSharp.Library;
|
||||
using PkmnLibSharp.Library.GrowthRates;
|
||||
using PkmnLibSharp.Library.Items;
|
||||
using PkmnLibSharp.Library.Moves;
|
||||
|
||||
namespace PkmnLibSharpTests.Battling
|
||||
{
|
||||
public static class BattleLibraryHelper
|
||||
{
|
||||
private static BattleLibrary _cache;
|
||||
|
||||
public static BattleLibrary GetLibrary()
|
||||
{
|
||||
if (_cache != null) return _cache;
|
||||
|
||||
_cache = BattleLibrary.Create(BuildStatic(), new StatCalculator(), new DamageLibrary(),
|
||||
new ExperienceLibrary(),
|
||||
new AngelScriptResolver(), new MiscLibrary());
|
||||
return _cache;
|
||||
}
|
||||
|
||||
private static PokemonLibrary BuildStatic()
|
||||
{
|
||||
var settings = new LibrarySettings(100, 4, 4096);
|
||||
var species = new SpeciesLibrary(10);
|
||||
species.Insert("testSpecies", Species.Create(1, "testSpecies",
|
||||
Forme.Create("default", 10f, 10f, 100, new byte[] {0, 1}, 100,
|
||||
100, 100, 100, 100, 100, new[] {"testAbility", "testAbility2"},
|
||||
new[] {"testHiddenAbility"}, LearnableMoves.Create(100)), 0.5f, "growthRate",
|
||||
20, 100));
|
||||
|
||||
var moves = MoveLibrary.Create(10);
|
||||
var items = new ItemLibrary(10);
|
||||
items.Insert("testItem", Item.Create("testItem", ItemCategory.MiscItem, BattleItemCategory.None,
|
||||
500, new string[] { }, 20));
|
||||
var gr = new GrowthRateLibrary(10);
|
||||
gr.AddGrowthRate("growthRate",
|
||||
new LookupGrowthRate(
|
||||
Enumerable.Range(1, 100).Select(x => (uint)x * 100).ToArray()));
|
||||
var types = new TypeLibrary(10);
|
||||
var natures = new NatureLibrary(10);
|
||||
natures.LoadNature("testNature", new Nature());
|
||||
var lib = PokemonLibrary.Create(settings, species, moves, items, gr, types, natures);
|
||||
return lib;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Battling;
|
||||
|
||||
namespace PkmnLibSharpTests.Battling
|
||||
{
|
||||
public class PokemonBuilderTests
|
||||
{
|
||||
[Test]
|
||||
public void SimpleBuildPokemon()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var pokemon = new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.Build();
|
||||
Assert.AreEqual("testSpecies", pokemon.Species.Name);
|
||||
Assert.AreEqual(50, pokemon.Level);
|
||||
Assert.AreEqual("default", pokemon.Forme.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPokemonWithNickname()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var pokemon = new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.WithNickname("cuteNickname")
|
||||
.Build();
|
||||
Assert.AreEqual("cuteNickname", pokemon.Nickname);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPokemonWithGender()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var pokemon = new PokemonBuilder(lib, "testSpecies", 50)
|
||||
.WithGender(Gender.Female)
|
||||
.Build();
|
||||
Assert.AreEqual(Gender.Female, pokemon.Gender);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -4,6 +4,10 @@
|
|||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
|
||||
<Platforms>x86_64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -16,8 +20,4 @@
|
|||
<ProjectReference Include="..\PkmnLibSharp\PkmnLibSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Battling" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue