Commit ab84cd93 authored by Koishi_Mint's avatar Koishi_Mint Committed by nanahira

add GetBinClassCount (#153)

* binlib

* libbin-head

* typo

* Update interpreter.cpp

* Update libgroup.cpp

* Update scriptlib.h
parent 514a7d8f
...@@ -357,6 +357,7 @@ static const struct luaL_Reg grouplib[] = { ...@@ -357,6 +357,7 @@ static const struct luaL_Reg grouplib[] = {
{ "Equal", scriptlib::group_equal }, { "Equal", scriptlib::group_equal },
{ "IsContains", scriptlib::group_is_contains }, { "IsContains", scriptlib::group_is_contains },
{ "SearchCard", scriptlib::group_search_card }, { "SearchCard", scriptlib::group_search_card },
{ "GetBinClassCount", scriptlib::group_get_bin_class_count },
{ NULL, NULL } { NULL, NULL }
}; };
......
...@@ -632,3 +632,22 @@ int32 scriptlib::group_search_card(lua_State *L) { ...@@ -632,3 +632,22 @@ int32 scriptlib::group_search_card(lua_State *L) {
} }
return 0; return 0;
} }
int32 scriptlib::group_get_bin_class_count(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2);
group* pgroup = *(group**) lua_touserdata(L, 1);
duel* pduel = pgroup->pduel;
int32 extraargs = lua_gettop(L) - 2;
int32 er = 0;
for(auto cit = pgroup->container.begin(); cit != pgroup->container.end(); ++cit) {
er |= pduel->lua->get_operation_value(*cit, 2, extraargs);
}
int32 ans = 0;
while(er) {
er &= er - 1;
ans++;
}
lua_pushinteger(L, ans);
return 1;
}
...@@ -354,6 +354,7 @@ public: ...@@ -354,6 +354,7 @@ public:
static int32 group_equal(lua_State *L); static int32 group_equal(lua_State *L);
static int32 group_is_contains(lua_State *L); static int32 group_is_contains(lua_State *L);
static int32 group_search_card(lua_State *L); static int32 group_search_card(lua_State *L);
static int32 group_get_bin_class_count(lua_State *L);
//Duel functions //Duel functions
static int32 duel_enable_global_flag(lua_State *L); static int32 duel_enable_global_flag(lua_State *L);
......
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