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.
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
Double click the file configure.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.
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
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
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.
Writes the ocgcore API version numbers at the provided addresses if they're not NULL.
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
.
Deallocates the duel
instance created by OCG_CreateDuel
.
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.
Start the duel
simulation and state machine. Call this after all options and cards for the duel have been loaded.
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 endedOCG_DUEL_STATUS_AWAITING
Player response requiredOCG_DUEL_STATUS_CONTINUE
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.
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.
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 codelength
Size ofbuffer
name
Unique identifier of the script
Returns the number of cards in the specified zone.
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.
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.
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.
See interpreter.cpp
.