No description
Find a file
2024-04-15 22:39:25 +02:00
.github/workflows Update delete-artifact github action 2024-03-02 20:05:43 +01:00
jni Bump project to cpp17 2023-11-24 20:49:19 +01:00
RNG Update copyright for 2024 2024-01-03 01:21:08 +01:00
travis Add android ndk 16b and android ndk 26b to ci targets 2024-01-05 17:31:00 +01:00
.gitattributes Create .gitattributes 2019-09-22 00:33:48 +02:00
.gitignore Update/Import new utilities from the lua scripting library (#151) 2023-12-02 11:08:36 +01:00
Android.mk Define NDEBUG in release builds 2024-03-08 10:22:50 +01:00
bit.h Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
card.cpp Update the way grant effects are sorted 2024-04-01 20:04:32 +02:00
card.h Fix EFFECT_COUNTER_LIMIT handling 2024-02-15 00:43:00 +01:00
common.h Enable assertions while running the clang analyzer 2024-03-09 15:45:29 +01: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 Minor syntax updates 2024-03-08 11:04:41 +01:00
duel.h Address various warnings raised by clang's -Weverything 2024-01-05 15:50:25 +01:00
effect.cpp Update the way grant effects are sorted 2024-04-01 20:04:32 +02:00
effect.h Update the way grant effects are sorted 2024-04-01 20:04:32 +02:00
effect_constants.h Update copyright for 2024 2024-01-03 01:21:08 +01:00
field.cpp Wrap luaL calls so that the lua stack has always at least 5 elements 2024-04-13 10:36:47 +02:00
field.h Make disable_check_set an ordered set 2024-04-01 21:43:21 +02:00
function_array_helper.h Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
group.cpp Update header inclusion 2024-01-05 13:03:46 +01:00
group.h Minor updates 2024-04-02 14:02:23 +02:00
interpreter.cpp Use luaL_loadbufferx directly 2024-04-13 19:03:48 +02:00
interpreter.h Wrap luaL calls so that the lua stack has always at least 5 elements 2024-04-13 10:36:47 +02:00
libcard.cpp Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
libdebug.cpp Wrap luaL calls so that the lua stack has always at least 5 elements 2024-04-13 10:36:47 +02:00
libduel.cpp Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
libeffect.cpp Wrap luaL calls so that the lua stack has always at least 5 elements 2024-04-13 10:36:47 +02:00
libgroup.cpp Assert various warnings when compiling x64 with msvc 2024-04-15 22:39:25 +02:00
LICENSE Update copyright for 2024 2024-01-03 01:21:08 +01:00
lua_obj.h Fix ref_handle in lua_obj not being default initialized 2024-04-08 12:03:50 +02:00
meson.build Restructure the processor handling to use a variant object (#149) 2024-01-08 20:46:41 +01:00
ocgapi.cpp Restructure the processor handling to use a variant object (#149) 2024-01-08 20:46:41 +01:00
ocgapi.h Update copyright for 2024 2024-01-03 01:21:08 +01:00
ocgapi_types.h Update copyright for 2024 2024-01-03 01:21:08 +01:00
operations.cpp Wrap luaL calls so that the lua stack has always at least 5 elements 2024-04-13 10:36:47 +02:00
playerop.cpp Update instances where SortCard was being used 2024-01-13 16:05:50 +01:00
premake5.lua Use luaL_loadbufferx directly 2024-04-13 19:03:48 +02:00
processor.cpp Wrap luaL calls so that the lua stack has always at least 5 elements 2024-04-13 10:36:47 +02:00
processor_unit.h Fix crash in ForcedBattle due to altered `returns` state 2024-03-03 12:58:36 +01:00
processor_visit.cpp Restructure the processor handling to use a variant object (#149) 2024-01-08 20:46:41 +01:00
progressivebuffer.h Address various warnings raised by clang's -Weverything 2024-01-05 15:50:25 +01:00
README.md Added C API documentation to README [ci skip] 2020-02-08 00:23:13 -05:00
scriptlib.cpp Update lua type retrieval and checking 2024-03-02 19:58:42 +01:00
scriptlib.h Minor updates 2024-04-02 14:02:23 +02:00

YGOPro script engine. Build Status

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.

Compiling

See the main EDOPro wiki for details.

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.