Updates CreatureLib, implements support for ItemUseScript.

This commit is contained in:
Deukhoofd 2021-03-07 19:36:09 +01:00
parent cbe5747d04
commit 3a7edb2fc3
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
26 changed files with 234 additions and 63 deletions

View File

@ -22,8 +22,8 @@ namespace PkmnLibSharp.Battling.Events
} }
} }
private uint PreviousExperience => Creaturelib.Generated.ExperienceGainEvent.GetPreviousExperience(Ptr); public uint PreviousExperience => Creaturelib.Generated.ExperienceGainEvent.GetPreviousExperience(Ptr);
private uint NewExperience => Creaturelib.Generated.ExperienceGainEvent.GetNewExperience(Ptr); public uint NewExperience => Creaturelib.Generated.ExperienceGainEvent.GetNewExperience(Ptr);
private Pokemon? _pokemon; private Pokemon? _pokemon;

View File

@ -0,0 +1,53 @@
using System;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling
{
public class ItemUseScript : PointerWrapper
{
internal ItemUseScript(IntPtr ptr) : base(ptr){}
public bool IsItemUsable()
{
byte res = 0;
Creaturelib.Generated.ItemUseScript.IsItemUsable(Ptr, ref res).Assert();
return res == 1;
}
public bool IsPokemonUseItem()
{
byte res = 0;
Creaturelib.Generated.ItemUseScript.IsCreatureUseItem(Ptr, ref res).Assert();
return res == 1;
}
public bool IsUseValidForPokemon(Pokemon pokemon)
{
byte res = 0;
Creaturelib.Generated.ItemUseScript.IsUseValidForCreature(Ptr, pokemon.Ptr, ref res).Assert();
return res == 1;
}
public bool IsHoldable()
{
byte res = 0;
Creaturelib.Generated.ItemUseScript.IsHoldable(Ptr, ref res).Assert();
return res == 1;
}
public void OnUse()
{
Creaturelib.Generated.ItemUseScript.OnUse(Ptr);
}
public void OnPokemonUse(Pokemon pokemon)
{
Creaturelib.Generated.ItemUseScript.OnCreatureUse(Ptr, pokemon.Ptr);
}
protected override void DeletePtr()
{
Creaturelib.Generated.ItemUseScript.Destruct(Ptr);
}
}
}

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using PkmnLibSharp.Library.Items;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling namespace PkmnLibSharp.Battling
@ -9,12 +11,15 @@ namespace PkmnLibSharp.Battling
public AngelScriptResolver() : base(Pkmnlib.Generated.AngelScriptResolver.Construct()) public AngelScriptResolver() : base(Pkmnlib.Generated.AngelScriptResolver.Construct())
{ {
} }
internal AngelScriptResolver(IntPtr ptr) : base(ptr)
{
}
public void Initialize(BattleLibrary library) public void Initialize(BattleLibrary library)
{ {
Pkmnlib.Generated.AngelScriptResolver.Initialize(Ptr, library.Ptr).Assert(); Pkmnlib.Generated.AngelScriptResolver.Initialize(Ptr, library.Ptr).Assert();
} }
public void CreateScript(string name, string script) public void CreateScript(string name, string script)
{ {
Pkmnlib.Generated.AngelScriptResolver.CreateScript(Ptr, name.ToPtr(), script.ToPtr()).Assert(); Pkmnlib.Generated.AngelScriptResolver.CreateScript(Ptr, name.ToPtr(), script.ToPtr()).Assert();

View File

@ -78,6 +78,21 @@ namespace PkmnLibSharp.Battling
} }
} }
public ScriptResolver ScriptResolver
{
get
{
if (_scriptResolver != null) return _scriptResolver;
var ptr = Creaturelib.Generated.BattleLibrary.GetScriptResolver(Ptr);
if (TryResolvePointer(ptr, out _scriptResolver))
return _scriptResolver!;
// TODO: Make work with other script resolvers.
_scriptResolver = new AngelScriptResolver(ptr);
return _scriptResolver;
}
}
internal BattleLibrary(IntPtr ptr) : base(ptr) internal BattleLibrary(IntPtr ptr) : base(ptr)
{ {
} }

View File

@ -1,12 +1,29 @@
using System; using System;
using System.Collections.Generic;
using PkmnLibSharp.Library.Items;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling namespace PkmnLibSharp.Battling
{ {
public abstract class ScriptResolver : PointerWrapper public abstract class ScriptResolver : PointerWrapper
{ {
private readonly Dictionary<Item, ItemUseScript> _itemUseScripts = new Dictionary<Item, ItemUseScript>();
protected ScriptResolver(IntPtr ptr) : base(ptr) protected ScriptResolver(IntPtr ptr) : base(ptr)
{ {
} }
public ItemUseScript? LoadItemUseScript(Item item)
{
if (_itemUseScripts.TryGetValue(item, out var v))
return v;
var ptr = IntPtr.Zero;
Creaturelib.Generated.ScriptResolver.LoadItemScript(ref ptr, Ptr, item.Ptr);
if (ptr == IntPtr.Zero)
return null;
var itemUseScript = new ItemUseScript(ptr);
_itemUseScripts.Add(item, itemUseScript);
return itemUseScript;
}
} }
} }

View File

@ -36,7 +36,7 @@ namespace Creaturelib.Generated
internal static extern byte GetPriority(ref sbyte @out, IntPtr p); internal static extern byte GetPriority(ref sbyte @out, IntPtr p);
/// <param name="p">const AttackTurnChoice *</param> /// <param name="p">const AttackTurnChoice *</param>
/// <returns>Script *</returns> /// <returns>BattleScript *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackTurnChoice_GetAttackScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackTurnChoice_GetAttackScript")]
internal static extern IntPtr GetAttackScript(IntPtr p); internal static extern IntPtr GetAttackScript(IntPtr p);

View File

@ -152,7 +152,7 @@ namespace Creaturelib.Generated
/// <param name="p">Battle *</param> /// <param name="p">Battle *</param>
/// <param name="key">const char *</param> /// <param name="key">const char *</param>
/// <returns>Script *</returns> /// <returns>BattleScript *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_GetVolatileScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_GetVolatileScript")]
internal static extern IntPtr GetVolatileScript(IntPtr p, IntPtr key); internal static extern IntPtr GetVolatileScript(IntPtr p, IntPtr key);
@ -163,7 +163,7 @@ namespace Creaturelib.Generated
internal static extern byte AddVolatileScriptByName(IntPtr p, IntPtr key); internal static extern byte AddVolatileScriptByName(IntPtr p, IntPtr key);
/// <param name="p">Battle *</param> /// <param name="p">Battle *</param>
/// <param name="script">Script *</param> /// <param name="script">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_AddVolatileScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_AddVolatileScript")]
internal static extern byte AddVolatileScript(IntPtr p, IntPtr script); internal static extern byte AddVolatileScript(IntPtr p, IntPtr script);
@ -175,7 +175,7 @@ namespace Creaturelib.Generated
internal static extern byte RemoveVolatileScript(IntPtr p, IntPtr key); internal static extern byte RemoveVolatileScript(IntPtr p, IntPtr key);
/// <param name="p">Battle *</param> /// <param name="p">Battle *</param>
/// <param name="script">Script *</param> /// <param name="script">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_RemoveVolatileScriptWithScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_RemoveVolatileScriptWithScript")]
internal static extern byte RemoveVolatileScriptWithScript(IntPtr p, IntPtr script); internal static extern byte RemoveVolatileScriptWithScript(IntPtr p, IntPtr script);

View File

@ -47,5 +47,10 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_BattleLibrary_GetExperienceLibrary")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_BattleLibrary_GetExperienceLibrary")]
internal static extern IntPtr GetExperienceLibrary(IntPtr p); internal static extern IntPtr GetExperienceLibrary(IntPtr p);
/// <param name="p">const BattleLibrary *</param>
/// <returns>ScriptResolver *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_BattleLibrary_GetScriptResolver")]
internal static extern IntPtr GetScriptResolver(IntPtr p);
} }
} }

View File

@ -241,7 +241,7 @@ namespace Creaturelib.Generated
internal static extern byte AddVolatileScriptByName(IntPtr p, IntPtr scriptName); internal static extern byte AddVolatileScriptByName(IntPtr p, IntPtr scriptName);
/// <param name="p">Creature *</param> /// <param name="p">Creature *</param>
/// <param name="script">Script *</param> /// <param name="script">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_AddVolatileScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_AddVolatileScript")]
internal static extern byte AddVolatileScript(IntPtr p, IntPtr script); internal static extern byte AddVolatileScript(IntPtr p, IntPtr script);
@ -253,7 +253,7 @@ namespace Creaturelib.Generated
internal static extern byte RemoveVolatileScriptByName(IntPtr p, IntPtr scriptName); internal static extern byte RemoveVolatileScriptByName(IntPtr p, IntPtr scriptName);
/// <param name="p">Creature *</param> /// <param name="p">Creature *</param>
/// <param name="script">Script *</param> /// <param name="script">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_RemoveVolatileScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_RemoveVolatileScript")]
internal static extern byte RemoveVolatileScript(IntPtr p, IntPtr script); internal static extern byte RemoveVolatileScript(IntPtr p, IntPtr script);

View File

@ -12,7 +12,7 @@ namespace Creaturelib.Generated
/// <param name="numberHits">unsigned char</param> /// <param name="numberHits">unsigned char</param>
/// <param name="user">Creature *</param> /// <param name="user">Creature *</param>
/// <param name="attack">LearnedAttack *</param> /// <param name="attack">LearnedAttack *</param>
/// <param name="script">Script *</param> /// <param name="script">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ExecutingAttack_Construct")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ExecutingAttack_Construct")]
internal static extern byte Construct(ref IntPtr @out, IntPtr targets, ulong targetCount, byte numberHits, IntPtr user, IntPtr attack, IntPtr script); internal static extern byte Construct(ref IntPtr @out, IntPtr targets, ulong targetCount, byte numberHits, IntPtr user, IntPtr attack, IntPtr script);

View File

@ -10,11 +10,14 @@ namespace Creaturelib.Generated
/// <param name="category">ItemCategory</param> /// <param name="category">ItemCategory</param>
/// <param name="battleCategory">BattleItemCategory</param> /// <param name="battleCategory">BattleItemCategory</param>
/// <param name="price">int</param> /// <param name="price">int</param>
/// <param name="effectName">const char *</param>
/// <param name="effectParameters">EffectParameter * *</param>
/// <param name="effectParameterCount">long unsigned int</param>
/// <param name="flags">const char * *</param> /// <param name="flags">const char * *</param>
/// <param name="flagsCount">long unsigned int</param> /// <param name="flagsCount">long unsigned int</param>
/// <returns>Item *</returns> /// <returns>Item *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Item_Construct")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Item_Construct")]
internal static extern IntPtr Construct(IntPtr name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr flags, ulong flagsCount); internal static extern IntPtr Construct(IntPtr name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr effectName, IntPtr effectParameters, ulong effectParameterCount, IntPtr flags, ulong flagsCount);
/// <param name="p">const Item *</param> /// <param name="p">const Item *</param>
/// <returns>void</returns> /// <returns>void</returns>

View File

@ -0,0 +1,51 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class ItemUseScript
{
/// <param name="p">ItemUseScript *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_Destruct")]
internal static extern void Destruct(IntPtr p);
/// <param name="p">ItemUseScript *</param>
/// <param name="out">unsigned char &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsItemUsable")]
internal static extern byte IsItemUsable(IntPtr p, ref byte @out);
/// <param name="p">ItemUseScript *</param>
/// <param name="out">unsigned char &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsCreatureUseItem")]
internal static extern byte IsCreatureUseItem(IntPtr p, ref byte @out);
/// <param name="p">ItemUseScript *</param>
/// <param name="creature">Creature *</param>
/// <param name="out">unsigned char &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsUseValidForCreature")]
internal static extern byte IsUseValidForCreature(IntPtr p, IntPtr creature, ref byte @out);
/// <param name="p">ItemUseScript *</param>
/// <param name="out">unsigned char &</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsHoldable")]
internal static extern byte IsHoldable(IntPtr p, ref byte @out);
/// <param name="p">ItemUseScript *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_OnUse")]
internal static extern byte OnUse(IntPtr p);
/// <param name="p">ItemUseScript *</param>
/// <param name="creature">Creature *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_OnCreatureUse")]
internal static extern byte OnCreatureUse(IntPtr p, IntPtr creature);
}
}

View File

@ -6,67 +6,67 @@ namespace Creaturelib.Generated
{ {
internal static class Script internal static class Script
{ {
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <returns>void</returns> /// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_Destruct")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_Destruct")]
internal static extern void Destruct(IntPtr p); internal static extern void Destruct(IntPtr p);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_Stack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_Stack")]
internal static extern byte Stack(IntPtr p); internal static extern byte Stack(IntPtr p);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnRemove")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnRemove")]
internal static extern byte OnRemove(IntPtr p); internal static extern byte OnRemove(IntPtr p);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <returns>const char *</returns> /// <returns>const char *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_GetName")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_GetName")]
internal static extern IntPtr GetName(IntPtr p); internal static extern IntPtr GetName(IntPtr p);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="choice">const BaseTurnChoice *</param> /// <param name="choice">const BaseTurnChoice *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnBeforeTurn")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnBeforeTurn")]
internal static extern byte OnBeforeTurn(IntPtr p, IntPtr choice); internal static extern byte OnBeforeTurn(IntPtr p, IntPtr choice);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="choice">AttackTurnChoice *</param> /// <param name="choice">AttackTurnChoice *</param>
/// <param name="outAttack">const char * &</param> /// <param name="outAttack">const char * &</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ChangeAttack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ChangeAttack")]
internal static extern byte ChangeAttack(IntPtr p, IntPtr choice, ref IntPtr outAttack); internal static extern byte ChangeAttack(IntPtr p, IntPtr choice, ref IntPtr outAttack);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="outResult">bool *</param> /// <param name="outResult">bool *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_PreventAttack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_PreventAttack")]
internal static extern byte PreventAttack(IntPtr p, IntPtr attack, IntPtr outResult); internal static extern byte PreventAttack(IntPtr p, IntPtr attack, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="outResult">bool *</param> /// <param name="outResult">bool *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_FailAttack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_FailAttack")]
internal static extern byte FailAttack(IntPtr p, IntPtr attack, IntPtr outResult); internal static extern byte FailAttack(IntPtr p, IntPtr attack, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="outResult">bool *</param> /// <param name="outResult">bool *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_StopBeforeAttack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_StopBeforeAttack")]
internal static extern byte StopBeforeAttack(IntPtr p, IntPtr attack, IntPtr outResult); internal static extern byte StopBeforeAttack(IntPtr p, IntPtr attack, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnBeforeAttack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnBeforeAttack")]
internal static extern byte OnBeforeAttack(IntPtr p, IntPtr attack); internal static extern byte OnBeforeAttack(IntPtr p, IntPtr attack);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="outResult">bool *</param> /// <param name="outResult">bool *</param>
@ -74,7 +74,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_FailIncomingAttack")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_FailIncomingAttack")]
internal static extern byte FailIncomingAttack(IntPtr p, IntPtr attack, IntPtr target, IntPtr outResult); internal static extern byte FailIncomingAttack(IntPtr p, IntPtr attack, IntPtr target, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="outResult">bool *</param> /// <param name="outResult">bool *</param>
@ -82,14 +82,14 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_IsInvulnerable")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_IsInvulnerable")]
internal static extern byte IsInvulnerable(IntPtr p, IntPtr attack, IntPtr target, IntPtr outResult); internal static extern byte IsInvulnerable(IntPtr p, IntPtr attack, IntPtr target, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnAttackMiss")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnAttackMiss")]
internal static extern byte OnAttackMiss(IntPtr p, IntPtr attack, IntPtr target); internal static extern byte OnAttackMiss(IntPtr p, IntPtr attack, IntPtr target);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -98,7 +98,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ChangeAttackType")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ChangeAttackType")]
internal static extern byte ChangeAttackType(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr outType); internal static extern byte ChangeAttackType(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr outType);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -107,7 +107,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OverrideBasePower")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OverrideBasePower")]
internal static extern byte OverrideBasePower(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr basePower); internal static extern byte OverrideBasePower(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr basePower);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -116,7 +116,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ChangeDamageStatsUser")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ChangeDamageStatsUser")]
internal static extern byte ChangeDamageStatsUser(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr statsUser); internal static extern byte ChangeDamageStatsUser(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr statsUser);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -125,7 +125,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_BypassDefensiveStat")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_BypassDefensiveStat")]
internal static extern byte BypassDefensiveStat(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr bypass); internal static extern byte BypassDefensiveStat(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr bypass);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -134,7 +134,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_BypassOffensiveStat")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_BypassOffensiveStat")]
internal static extern byte BypassOffensiveStat(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr bypass); internal static extern byte BypassOffensiveStat(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr bypass);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -143,7 +143,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ModifyStatModifier")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ModifyStatModifier")]
internal static extern byte ModifyStatModifier(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr modifier); internal static extern byte ModifyStatModifier(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr modifier);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -152,7 +152,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ModifyDamageModifier")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ModifyDamageModifier")]
internal static extern byte ModifyDamageModifier(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr modifier); internal static extern byte ModifyDamageModifier(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr modifier);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -161,7 +161,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OverrideDamage")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OverrideDamage")]
internal static extern byte OverrideDamage(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr damage); internal static extern byte OverrideDamage(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr damage);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -170,7 +170,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_PreventSecondaryEffects")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_PreventSecondaryEffects")]
internal static extern byte PreventSecondaryEffects(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr outResult); internal static extern byte PreventSecondaryEffects(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="hitNumber">unsigned char</param> /// <param name="hitNumber">unsigned char</param>
@ -178,21 +178,21 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnSecondaryEffect")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnSecondaryEffect")]
internal static extern byte OnSecondaryEffect(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber); internal static extern byte OnSecondaryEffect(IntPtr p, IntPtr attack, IntPtr target, byte hitNumber);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">ExecutingAttack *</param> /// <param name="attack">ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnAfterHits")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_OnAfterHits")]
internal static extern byte OnAfterHits(IntPtr p, IntPtr attack, IntPtr target); internal static extern byte OnAfterHits(IntPtr p, IntPtr attack, IntPtr target);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="choice">const SwitchTurnChoice *</param> /// <param name="choice">const SwitchTurnChoice *</param>
/// <param name="outResult">bool *</param> /// <param name="outResult">bool *</param>
/// <returns>unsigned char</returns> /// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_PreventSelfSwitch")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_PreventSelfSwitch")]
internal static extern byte PreventSelfSwitch(IntPtr p, IntPtr choice, IntPtr outResult); internal static extern byte PreventSelfSwitch(IntPtr p, IntPtr choice, IntPtr outResult);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">const ExecutingAttack *</param> /// <param name="attack">const ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="chance">float *</param> /// <param name="chance">float *</param>
@ -200,7 +200,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ModifyEffectChance")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_ModifyEffectChance")]
internal static extern byte ModifyEffectChance(IntPtr p, IntPtr attack, IntPtr target, IntPtr chance); internal static extern byte ModifyEffectChance(IntPtr p, IntPtr attack, IntPtr target, IntPtr chance);
/// <param name="p">Script *</param> /// <param name="p">BattleScript *</param>
/// <param name="attack">const ExecutingAttack *</param> /// <param name="attack">const ExecutingAttack *</param>
/// <param name="target">Creature *</param> /// <param name="target">Creature *</param>
/// <param name="chance">float *</param> /// <param name="chance">float *</param>

View File

@ -21,7 +21,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ScriptResolver_Initialize")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ScriptResolver_Initialize")]
internal static extern byte Initialize(IntPtr p, IntPtr library); internal static extern byte Initialize(IntPtr p, IntPtr library);
/// <param name="out">Script * &</param> /// <param name="out">BattleScript * &</param>
/// <param name="p">ScriptResolver *</param> /// <param name="p">ScriptResolver *</param>
/// <param name="category">ScriptCategory</param> /// <param name="category">ScriptCategory</param>
/// <param name="scriptName">const char *</param> /// <param name="scriptName">const char *</param>
@ -29,5 +29,12 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ScriptResolver_LoadScript")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ScriptResolver_LoadScript")]
internal static extern byte LoadScript(ref IntPtr @out, IntPtr p, ScriptCategory category, IntPtr scriptName); internal static extern byte LoadScript(ref IntPtr @out, IntPtr p, ScriptCategory category, IntPtr scriptName);
/// <param name="out">ItemUseScript * &</param>
/// <param name="p">ScriptResolver *</param>
/// <param name="item">const Item *</param>
/// <returns>unsigned char</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ScriptResolver_LoadItemScript")]
internal static extern byte LoadItemScript(ref IntPtr @out, IntPtr p, IntPtr item);
} }
} }

View File

@ -33,7 +33,7 @@ namespace Pkmnlib.Generated
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_FinalizeModule")] [DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_FinalizeModule")]
internal static extern byte FinalizeModule(IntPtr p); internal static extern byte FinalizeModule(IntPtr p);
/// <param name="out">Script * &</param> /// <param name="out">BattleScript * &</param>
/// <param name="p">AngelScriptResolver *</param> /// <param name="p">AngelScriptResolver *</param>
/// <param name="category">ScriptCategory</param> /// <param name="category">ScriptCategory</param>
/// <param name="scriptName">const char *</param> /// <param name="scriptName">const char *</param>

View File

@ -10,12 +10,15 @@ namespace Pkmnlib.Generated
/// <param name="category">ItemCategory</param> /// <param name="category">ItemCategory</param>
/// <param name="battleCategory">BattleItemCategory</param> /// <param name="battleCategory">BattleItemCategory</param>
/// <param name="price">int</param> /// <param name="price">int</param>
/// <param name="effectName">const char *</param>
/// <param name="effectParameters">EffectParameter * *</param>
/// <param name="effectParameterCount">long unsigned int</param>
/// <param name="flags">const char * *</param> /// <param name="flags">const char * *</param>
/// <param name="flagsCount">long unsigned int</param> /// <param name="flagsCount">long unsigned int</param>
/// <param name="flingPower">unsigned char</param> /// <param name="flingPower">unsigned char</param>
/// <returns>Item *</returns> /// <returns>Item *</returns>
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Item_Construct")] [DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Item_Construct")]
internal static extern IntPtr Construct(IntPtr name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr flags, ulong flagsCount, byte flingPower); internal static extern IntPtr Construct(IntPtr name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr effectName, IntPtr effectParameters, ulong effectParameterCount, IntPtr flags, ulong flagsCount, byte flingPower);
/// <param name="p">const Item *</param> /// <param name="p">const Item *</param>
/// <returns>void</returns> /// <returns>void</returns>

View File

@ -7,7 +7,18 @@ namespace PkmnLibSharp.Library.Items
public class Item : PointerWrapper public class Item : PointerWrapper
{ {
private string? _name; private string? _name;
public Item(string name, ItemCategory category, BattleItemCategory battleCategory, int price, string effectName,
EffectParameter[] parameters, string[] flags, byte flingPower)
{
var convertedFlags = flags.Select(x => x.ToPtr()).ToArray().ArrayPtr();
var pars = parameters.Select(x => x.Ptr).ToArray().ArrayPtr();
var p = Pkmnlib.Generated.Item.Construct(name.ToPtr(), (Pkmnlib.ItemCategory) category,
(Pkmnlib.BattleItemCategory) battleCategory, price, effectName.ToPtr(), pars, (ulong) parameters.Length,
convertedFlags, (ulong) flags.Length, flingPower);
Initialize(p);
}
public string Name => _name ??= Creaturelib.Generated.Item.GetName(Ptr).PtrString()!; public string Name => _name ??= Creaturelib.Generated.Item.GetName(Ptr).PtrString()!;
public ItemCategory Category => (ItemCategory) Creaturelib.Generated.Item.GetCategory(Ptr); public ItemCategory Category => (ItemCategory) Creaturelib.Generated.Item.GetCategory(Ptr);
@ -22,16 +33,6 @@ namespace PkmnLibSharp.Library.Items
return Creaturelib.Generated.Item.HasFlag(Ptr, s.ToPtr()) == MarshalHelper.True; return Creaturelib.Generated.Item.HasFlag(Ptr, s.ToPtr()) == MarshalHelper.True;
} }
public Item (string name, ItemCategory category, BattleItemCategory battleCategory,
int price,
string[] flags, byte flingPower)
{
var convertedFlags = flags.Select(x => x.ToPtr()).ToArray().ArrayPtr();
var p = Pkmnlib.Generated.Item.Construct(name.ToPtr(), (Pkmnlib.ItemCategory) category,
(Pkmnlib.BattleItemCategory) battleCategory, price, convertedFlags, (ulong) flags.Length, flingPower);
Initialize(p);
}
public override string ToString() public override string ToString()
{ {
return base.ToString() + $": {Name}"; return base.ToString() + $": {Name}";

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/Windows/libpkmnLib.dll (Stored with Git LFS)

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ namespace PkmnLibSharpTests.Battling
var items = new ItemLibrary(10); var items = new ItemLibrary(10);
items.Insert("testItem", new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.None, items.Insert("testItem", new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.None,
500, new string[] { }, 20)); 500, "", new EffectParameter[0], new string[] { }, 20));
var gr = new GrowthRateLibrary(10); var gr = new GrowthRateLibrary(10);
gr.AddGrowthRate("growthRate", gr.AddGrowthRate("growthRate",
new LookupGrowthRate( new LookupGrowthRate(

View File

@ -18,6 +18,7 @@ namespace PkmnLibSharpTests.Library
public void Insert() public void Insert()
{ {
var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
var library = new ItemLibrary(100); var library = new ItemLibrary(100);
library.Insert("foobar", item); library.Insert("foobar", item);
@ -29,6 +30,7 @@ namespace PkmnLibSharpTests.Library
public void Delete() public void Delete()
{ {
var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
var library = new ItemLibrary(100); var library = new ItemLibrary(100);
library.Insert("foobar", item); library.Insert("foobar", item);
@ -42,6 +44,7 @@ namespace PkmnLibSharpTests.Library
public void Get() public void Get()
{ {
var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
var library = new ItemLibrary(100); var library = new ItemLibrary(100);
library.Insert("foobar", item); library.Insert("foobar", item);
@ -59,6 +62,7 @@ namespace PkmnLibSharpTests.Library
public void TryGet() public void TryGet()
{ {
var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
var library = new ItemLibrary(100); var library = new ItemLibrary(100);
library.Insert("foobar", item); library.Insert("foobar", item);

View File

@ -10,6 +10,7 @@ namespace PkmnLibSharpTests.Library
public void ConstructDestruct() public void ConstructDestruct()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
item.Dispose(); item.Dispose();
} }
@ -17,6 +18,7 @@ namespace PkmnLibSharpTests.Library
public void GetName() public void GetName()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
Assert.AreEqual("foobar", item.Name); Assert.AreEqual("foobar", item.Name);
item.Dispose(); item.Dispose();
@ -25,6 +27,7 @@ namespace PkmnLibSharpTests.Library
public void GetCategory() public void GetCategory()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
Assert.AreEqual(ItemCategory.MiscItem, item.Category); Assert.AreEqual(ItemCategory.MiscItem, item.Category);
item.Dispose(); item.Dispose();
@ -33,6 +36,7 @@ namespace PkmnLibSharpTests.Library
public void GetBattleCategory() public void GetBattleCategory()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
Assert.AreEqual(BattleItemCategory.Healing, item.BattleCategory); Assert.AreEqual(BattleItemCategory.Healing, item.BattleCategory);
item.Dispose(); item.Dispose();
@ -41,6 +45,7 @@ namespace PkmnLibSharpTests.Library
public void GetPrice() public void GetPrice()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
Assert.AreEqual(1000, item.Price); Assert.AreEqual(1000, item.Price);
item.Dispose(); item.Dispose();
@ -49,6 +54,7 @@ namespace PkmnLibSharpTests.Library
public void HasFlag() public void HasFlag()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
Assert.True(item.HasFlag("testFlag")); Assert.True(item.HasFlag("testFlag"));
Assert.False(item.HasFlag("non-existing")); Assert.False(item.HasFlag("non-existing"));
@ -58,6 +64,7 @@ namespace PkmnLibSharpTests.Library
public void GetFlingPower() public void GetFlingPower()
{ {
var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000, var item = new Item("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
"", new EffectParameter[0],
new[] {"testFlag"}, 50); new[] {"testFlag"}, 50);
Assert.AreEqual(50, item.FlingPower); Assert.AreEqual(50, item.FlingPower);
item.Dispose(); item.Dispose();