Commit 923c6699 authored by mercury233's avatar mercury233 Committed by GitHub

update Group.SelectUnselect to support nil (#444)

parent d8fb6591
......@@ -269,20 +269,23 @@ int32 scriptlib::group_select_unselect(lua_State *L) {
check_action_permission(L);
check_param_count(L, 3);
check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_GROUP, 2);
group* pgroup1 = *(group**)lua_touserdata(L, 1);
group* pgroup2 = *(group**)lua_touserdata(L, 2);
duel* pduel = pgroup1->pduel;
group* select_group = *(group**)lua_touserdata(L, 1);
group* unselect_group = 0;
if(check_param(L, PARAM_TYPE_GROUP, 2, TRUE))
unselect_group = *(group**)lua_touserdata(L, 2);
duel* pduel = select_group->pduel;
uint32 playerid = (uint32)lua_tointeger(L, 3);
if(playerid != 0 && playerid != 1)
return 0;
if(pgroup1->container.size() + pgroup2->container.size() == 0)
if(select_group->container.size() == 0 && (!unselect_group || unselect_group->container.size() == 0))
return 0;
for(auto it = pgroup2->container.begin(); it != pgroup2->container.end(); ++it) {
card* pcard = *it;
for(auto it2 = pgroup1->container.begin(); it2 != pgroup1->container.end(); ++it2) {
if((*it2) == pcard) {
return 0;
if(unselect_group) {
for(auto it = unselect_group->container.begin(); it != unselect_group->container.end(); ++it) {
card* pcard = *it;
for(auto it2 = select_group->container.begin(); it2 != select_group->container.end(); ++it2) {
if((*it2) == pcard) {
return 0;
}
}
}
}
......@@ -306,11 +309,13 @@ int32 scriptlib::group_select_unselect(lua_State *L) {
min = max;
pduel->game_field->core.select_cards.clear();
pduel->game_field->core.unselect_cards.clear();
for(auto it = pgroup1->container.begin(); it != pgroup1->container.end(); ++it) {
for(auto it = select_group->container.begin(); it != select_group->container.end(); ++it) {
pduel->game_field->core.select_cards.push_back(*it);
}
for(auto it = pgroup2->container.begin(); it != pgroup2->container.end(); ++it) {
pduel->game_field->core.unselect_cards.push_back(*it);
if(unselect_group) {
for(auto it = unselect_group->container.begin(); it != unselect_group->container.end(); ++it) {
pduel->game_field->core.unselect_cards.push_back(*it);
}
}
pduel->game_field->add_process(PROCESSOR_SELECT_UNSELECT_CARD, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16), finishable);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
......
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