node-ygocore
WIP node bindings for ygopro-core (the OCG script engine)
NOTE This is not Ygopro the game!!!
Install
npm install ygocore
How to use
To use this package, you need to know how ocgcore
works.
Note
I'm not the author/contributer of
ygopro
, if my understandings onocgcore
's API are not correct, please fire me an issue. Thanks!
;
this project is writen in Typescript, each method is type-annotated.
Prepare a duel
create a duel instance
ocgapi:
create_duel()
;
set duelist's LP/cards to draw
ocgapi:
set_player_info()
engine.setPlayerInfoduel, ;
add card to the field
ocgapi:
new_card()
engine.newCardduel, ;
Duel!
start the duel
ocgapi:
start_duel()
engine.startDuelduel, options;
process for one step
ocgapi:
process()
,get_message()
;
data
is a buffer (of type Buffer
) contains messages returned from ocgcore
, to deserialize it, you can use ygocore-interface's parseMessage
(see below)
write player's response
ocgapi:
set_responsei()
,set_responseb()
engine.setResponseduel, response;
End the duel
ocgapi:
end_duel()
engine.endDuelduel;
Query the game field
query cards by location
ocgapi:
query_field_card
;
Again, to deserialize the message, you can use ygocore-interface's
parseFieldCardQueryResult
.
query single card
ocgapi:
query_card
;
Again and again, to deserialize the message, you can use ygocore-interface's
parseCardQueryResult
.
query card count
ocgapi:
query_field_count
;
ygocore-interface
;;for of messages
Constants in common.h
are also exported:
;/* .... */;;