Files
yugioh-legacy-engine/binding/YGOLegacy.Engine/EngineApi.cs
T
donnyandClaude Opus 5.5 458c9df105 binding: PromptContext record + codec, FeatureFlags.PromptContext, protocol 12 (TICKET-451, v1.7.0)
StocMessage.PromptContext 0x44, PromptContextCodec (23 bytes),
EngineApi.ygol_query_prompt_context, Capability.ProtocolVersion 12, tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:05:09 -07:00

161 lines
8.5 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace YGOLegacy.Engine
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate IntPtr ScriptReader([MarshalAs(UnmanagedType.LPUTF8Str)] string script_name, int* len);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate uint CardReader(uint code, IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate uint MessageHandler(IntPtr pduel, uint msg_type);
public static unsafe class EngineApi
{
private const string Library = "ygol-engine";
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_script_reader(ScriptReader f);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_card_reader(CardReader f);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_message_handler(MessageHandler f);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr create_duel(uint seed);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr create_duel_v2(uint[] seed_sequence);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr create_duel_ex(uint seed, uint create_flags);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr create_duel_v2_ex(uint[] seed_sequence, uint create_flags);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void start_duel(IntPtr pduel, uint options);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void end_duel(IntPtr pduel);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_player_info(IntPtr pduel, int playerid, int lp, int startcount, int drawcount);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void get_log_message(IntPtr pduel, byte[] buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_message(IntPtr pduel, byte[] buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern uint process(IntPtr pduel);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void new_card(IntPtr pduel, uint code, byte owner, byte playerid, byte location, byte sequence, byte position);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void new_tag_card(IntPtr pduel, uint code, byte owner, byte location);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int query_card(IntPtr pduel, byte playerid, byte location, byte sequence, uint query_flag, byte[] buf, int use_cache);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int query_field_count(IntPtr pduel, byte playerid, byte location);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int query_field_card(IntPtr pduel, byte playerid, byte location, uint query_flag, byte[] buf, int use_cache);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int query_field_info(IntPtr pduel, byte[] buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_responsei(IntPtr pduel, int value);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_responseb(IntPtr pduel, byte[] buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int preload_script(IntPtr pduel, [MarshalAs(UnmanagedType.LPUTF8Str)] string script_name);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr default_script_reader([MarshalAs(UnmanagedType.LPUTF8Str)] string script_name, int* len);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_preview_attack(IntPtr pduel, byte playerid, byte location, byte sequence, byte target_location, byte target_sequence, byte[] @out);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_query_tag_cards(IntPtr pduel, byte playerid, byte[] @out);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_query_prompt_context(IntPtr pduel, byte playerid, byte[] @out);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_registry_value(IntPtr pduel, [MarshalAs(UnmanagedType.LPUTF8Str)] string key, byte[] out_buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void set_registry_value(IntPtr pduel, [MarshalAs(UnmanagedType.LPUTF8Str)] string key, [MarshalAs(UnmanagedType.LPUTF8Str)] string value);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_registry_keys(IntPtr pduel, byte[] out_buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void clear_registry(IntPtr pduel);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int dump_registry(IntPtr pduel, byte[] out_buf);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void load_registry(IntPtr pduel, byte[] in_buf, int in_len);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_lua_coverage_dump_size(IntPtr pduel, [MarshalAs(UnmanagedType.LPUTF8Str)] string name);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int dump_lua_coverage(IntPtr pduel, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, byte[] out_buf, int out_len);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_all_lua_coverages_dump_size(IntPtr pduel);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int dump_all_lua_coverages(IntPtr pduel, byte[] out_buf, int out_len);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void clear_lua_coverage(IntPtr pduel, [MarshalAs(UnmanagedType.LPUTF8Str)] string name);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void clear_all_lua_coverages(IntPtr pduel);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_sb_add(IntPtr pduel, uint code, byte owner, byte playerid, byte location, byte sequence, byte position);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_sb_move(IntPtr pduel, byte playerid, byte location, byte sequence, byte dst_playerid, byte dst_location, byte dst_sequence, byte position);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_sb_remove(IntPtr pduel, byte playerid, byte location, byte sequence);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_sb_set_position(IntPtr pduel, byte playerid, byte location, byte sequence, byte position);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_sb_set_lp(IntPtr pduel, byte playerid, int lp);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int ygol_sb_reask(IntPtr pduel);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern int start_server([MarshalAs(UnmanagedType.LPUTF8Str)] string args);
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern void stop_server();
[DllImport(Library, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ygol_engine_version();
}
}