Files
yugioh-legacy-engine/core
donnyandClaude Fable 5.1 2344e5dae1 tag partner cards: ygol_query_tag_cards + STOC_TAG_PARTNER_CARDS 0x5F, capability 0x2000, protocol 9 (TICKET-405)
Core: ygol_query_tag_cards(pduel, playerid, out) reads the waiting tag
partner's tag_list_hand / tag_list_extra (bit 31 = face-up, like
MSG_TAG_SWAP) and tag_list_main sorted ascending; returns the byte length,
0 when not a tag duel. Read only.

Server: STOC_TAG_PARTNER_CARDS 0x5F = u8 side + those bytes, no stamp, to
that side's two seats only (never the other team, never an observer):
after start_duel, after every MSG_TAG_SWAP, and in a seated duelist's
field resync. FEATURE_TAG_PARTNER_CARDS 0x2000 advertised by single_duel
and tag_duel; FEATURE_PROTOCOL 8 -> 9. 0x800 / 0x1000 stay reserved for
proposals 44 / 45.

Binding: StocMessage.TagPartnerCards, FeatureFlags.TagPartnerCards, the
TagPartnerCards record + StocCodecs.TagPartnerCards,
EngineApi.ygol_query_tag_cards, Capability.ProtocolVersion 9, tests.

Contract rows, CHANGELOG v1.2.0, the probe's tag partner cards room, the
export gates 334 / 855 / 849 -> 335 / 856 / 850.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-15 23:26:39 -07:00
..

YGOPro script engine

Introduction

The core logic and lua script processor of YGOPro. This library can be made external of the project and used to power server technologies. It maintains a state engine that is manipulated by Lua scripts using manipulation functions it exposes.

Compiling

In most cases, what you want to compile is the main program of YGOPro. You should refer to the main YGOPro project's wiki. If you want to compile the dynamic link library of this repository (ocgcore.dll), you can refer to this script.

For WebAssembly builds, use Emscripten 3.1.1 through 3.1.7.

Exposed Functions

The 3 functions need to be provided to the core so it can get card and database information.

  • void set_script_reader(script_reader f);
    Interface provided returns scripts based on number that corresponds to a lua file, send in a string.

  • void set_card_reader(card_reader f);
    Interface provided function that provides database information from the datas table of cards.cdb.

  • void set_message_handler(message_handler f);
    Interface provided function that handles error messages.

These functions create the game itself and then manipulate it.

  • intptr_t create_duel(uint_fast32_t seed);
    (Deprecated) Create an instance of duel with 1 uint32 PRNG seed.
    This function is reserved for replay mode only.

  • intptr_t create_duel_v2(uint32_t seed_sequence[]);
    Create an instance of duel with PRNG seed seed_sequence[] of length SEED_COUNT.

  • void start_duel(intptr_t pduel, uint32_t options);
    Start the duel.

  • void end_duel(intptr_t pduel);
    End the duel.

  • void set_player_info(intptr_t pduel, int32_t playerid, int32_t lp, int32_t startcount, int32_t drawcount);
    Set up the duel information.

  • void get_log_message(intptr_t pduel, char* buf);

  • int32_t get_message(intptr_t pduel, byte* buf);

  • int32_t process(intptr_t pduel);
    Do a game tick.

  • void new_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position);
    Add a card to the duel state.

  • void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t location);
    Add a new card to the tag pool.

  • int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint32_t query_flag, byte* buf, int32_t use_cache);
    Get a card in a specific location.

  • int32_t query_field_count(intptr_t pduel, uint8_t playerid, uint8_t location);
    Get the number of cards in a specific location.

  • int32_t query_field_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint32_t query_flag, byte* buf, int32_t use_cache);
    Get all cards in some location.

  • int32_t query_field_info(intptr_t pduel, byte* buf);

  • void set_responsei(intptr_t pduel, int32_t value);

  • void set_responseb(intptr_t pduel, byte* buf);

  • int32_t preload_script(intptr_t pduel, const char* script_name);

  • byte* default_script_reader(const char* script_name, int* len);
    The default script reader using fread.

Lua functions

  • libcard.cpp
  • libdebug.cpp
  • libduel.cpp
  • libeffect.cpp
  • libgroup.cpp