Commit fe1ce4de authored by Chen Bill's avatar Chen Bill

update ocgapi definition

parent fb30f1e0
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
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. 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 ## Compiling
See [ygopro wiki](https://github.com/Fluorohydride/ygopro/wiki).
### 1.) Download Fluorohydride/ygopro ### 1.) Download Fluorohydride/ygopro
Start by downloading the most parent of the source code. The team developing this project are the de facto edge and experts in our community. The most up-to-date `ocgcore` is a compiled dll version of the `Fluorohydride/ygopro/ocgcore` folders project. Start by downloading the most parent of the source code. The team developing this project are the de facto edge and experts in our community. The most up-to-date `ocgcore` is a compiled dll version of the `Fluorohydride/ygopro/ocgcore` folders project.
...@@ -11,56 +13,83 @@ Start by downloading the most parent of the source code. The team developing thi ...@@ -11,56 +13,83 @@ Start by downloading the most parent of the source code. The team developing thi
Download premake5.exe, put it in `c:\windows` or a similar folder that is globally accessible via `cmd` or PowerShell. Install Visual Studio 2022, it is the system used for the guide because other parts of the project use C# and most the development team are Windows users. Download premake5.exe, put it in `c:\windows` or a similar folder that is globally accessible via `cmd` or PowerShell. Install Visual Studio 2022, it is the system used for the guide because other parts of the project use C# and most the development team are Windows users.
### 3.) Download dependencies ### 3.) Download dependencies
Dependencies are absent from the main project. There is information on how to build them but the easiest thing to do is to download the following folders from a [soarqin/ygopro](https://github.com/soarqin/ygopro) fork and simply copy them into the `Fluorohydride/ygopro` folder.
* event
* freetype
* irrlicht
* lua * lua
* sqlite3
### 4.) Create the project files ### 4.) Create the project files
Run the following commands from the command line in the `Fluorohydride/ygopro` folder. Run the following commands from the command line in the `Fluorohydride/ygopro` folder.
` premake5 vs2022 ` `premake5 vs2022`
If you are not using Visual Studio 2022 or higher, make necessary adjustments. In the file system open `Fluorohydride/ygopro/build` folder open the `ygo` project. If you are not using Visual Studio 2022 or higher, make necessary adjustments. In the file system open `Fluorohydride/ygopro/build` folder open the `ygopro` project.
### 5.) Build the system ### 5.) Build the system
Make sure the code actually compiles. Compile them in the following order one by one: Make sure the code actually compiles. Compile them in the following order one by one:
* lua * lua
* sqlite3
* ocgcore * ocgcore
This should provide you with `ocgcore.lib` in the build output folder. `YGOCore` requires a `*.dll`; in `ocgcore` project properties change it to a dynamically linked library. Recompile, it should fail with an error indicating missing dependencies. Right click the project, add an existing file. Add `lua.lib` from the build folder to the project. It should now compile. This should provide you with `ocgcore.lib` in the build output folder. `YGOCore` requires a `*.dll`; in `ocgcore` project properties change it to a dynamically linked library. Recompile, it should fail with an error indicating missing dependencies. Right click the project, add an existing file. Add `lua.lib` from the build folder to the project. It should now compile.
## Exposed Functions ## Exposed Functions
These three function need to be provided to the core so it can get card and database information. 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_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 `data` table of `cards.cdb`. - `void set_card_reader(card_reader f);`
Interface provided function that provides database information from the `data` table of `cards.cdb`.
- `void set_message_handler(message_handler f);` : Interface provided function that handles errors - `void set_message_handler(message_handler f);`
Interface provided function that handles error messages.
These functions create the game itself and then manipulate it. These functions create the game itself and then manipulate it.
- `ptr create_duel(uint32 seed);` : Create a the instance of the duel using a random number. - `intptr_t create_duel(uint_fast32_t seed);`
- `void start_duel(ptr pduel, int32 options);` : Starts the duel Create a the instance of the duel with a PRNG seed.
- `void end_duel(ptr pduel);` : ends the duel
- `void set_player_info(ptr pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount);` sets the duel up - `void start_duel(intptr_t pduel, int32 options);`
- `void get_log_message(ptr pduel, byte* buf);` Start the duel.
- `int32 get_message(ptr pduel, byte* buf);`
- `int32 process(ptr pduel);` : do a game tick - `void end_duel(intptr_t pduel);`
- `void new_card(ptr pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);` : add a card to the duel state. End the duel.
- `void new_tag_card(ptr pduel, uint32 code, uint8 owner, uint8 location);` : add a new card to the tag pool.
- `int32 query_card(ptr pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache);` : find out about a card in a specific spot. - `void set_player_info(intptr_t pduel, int32 playerid, int32 lp, int32 startcount, int32 drawcount);`
- `int32 query_field_count(ptr pduel, uint8 playerid, uint8 location);` : Get the number of cards in a specific field/zone. Set up the duel information.
- `int32 query_field_card(ptr pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache);`
- `int32 query_field_info(ptr pduel, byte* buf);` - `void get_log_message(intptr_t pduel, char* buf);`
- `void set_responsei(ptr pduel, int32 value);`
- `void set_responseb(ptr pduel, byte* buf);` - `int32 get_message(intptr_t pduel, byte* buf);`
- `int32 preload_script(ptr pduel, char* script, int32 len);`
- `int32 process(intptr_t pduel);`
Do a game tick.
- `void new_card(intptr_t pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position);`
Add a card to the duel state.
- `void new_tag_card(intptr_t pduel, uint32 code, uint8 owner, uint8 location);`
Add a new card to the tag pool.
- `int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache);`
Get a card in a specific location.
- `int32 query_field_count(intptr_t pduel, uint8 playerid, uint8 location);`
Get the number of cards in a specific location.
- `int32 query_field_card(intptr_t pduel, uint8 playerid, uint8 location, uint32 query_flag, byte* buf, int32 use_cache);`
Get all cards in some location.
- `int32 query_field_info(intptr_t pduel, byte* buf);`
- `void set_responsei(intptr_t pduel, int32 value);`
- `void set_responseb(intptr_t pduel, byte* buf);`
- `int32 preload_script(intptr_t pduel, const char* script, int32 len);`
# Lua functions # Lua functions
`interpreter.cpp` - `libcard.cpp`
- `libdebug.cpp`
- `libduel.cpp`
- `libeffect.cpp`
- `libgroup.cpp`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment