Implements all EvolutionData.

This commit is contained in:
Deukhoofd 2020-08-08 15:37:44 +02:00
parent cecb1e9a83
commit 7f4ccbfe2a
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
5 changed files with 78 additions and 2 deletions

View File

@ -1,4 +1,4 @@
namespace PkmnLibSharp.Battling
namespace PkmnLibSharp.Library
{
public enum Gender
{

View File

@ -1,4 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using PkmnLibSharp.Library.Items;
using PkmnLibSharp.Library.Moves;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library.Evolution
@ -13,6 +18,66 @@ namespace PkmnLibSharp.Library.Evolution
{
return new EvolutionData(Pkmnlib.Generated.EvolutionData.CreateLevelEvolution(level, into.Ptr));
}
public static EvolutionData CreateFriendshipEvolution(byte level, Species into)
{
return new EvolutionData(Pkmnlib.Generated.EvolutionData.CreateFriendshipEvolution(level, into.Ptr));
}
public static EvolutionData CreateKnownMoveEvolution(MoveData move, Species into)
{
return new EvolutionData(Pkmnlib.Generated.EvolutionData.CreateKnownMoveEvolution(move.Ptr, into.Ptr));
}
public static EvolutionData CreateLocationEvolution(string location, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateLocationEvolution(location.ToPtr(), into.Ptr));
}
public static EvolutionData CreateTimeEvolution(TimeOfDay timeOfDay, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateTimeEvolution((Pkmnlib.TimeOfDay) timeOfDay, into.Ptr));
}
public static EvolutionData CreateItemEvolution(Item item, Species into)
{
return new EvolutionData(Pkmnlib.Generated.EvolutionData.CreateItemEvolution(item.Ptr, into.Ptr));
}
public static EvolutionData CreateGenderBasedEvolution(Gender gender, byte level, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateGenderBasedEvolution((Pkmnlib.Gender) gender, level, into.Ptr));
}
public static EvolutionData CreateItemUseEvolution(Item item, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateItemUseEvolution(item.Ptr, into.Ptr));
}
public static EvolutionData CreateItemUseWithGenderEvolution(Item item, Gender gender, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateItemUseWithGenderEvolution(item.Ptr, (Pkmnlib.Gender) gender, into.Ptr));
}
public static EvolutionData CreateTradeEvolution(Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateTradeEvolution(into.Ptr));
}
public static EvolutionData CreateTradeWithItemEvolution(Item item, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateTradeWithItemEvolution(item.Ptr, into.Ptr));
}
public static EvolutionData CreateTradeWithSpeciesEvolution(Species with, Species into)
{
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateTradeWithSpeciesEvolution(with.Ptr, into.Ptr));
}
public static EvolutionData CreateCustomEvolution(IList<EffectParameter> parameters, Species into)
{
var parametersPtrs = parameters.Select(x => x.Ptr).ToArray();
GCHandle.Alloc(parametersPtrs, GCHandleType.Pinned);
var ptr = parametersPtrs.ArrayPtr();
return new EvolutionData(
Pkmnlib.Generated.EvolutionData.CreateCustomEvolution(ptr, (ulong) parameters.Count, into.Ptr));
}
public EvolutionMethod Method => (EvolutionMethod) Pkmnlib.Generated.EvolutionData.GetMethod(Ptr);

View File

@ -5,7 +5,7 @@ using Pkmnlib;
using Pkmnlib.Generated;
using PkmnLibSharp.Utilities;
using EvolutionData = PkmnLibSharp.Library.Evolution.EvolutionData;
using Gender = PkmnLibSharp.Battling.Gender;
using Gender = PkmnLibSharp.Library.Gender;
using Random = PkmnLibSharp.Utilities.Random;
namespace PkmnLibSharp.Library

View File

@ -0,0 +1,10 @@
namespace PkmnLibSharp.Library
{
public enum TimeOfDay
{
Night = 0,
Morning = 1,
Afternoon = 2,
Evening = 3,
}
}

View File

@ -1,5 +1,6 @@
using NUnit.Framework;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Battling
{