No description
Find a file
2026-06-19 17:33:15 +02:00
.github/workflows checkout before installing vs tools in windows builds 2026-04-07 12:16:49 +02:00
jni Always build all the archs for android 2024-08-08 17:25:08 +02:00
lua Use -ffloat-store option when building lmathlib.c with mingw 2025-07-23 19:00:17 +02:00
RNG Update copyright for 2024 2024-01-03 01:21:08 +01:00
scripts Update to mingw lite 16.1.0 2026-06-13 10:41:55 +02:00
.gitattributes Create .gitattributes 2019-09-22 00:33:48 +02:00
.gitignore Add lua as submodule to the repo 2024-09-24 14:27:30 +02:00
.gitmodules Add lua as submodule to the repo 2024-09-24 14:27:30 +02:00
Android.mk Add common-page-size linker flag for android aarch64 2025-08-14 15:43:30 +02:00
bit.h Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
card.cpp pass reason when checking player's EFFECT_CANNOT_TO_GRAVE 2026-06-02 11:01:17 +02:00
card.h pass reason when checking player's EFFECT_CANNOT_TO_GRAVE 2026-06-02 11:01:17 +02:00
common.h Add ocgapi_constants.h 2025-06-25 21:39:39 +02:00
containers_fwd.h Update the way grant effects are sorted 2024-04-01 20:04:32 +02:00
COPYING Convert to AGPL and add Lua licence [ci skip] (#61) 2019-09-19 20:07:58 -04:00
duel.cpp add ocgapi callback to check wether a given set of opcodes allow declaring at least 1 card 2026-06-19 17:33:15 +02:00
duel.h add ocgapi callback to check wether a given set of opcodes allow declaring at least 1 card 2026-06-19 17:33:15 +02:00
effect.cpp Add Effect.RestoreCountLimit 2024-05-19 14:23:57 +02:00
effect.h Make effect's category 64 bits 2026-01-15 20:22:30 +01:00
effect_constants.h add EFFECT_NORMAL_SUMMON_FACEUP_DEFENSE 2026-03-16 21:58:26 +01:00
field.cpp Fix again Duel.ReleaseRitualMaterial 2026-06-07 13:17:07 +02:00
field.h Fix again Duel.ReleaseRitualMaterial 2026-06-07 13:17:07 +02:00
function_array_helper.h add missing LUA_NAMESPACE specifier in GET_LUA_FUNCTIONS_ARRAY 2026-04-04 19:15:25 +02:00
group.h Move Group's lifetime management to Lua (#166) 2025-05-30 23:20:22 +02:00
interpreter.cpp add workaround for bugged luaL_checkstack in lua 5.4 and earlier 2026-05-15 20:20:50 +02:00
interpreter.h Use a lua table to keep track of already loaded scripts 2025-07-12 22:28:56 +02:00
libcard.cpp pass reason when checking player's EFFECT_CANNOT_TO_GRAVE 2026-06-02 11:01:17 +02:00
libdebug.cpp Add extra LUA_NAMESPACE 2025-07-05 19:50:36 +02:00
libduel.cpp add Duel.HasAnnounceableCard 2026-06-19 17:33:15 +02:00
libeffect.cpp Make effect's category 64 bits 2026-01-15 20:22:30 +01:00
libgroup.cpp Add extra LUA_NAMESPACE 2025-07-05 19:50:36 +02:00
LICENSE Update license year 2026-01-15 20:22:30 +01:00
lua_obj.h Fix building as c++20 and later 2025-07-04 15:11:51 +02:00
meson.build Restructure the processor handling to use a variant object (#149) 2024-01-08 20:46:41 +01:00
ocgapi.cpp add ocgapi callback to check wether a given set of opcodes allow declaring at least 1 card 2026-06-19 17:33:15 +02:00
ocgapi.h Don't leak OCGAPI macros from the header 2025-06-25 22:16:55 +02:00
ocgapi_constants.h Add ocgapi_constants.h 2025-06-25 21:39:39 +02:00
ocgapi_types.h add ocgapi callback to check wether a given set of opcodes allow declaring at least 1 card 2026-06-19 17:33:15 +02:00
operations.cpp Properly allow tributing cards from the deck, and extra deck 2026-06-02 21:11:06 +02:00
playerop.cpp Address various clang-20 warnings 2025-06-25 20:55:42 +02:00
premake5.lua premake: Replace flags with appropriate function calls when available 2026-02-20 11:24:53 +01:00
processor.cpp Goat: Fix ignition effs being usable on summons 2025-11-23 13:36:43 +01:00
processor_unit.h fix handling of decktop message in sendto processor 2026-03-06 12:32:47 +01:00
processor_visit.cpp Simplify the check for Processors::NeedsAnswer 2025-06-23 22:31:23 +02:00
progressivebuffer.h Address various warnings raised by clang's -Weverything 2024-01-05 15:50:25 +01:00
README.md Fix wrong filename in readme 2025-04-27 22:28:13 +02:00
scriptlib.cpp Move Group's lifetime management to Lua (#166) 2025-05-30 23:20:22 +02:00
scriptlib.h Update FunctionResult template to use std::__invoke_of on old clang 2026-04-07 12:10:05 +02:00

YGOPro script engine.

A bleeding-edge fork of YGOPro core with updates to accommodate for new cards and features. It is incompatible with forks not derived from this one.

This is the core logic and lua script processor of YGOPro. It maintains a state engine with an exposed API for Lua scripts. This library can be built independently of YGOPro clients and power server technologies.

Building

A C++17 compliant compiler is needed (Visual Studio 2017, GCC 7, Clang 5.0.0 or any newer version) The project uses the lua library, compiled from source alongside the main project and the premake5 build system.

Clone this repo recursively

git clone --recurse-submodules  https://github.com/edo9300/ygopro-core

Visual Studio

Double click the file generate.bat in the scripts folder, select your installed Visual Studio version and it will download the needed resources and generate the Visual Studio solution, which can then be found in build/ocgcore.sln.

Pick the appropriate configuration and architecture and build the solution. The ocgcore solution to build a static library, the ocgcoreshared solution to build a dynamic library.

POSIX (including mingw)

You'll need to have premake5 installed. To manually download premake on your system, run

./scripts/install-premake5.sh linux|windows|macosx #pass the right value according to your os

To configure the project run

./premake5 gmake2

To build run

make -Cbuild TARGET config=CONFIG

TARGET can either be ocgcore to build a static library or ocgcoreshared to build a dynamic library.

CONFIG can either be debug or release, on mingw the values can be instead debug_win32, debug_x64, release_win32, release_x64

Android

You'll need to have the Android NDK installed (r16b or newer) and ndk-build available in your path.

The android project needs no configuration, just run the command

ndk-build

License

EDOPro's core is free/libre and open source software licensed under the GNU Affero General Public License, version 3 or later. Please see LICENSE and COPYING for more details.

Yu-Gi-Oh! is a trademark of Shueisha and Konami. This is not affiliated with or endorsed by Shueisha or Konami.

C API for clients

Informative

void OCG_GetVersion(int* major, int* minor)

Writes the ocgcore API version numbers at the provided addresses if they're not NULL.

Lifecycle

int OCG_CreateDuel(OCG_Duel* duel, OCG_DuelOptions options)

Creates a new duel simulation with the specified options and saves the pointer in duel. No members of options may be NULL pointers or uninitialized. Returns a status code of type OCG_DuelCreationStatus.

void OCG_DestroyDuel(OCG_Duel duel)

Deallocates the duel instance created by OCG_CreateDuel.

void OCG_DuelNewCard(OCG_Duel duel, OCG_NewCardInfo info)

Add the card specified by info to the duel. This calls the provided OCG_DataReader handler with info.code and OCG_ScriptReader if the card script has not been loaded yet.

void OCG_StartDuel(OCG_Duel duel)

Start the duel simulation and state machine. Call this after all options and cards for the duel have been loaded.

Processing a duel

int OCG_DuelProcess(OCG_Duel duel)

Runs the state machine to start the duel or after a waiting state requiring a player response. Returns are OCG_DuelStatus enum values.

  • OCG_DUEL_STATUS_END Duel ended
  • OCG_DUEL_STATUS_AWAITING Player response required
  • OCG_DUEL_STATUS_CONTINUE

void* OCG_DuelGetMessage(OCG_Duel duel, uint32_t* length)

The main interface to the simulation. Returns a pointer to the internal buffer containing all binary messages from the duel simulation. Subsequent calls invalidate previous buffers, so make a copy! The size of the buffer is written to length if it's not NULL.

See common.h for a list of all messages. The best protocol definitions for the message structure may be found at YGOpen.

void OCG_DuelSetResponse(OCG_Duel duel, const void* buffer, uint32_t length)

Sets the next player response for the duel simulation. Subsequent calls overwrite previous responses if not processed. The contents of the provided buffer are copied internally, assuming it contains length bytes.

int OCG_LoadScript(OCG_Duel duel, const char* buffer, uint32_t length, const char* name)

Load a Lua card script or supporting script for the specified duel. Generally you do not call this directly except to load global scripts; instead you want to call this from your OCG_ScriptReader handler provided to OCG_CreateDuel. Returns positive on success and zero on failure.

  • buffer Lua script code
  • length Size of buffer
  • name Unique identifier of the script

Querying active duel states

uint32_t OCG_DuelQueryCount(OCG_Duel duel, uint8_t team, uint32_t loc)

Returns the number of cards in the specified zone.

void* OCG_DuelQuery(OCG_Duel duel, uint32_t* length, OCG_QueryInfo info)

Returns a pointer to an internal buffer for the FIRST card matching the query. The size of the buffer is written to length if it's not NULL. Subsequent calls invalidate previous queries.

void* OCG_DuelQueryLocation(OCG_Duel duel, uint32_t* length, OCG_QueryInfo info)

Returns a pointer to an internal buffer for the ALL cards matching the query. The size of the buffer is written to length if it's not NULL. Subsequent calls invalidate previous queries.

void* OCG_DuelQueryField(OCG_Duel duel, uint32_t* length)

Returns a pointer to an internal buffer containing card counts for every zone in the game. The size of the buffer is written to length if it's not NULL. Subsequent calls invalidate previous queries.

Lua API for card scripts

See interpreter.cpp.