How fluorohydride/ygopro-core works
YGOPro script engine is an embeddable Lua-driven card-duel rules engine. The principal workflow is that a host supplies card and script readers, creates and configures a duel, submits player responses while advancing game ticks, and reads messages and state queries. Lua bindings expose card, duel, effect, group, and debugging capabilities; the rules engine processes duel state and operations. The source index and README support the main subsystem boundaries, but excerpts do not show every internal call, so uncertain links are omitted.
Main entry points: ocgapi.cpp Duel API · field.cpp Field state and rules · scriptlib.h Script interface · duel.cpp Duel instance
Components 20
Host API
- Duel API
ocgapi.cpp - Host callbacks
ocgapi.h
Lua Scripting
- Lua interpreter
interpreter.cpp - Script interface
scriptlib.h - Card bindings
libcard.cpp - Duel bindings
libduel.cpp - Effect bindings
libeffect.cpp - Group bindings
libgroup.cpp - Debug bindings
libdebug.cpp
Duel Rules
- Duel instance
duel.cpp - Duel processor
processor.cpp - Field state and rules
field.cpp - Card operations
operations.cpp - Player operations
playerop.cpp
Game Model
- Card state
card.cpp - Effect state
effect.cpp - Card groups
group.cpp - Shared protocol types
common.h - Message buffer
buffer.h
Other components
- Embedding host
Connections 23
- Embedding host → Duel API: configures and drives
README.md - Embedding host → Host callbacks: provides readers
README.md - Duel API → Duel instance: creates and advances
README.md - Duel API → Host callbacks: uses callbacks
ocgapi.cpp - Duel API → Lua interpreter: preloads scripts
ocgapi.cpp - Duel API → Field state and rules: queries duel state
ocgapi.cpp - Duel API → Message buffer: reads messages
ocgapi.cpp - Duel instance → Lua interpreter: owns interpreter
duel.cpp - Duel instance → Field state and rules: owns field state
duel.cpp - Lua interpreter → Script interface: registers script API
interpreter.cpp - Script interface → Card bindings: declares bindings
scriptlib.h - Script interface → Duel bindings: declares bindings
scriptlib.h - Script interface → Effect bindings: declares bindings
scriptlib.h - Script interface → Group bindings: declares bindings
scriptlib.h - Script interface → Debug bindings: declares bindings
README.md - Duel processor → Field state and rules: processes field state
processor.cpp - Field state and rules → Card state: updates cards
field.cpp - Field state and rules → Effect state: evaluates effects
field.cpp - Card operations → Field state and rules: operates on field
operations.cpp - Player operations → Field state and rules: operates on field
playerop.cpp - Card state → Effect state: filters effects
card.cpp - Duel instance → Card groups: creates groups
- Duel API → Shared protocol types: exposes message types