Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Card.IsTextMention #579

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ int32 card::is_special_summon_set_card(uint32 set_code) {
}
return FALSE;
}
int32 card::is_text_mention(uint32 code) {
if (::is_mention(data.code, code))
return TRUE;
else
return FALSE;
}
uint32 card::get_type() {
if(assume_type == ASSUME_TYPE)
return assume_value;
Expand Down
1 change: 1 addition & 0 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class card {
int32 is_fusion_set_card(uint32 set_code);
int32 is_link_set_card(uint32 set_code);
int32 is_special_summon_set_card(uint32 set_code);
int32 is_text_mention(uint32 code);
uint32 get_type();
uint32 get_fusion_type();
uint32 get_synchro_type();
Expand Down
9 changes: 9 additions & 0 deletions libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ int32 scriptlib::card_is_special_summon_set_card(lua_State *L) {
lua_pushboolean(L, result);
return 1;
}
int32 scriptlib::card_is_text_mention(lua_State* L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1);
uint32 code = (uint32)lua_tointeger(L, 2);
lua_pushboolean(L, pcard->is_text_mention(code));
return 1;
}
int32 scriptlib::card_get_type(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
Expand Down Expand Up @@ -3379,6 +3387,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsFusionSetCard", scriptlib::card_is_fusion_set_card },
{ "IsLinkSetCard", scriptlib::card_is_link_set_card },
{ "IsSpecialSummonSetCard", scriptlib::card_is_special_summon_set_card },
{ "IsTextMention", scriptlib::card_is_text_mention },
{ "GetType", scriptlib::card_get_type },
{ "GetOriginalType", scriptlib::card_get_origin_type },
{ "GetFusionType", scriptlib::card_get_fusion_type },
Expand Down
10 changes: 10 additions & 0 deletions ocgapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
static script_reader sreader = default_script_reader;
static card_reader creader = default_card_reader;
static message_handler mhandler = default_message_handler;
static mention_handler thandler = default_mention_handler;
static byte buffer[0x20000];
static std::set<duel*> duel_set;

Expand All @@ -30,6 +31,9 @@ extern "C" DECL_DLLEXPORT void set_card_reader(card_reader f) {
extern "C" DECL_DLLEXPORT void set_message_handler(message_handler f) {
mhandler = f;
}
extern "C" DECL_DLLEXPORT void set_mention_handler(mention_handler f) {
thandler = f;
}
byte* read_script(const char* script_name, int* len) {
return sreader(script_name, len);
}
Expand All @@ -39,6 +43,9 @@ uint32 read_card(uint32 code, card_data* data) {
uint32 handle_message(void* pduel, uint32 msg_type) {
return mhandler((intptr_t)pduel, msg_type);
}
bool is_mention(uint32 text_code, uint32 name_code) {
return thandler(text_code, name_code);
}
byte* default_script_reader(const char* script_name, int* slen) {
FILE *fp;
fp = std::fopen(script_name, "rb");
Expand All @@ -57,6 +64,9 @@ uint32 default_card_reader(uint32 code, card_data* data) {
uint32 default_message_handler(intptr_t pduel, uint32 message_type) {
return 0;
}
bool default_mention_handler(uint32 text_code, uint32 name_code) {
return false;
}
extern "C" DECL_DLLEXPORT intptr_t create_duel(uint_fast32_t seed) {
duel* pduel = new duel();
duel_set.insert(pduel);
Expand Down
4 changes: 4 additions & 0 deletions ocgapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ class interpreter;
typedef byte* (*script_reader)(const char*, int*);
typedef uint32 (*card_reader)(uint32, card_data*);
typedef uint32 (*message_handler)(intptr_t, uint32);
typedef bool (*mention_handler)(uint32, uint32);

extern "C" DECL_DLLEXPORT void set_script_reader(script_reader f);
extern "C" DECL_DLLEXPORT void set_card_reader(card_reader f);
extern "C" DECL_DLLEXPORT void set_message_handler(message_handler f);
extern "C" DECL_DLLEXPORT void set_mention_handler(mention_handler f);

byte* read_script(const char* script_name, int* len);
uint32 read_card(uint32 code, card_data* data);
uint32 handle_message(void* pduel, uint32 message_type);
bool is_mention(uint32 text_code, uint32 name_code);

extern "C" DECL_DLLEXPORT intptr_t create_duel(uint_fast32_t seed);
extern "C" DECL_DLLEXPORT void start_duel(intptr_t pduel, int32 options);
Expand All @@ -57,5 +60,6 @@ extern "C" DECL_DLLEXPORT int32 preload_script(intptr_t pduel, const char* scrip
byte* default_script_reader(const char* script_name, int* len);
uint32 default_card_reader(uint32 code, card_data* data);
uint32 default_message_handler(intptr_t pduel, uint32 msg_type);
bool default_mention_handler(uint32 text_code, uint32 name_code);

#endif /* OCGAPI_H_ */
1 change: 1 addition & 0 deletions scriptlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class scriptlib {
static int32 card_is_fusion_set_card(lua_State *L);
static int32 card_is_link_set_card(lua_State *L);
static int32 card_is_special_summon_set_card(lua_State *L);
static int32 card_is_text_mention(lua_State* L);
static int32 card_get_type(lua_State *L);
static int32 card_get_origin_type(lua_State *L);
static int32 card_get_fusion_type(lua_State *L);
Expand Down