u8 announce_kind after chain_link, set only while MSG_ANNOUNCE_NUMBER is open: 1 when the script called Duel.AnnounceLevel (it passes playerid + 0x10000 to the unit), else 2 when the asking effect has CATEGORY_DICE and is visible to the answering player, else 0. Contract, changelog, binding PromptContext.AnnounceKind + AnnouncePlain / Level / Dice, codec 24 bytes, probe: plain 0, AnnounceLevel 1, a dice effect's AnnounceNumber 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
142 lines
7.8 KiB
C++
142 lines
7.8 KiB
C++
// contract/ocgapi.h: the public C API of ygol-engine. This file is core/ocgapi.h verbatim plus the
|
|
// server's exports in the block before the final #endif. build/windows.ps1 refuses to build when it
|
|
// differs from those two sources; edit the sources, then this copy, never this copy alone.
|
|
/*
|
|
* interface.h
|
|
*
|
|
* Created on: 2010-4-28
|
|
* Author: Argon
|
|
*/
|
|
|
|
#ifndef OCGAPI_H_
|
|
#define OCGAPI_H_
|
|
|
|
#include "common.h"
|
|
|
|
#ifdef __cplusplus
|
|
#define EXTERN_C extern "C"
|
|
#else
|
|
#define EXTERN_C
|
|
#endif
|
|
|
|
#ifndef OCGCORE_API
|
|
#if defined(__EMSCRIPTEN__)
|
|
#include <emscripten/emscripten.h>
|
|
#define OCGCORE_API EXTERN_C EMSCRIPTEN_KEEPALIVE
|
|
#elif defined(_WIN32)
|
|
#define OCGCORE_API EXTERN_C __declspec(dllexport)
|
|
#else
|
|
#define OCGCORE_API EXTERN_C __attribute__ ((visibility ("default")))
|
|
#endif
|
|
#endif
|
|
|
|
#define SEED_COUNT 8
|
|
|
|
#define LEN_FAIL 0
|
|
#define LEN_EMPTY 4
|
|
#define LEN_HEADER 8
|
|
#define TEMP_CARD_ID 0
|
|
|
|
struct card_data;
|
|
|
|
typedef byte* (*script_reader)(const char* script_name, int* len);
|
|
typedef uint32_t (*card_reader)(uint32_t code, card_data* data);
|
|
typedef uint32_t (*message_handler)(intptr_t pduel, uint32_t msg_type);
|
|
|
|
OCGCORE_API void set_script_reader(script_reader f);
|
|
OCGCORE_API void set_card_reader(card_reader f);
|
|
OCGCORE_API void set_message_handler(message_handler f);
|
|
|
|
byte* read_script(const char* script_name, int* len);
|
|
uint32_t read_card(uint32_t code, card_data* data);
|
|
uint32_t handle_message(void* pduel, uint32_t message_type);
|
|
|
|
OCGCORE_API intptr_t create_duel(uint_fast32_t seed);
|
|
OCGCORE_API intptr_t create_duel_v2(uint32_t seed_sequence[]);
|
|
OCGCORE_API intptr_t create_duel_ex(uint_fast32_t seed, uint32_t create_flags);
|
|
OCGCORE_API intptr_t create_duel_v2_ex(uint32_t seed_sequence[], uint32_t create_flags);
|
|
OCGCORE_API void start_duel(intptr_t pduel, uint32_t options);
|
|
OCGCORE_API void end_duel(intptr_t pduel);
|
|
OCGCORE_API void set_player_info(intptr_t pduel, int32_t playerid, int32_t lp, int32_t startcount, int32_t drawcount);
|
|
OCGCORE_API void get_log_message(intptr_t pduel, char* buf);
|
|
OCGCORE_API int32_t get_message(intptr_t pduel, byte* buf);
|
|
OCGCORE_API uint32_t process(intptr_t pduel);
|
|
OCGCORE_API void new_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position);
|
|
OCGCORE_API void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t location);
|
|
OCGCORE_API 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);
|
|
OCGCORE_API int32_t query_field_count(intptr_t pduel, uint8_t playerid, uint8_t location);
|
|
OCGCORE_API int32_t query_field_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint32_t query_flag, byte* buf, int32_t use_cache);
|
|
OCGCORE_API int32_t query_field_info(intptr_t pduel, byte* buf);
|
|
OCGCORE_API void set_responsei(intptr_t pduel, int32_t value);
|
|
OCGCORE_API void set_responseb(intptr_t pduel, byte* buf);
|
|
OCGCORE_API int32_t preload_script(intptr_t pduel, const char* script_name);
|
|
OCGCORE_API byte* default_script_reader(const char* script_name, int* len);
|
|
|
|
// [YGOL] patch 0022 (attack preview): a read-only dry run of the damage step for one attacker and one
|
|
// target (target_location 0xFF = direct). Returns 1 answered, 0 refused (bad pointer, no such card,
|
|
// attacker not a face-up monster on playerid's field, target not a monster on the other field); a
|
|
// refusal writes nothing. out is 24 bytes: version (1), flags (bit 0 direct, bit 1 unknown, bit 2
|
|
// attacker destroyed, bit 3 target destroyed, bit 4 pierce, bit 5 illegal), 2 pad bytes, then five
|
|
// int32: attacker value, target value, damage to player 0, damage to player 1, reserved 0. A face-down
|
|
// target answers unknown with every number 0. A pair field::get_attack_target would not offer answers
|
|
// illegal alone with every number 0 (patch 0024). Call it only while the engine is parked on a prompt;
|
|
// the duel is byte-identical afterwards (proposal 43).
|
|
OCGCORE_API int32_t ygol_preview_attack(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t target_location, uint8_t target_sequence, uint8_t* out);
|
|
|
|
// [YGOL] v1.2.0 (tag partner cards, TICKET-405): the waiting tag partner's cards of playerid's side, read
|
|
// only. out: version (1), hand count, extra count, one pad byte, uint16 deck count, then the uint32 hand
|
|
// codes, the uint32 extra codes (bit 31 = face-up, like MSG_TAG_SWAP) and the uint32 deck codes sorted
|
|
// ascending (the order stays secret). Returns the byte length, 0 refused (bad pointer, bad player, not a
|
|
// tag duel); a refusal writes nothing. The duel is byte-identical afterwards (proposal 33 Rule 11).
|
|
OCGCORE_API int32_t ygol_query_tag_cards(intptr_t pduel, uint8_t playerid, uint8_t* out);
|
|
|
|
// [YGOL] v1.7.0 (prompt context, TICKET-451): which effect asks the prompt the engine is parked on, read only.
|
|
// playerid = the answering player. out (23 bytes): version (1), has_effect, uint32 code (the handler's current
|
|
// code), controller, location, sequence, position, uint64 description, uint16 effect_index (the order the
|
|
// card's script registered the effect in initial_effect; 0xffff unknown), phase (1 cost, 2 target, 3 operation, 4 the core asks whether to use the effect),
|
|
// chain link (0 none), announce kind (MSG_ANNOUNCE_NUMBER only: 1 Duel.AnnounceLevel, 2 the effect has
|
|
// CATEGORY_DICE and is visible, else 0). has_effect 0 = no effect runs: every other byte 0 but announce kind, effect_index 0xffff. A
|
|
// handler playerid does not control and that is not face-up writes code 0, effect_index 0xffff, description 0.
|
|
// Returns 23, 0 refused (bad pointer, bad player); a refusal writes nothing.
|
|
OCGCORE_API int32_t ygol_query_prompt_context(intptr_t pduel, uint8_t playerid, uint8_t* out);
|
|
|
|
// koishi specific
|
|
OCGCORE_API int32_t get_registry_value(intptr_t pduel, const char* key, byte* out_buf);
|
|
OCGCORE_API void set_registry_value(intptr_t pduel, const char* key, const char* value);
|
|
OCGCORE_API int32_t get_registry_keys(intptr_t pduel, byte* out_buf);
|
|
OCGCORE_API void clear_registry(intptr_t pduel);
|
|
OCGCORE_API int32_t dump_registry(intptr_t pduel, byte* out_buf);
|
|
OCGCORE_API void load_registry(intptr_t pduel, const byte* in_buf, int32_t in_len);
|
|
OCGCORE_API int32_t get_lua_coverage_dump_size(intptr_t pduel, const char* name);
|
|
OCGCORE_API int32_t dump_lua_coverage(intptr_t pduel, const char* name, byte* out_buf, int32_t out_len);
|
|
OCGCORE_API int32_t get_all_lua_coverages_dump_size(intptr_t pduel);
|
|
OCGCORE_API int32_t dump_all_lua_coverages(intptr_t pduel, byte* out_buf, int32_t out_len);
|
|
OCGCORE_API void clear_lua_coverage(intptr_t pduel, const char* name);
|
|
OCGCORE_API void clear_all_lua_coverages(intptr_t pduel);
|
|
|
|
|
|
// [YGOL] patch 0008 (sandbox god mode): additive, Sandbox-only exports. Nothing a normal
|
|
// duel, replay, BotArena or YGOSharp calls. Each returns 1 when it did the work, 0 when it
|
|
// refused and changed nothing.
|
|
OCGCORE_API int32_t ygol_sb_add(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position);
|
|
OCGCORE_API int32_t ygol_sb_move(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t dst_playerid, uint8_t dst_location, uint8_t dst_sequence, uint8_t position);
|
|
OCGCORE_API int32_t ygol_sb_remove(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence);
|
|
OCGCORE_API int32_t ygol_sb_set_position(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position);
|
|
OCGCORE_API int32_t ygol_sb_set_lp(intptr_t pduel, uint8_t playerid, int32_t lp);
|
|
OCGCORE_API int32_t ygol_sb_reask(intptr_t pduel);
|
|
|
|
// --- server exports (server/gframe/serverapi.h); the build fails if these lines differ from it ---
|
|
#define YGOSERVER_API OCGCORE_API
|
|
#ifdef __cplusplus
|
|
namespace ygo {
|
|
#endif
|
|
YGOSERVER_API int start_server(const char* args);
|
|
YGOSERVER_API void stop_server();
|
|
YGOSERVER_API const char* ygol_engine_version();
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
// --- end server exports ---
|
|
|
|
#endif /* OCGAPI_H_ */
|