309 lines
16 KiB
C#
309 lines
16 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using JetBrains.Annotations;
|
|
using PkmnLibSharp.DynamicData;
|
|
using PkmnLibSharp.StaticData;
|
|
using PkmnLibSharp.Utils;
|
|
|
|
namespace PkmnLibSharp.FFI.DynamicData
|
|
{
|
|
internal static class Pokemon
|
|
{
|
|
/// <summary>
|
|
/// Instantiates a new Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern NativeResult<FFIHandleValue> pokemon_new(FFIHandleValue dynamicLibrary,
|
|
FFIHandleValue species, FFIHandleValue form, byte hiddenAbility, byte abilityIndex, LevelInt level,
|
|
uint uniqueIdentifier, Gender gender, byte coloring, IntPtr natureName);
|
|
|
|
/// <summary>
|
|
/// The library data of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_library(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The species of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_species(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The form of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_form(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The species that should be displayed to the user. This handles stuff like the Illusion ability.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_display_species(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The form that should be displayed to the user. This handles stuff like the Illusion ability.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_display_form(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern LevelInt pokemon_level(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern uint pokemon_experience(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern uint pokemon_unique_identifier(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern Gender pokemon_gender(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_coloring(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Gets the held item of a Pokemon
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_held_item(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Checks whether the Pokemon is holding a specific item.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_has_held_item(FFIHandleValue pokemon, IntPtr itemName);
|
|
|
|
/// <summary>
|
|
/// Changes the held item of the Pokemon. Returns the previously held item.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern IdentifiablePointer pokemon_set_held_item(FFIHandleValue pokemon, FFIHandle item);
|
|
|
|
/// <summary>
|
|
/// Removes the held item from the Pokemon. Returns the previously held item.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern IdentifiablePointer pokemon_remove_held_item(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Makes the Pokemon uses its held item.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern NativeResult<byte> pokemon_consume_held_item(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern uint pokemon_current_health(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern uint pokemon_max_health(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern float pokemon_weight(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern float pokemon_height(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// An optional nickname of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern NativeResult<IntPtr> pokemon_nickname(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Whether the actual ability on the form is a hidden ability.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_real_ability_is_hidden(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The index of the actual ability on the form.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_real_ability_index(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern ulong pokemon_types_length(FFIHandleValue pokemon);
|
|
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern NativeResult<TypeIdentifier> pokemon_types_get(FFIHandleValue pokemon, ulong index);
|
|
|
|
/// <summary>
|
|
/// Gets a learned move of the Pokemon. Index should generally be below [`MAX_MOVES`], you will get
|
|
/// a null pointer otherwise.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_learned_move_get(FFIHandleValue pokemon, ulong index);
|
|
|
|
/// <summary>
|
|
/// The stats of the Pokemon when disregarding any stat boosts.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_flat_stats(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The stats of the Pokemon including the stat boosts.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_boosted_stats(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Get the stat boosts for a specific stat.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern sbyte pokemon_get_stat_boost(FFIHandleValue pokemon, Statistic statistic);
|
|
|
|
/// <summary>
|
|
/// Change a boosted stat by a certain amount.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern NativeResult<sbyte> pokemon_change_stat_boost(FFIHandleValue pokemon, Statistic statistic, sbyte diffAmount,
|
|
byte selfInflicted);
|
|
|
|
/// <summary>
|
|
/// Gets a <a href="https://bulbapedia.bulbagarden.net/wiki/Individual_values">individual value</a> of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_get_individual_value(FFIHandleValue pokemon, Statistic statistic);
|
|
|
|
/// <summary>
|
|
/// Modifies a <a href="https://bulbapedia.bulbagarden.net/wiki/Individual_values">individual value</a> of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_set_individual_value(FFIHandleValue pokemon, Statistic statistic, byte value);
|
|
|
|
/// <summary>
|
|
/// Gets a <a href="https://bulbapedia.bulbagarden.net/wiki/Effort_values">effort value</a> of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_get_effort_value(FFIHandleValue pokemon, Statistic statistic);
|
|
|
|
/// <summary>
|
|
/// Modifies a <a href="https://bulbapedia.bulbagarden.net/wiki/Effort_values">effort value</a> of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_set_effort_value(FFIHandleValue pokemon, Statistic statistic, byte value);
|
|
|
|
/// <summary>
|
|
/// Gets the data for the battle the Pokemon is currently in. If the Pokemon is not in a battle, this
|
|
/// returns null.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern IdentifiablePointer pokemon_get_battle(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Get the index of the side of the battle the Pokemon is in. If the Pokemon
|
|
/// is not on the battlefield, this always returns 0.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_get_battle_side_index(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Get the index of the slot on the side of the battle the Pokemon is in. If the Pokemon
|
|
/// is not on the battlefield, this always returns 0.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_get_battle_index(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Returns whether something overrides the ability.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_is_ability_overriden(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Returns the currently active ability.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern NativeResult<FFIHandleValue> pokemon_active_ability(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Whether or not the Pokemon is allowed to gain experience.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_allowed_experience_gain(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// The <a href="https://bulbapedia.bulbagarden.net/wiki/Nature">nature</a> of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern FFIHandleValue pokemon_nature(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Calculates the flat stats on the Pokemon. This should be called when for example the base
|
|
/// stats, level, nature, IV, or EV changes. This has a side effect of recalculating the boosted
|
|
/// stats, as those depend on the flat stats.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_recalculate_flat_stats(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Calculates the boosted stats on the Pokemon. This should be called when a stat boost changes.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_recalculate_boosted_stats(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Change the species of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_change_species(FFIHandleValue pokemon, FFIHandleValue species, FFIHandleValue form);
|
|
|
|
/// <summary>
|
|
/// Change the form of the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_change_form(FFIHandleValue pokemon, FFIHandleValue form);
|
|
|
|
/// <summary>
|
|
/// Whether or not the Pokemon is usable in a battle.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_is_usable(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Returns whether the Pokemon is fainted.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_is_fainted(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Whether or not the Pokemon is on the battlefield.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_is_on_battlefield(FFIHandleValue pokemon);
|
|
|
|
/// <summary>
|
|
/// Damages the Pokemon by a certain amount of damage, from a damage source.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_damage(FFIHandleValue pokemon, uint damage, DamageSource damageSource);
|
|
|
|
/// <summary>
|
|
/// Heals the Pokemon by a specific amount. Unless allowRevive is set to 1, this will not
|
|
/// heal if the Pokemon has 0 health. If the amount healed is 0, this will return false.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern byte pokemon_heal(FFIHandleValue pokemon, uint damage, byte allowRevive);
|
|
|
|
/// <summary>
|
|
/// Learn a move.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
[MustUseReturnValue]
|
|
internal static extern NativeResult pokemon_learn_move(FFIHandleValue pokemon, IntPtr moveName, MoveLearnMethod learnMethod);
|
|
|
|
/// <summary>
|
|
/// Removes the current non-volatile status from the Pokemon.
|
|
/// </summary>
|
|
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern void pokemon_clear_status(FFIHandleValue pokemon);
|
|
}
|
|
} |