Commit 0bc407ca authored by VanillaSalt's avatar VanillaSalt

update select

parent 43b6c09c
...@@ -982,7 +982,7 @@ void field::filter_player_effect(uint8 playerid, uint32 code, effect_set* eset, ...@@ -982,7 +982,7 @@ void field::filter_player_effect(uint8 playerid, uint32 code, effect_set* eset,
if(sort) if(sort)
eset->sort(); eset->sort();
} }
int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, uint32 location2, group* pgroup, card* pexception, uint32 extraargs, card** pret, int32 fcount, int32 is_target) { int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, uint32 location2, group* pgroup, card* pexception, group* pexgroup, uint32 extraargs, card** pret, int32 fcount, int32 is_target) {
if(self != 0 && self != 1) if(self != 0 && self != 1)
return FALSE; return FALSE;
card* pcard; card* pcard;
...@@ -993,7 +993,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -993,7 +993,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
for(uint32 i = 0; i < 5; ++i) { for(uint32 i = 0; i < 5; ++i) {
pcard = player[self].list_mzone[i]; pcard = player[self].list_mzone[i];
if(pcard && !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP) if(pcard && !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP)
&& pcard != pexception && pduel->lua->check_matching(pcard, findex, extraargs) && pcard != pexception && !(pexgroup && pexgroup->has_card(pcard))
&& pduel->lua->check_matching(pcard, findex, extraargs)
&& (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = pcard; *pret = pcard;
...@@ -1011,7 +1012,9 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1011,7 +1012,9 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
if(location & LOCATION_SZONE) { if(location & LOCATION_SZONE) {
for(uint32 i = 0; i < 8; ++i) { for(uint32 i = 0; i < 8; ++i) {
pcard = player[self].list_szone[i]; pcard = player[self].list_szone[i];
if(pcard && !pcard->is_status(STATUS_ACTIVATE_DISABLED) && pcard != pexception && pduel->lua->check_matching(pcard, findex, extraargs) if(pcard && !pcard->is_status(STATUS_ACTIVATE_DISABLED)
&& pcard != pexception && !(pexgroup && pexgroup->has_card(pcard))
&& pduel->lua->check_matching(pcard, findex, extraargs)
&& (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = pcard; *pret = pcard;
...@@ -1028,7 +1031,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1028,7 +1031,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_DECK) { if(location & LOCATION_DECK) {
for(auto cit = player[self].list_main.rbegin(); cit != player[self].list_main.rend(); ++cit) { for(auto cit = player[self].list_main.rbegin(); cit != player[self].list_main.rend(); ++cit) {
if(*cit != pexception && pduel->lua->check_matching(*cit, findex, extraargs) if(*cit != pexception && !(pexgroup && pexgroup->has_card(*cit))
&& pduel->lua->check_matching(*cit, findex, extraargs)
&& (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = *cit; *pret = *cit;
...@@ -1045,7 +1049,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1045,7 +1049,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_EXTRA) { if(location & LOCATION_EXTRA) {
for(auto cit = player[self].list_extra.rbegin(); cit != player[self].list_extra.rend(); ++cit) { for(auto cit = player[self].list_extra.rbegin(); cit != player[self].list_extra.rend(); ++cit) {
if(*cit != pexception && pduel->lua->check_matching(*cit, findex, extraargs) if(*cit != pexception && !(pexgroup && pexgroup->has_card(*cit))
&& pduel->lua->check_matching(*cit, findex, extraargs)
&& (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = *cit; *pret = *cit;
...@@ -1062,7 +1067,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1062,7 +1067,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_HAND) { if(location & LOCATION_HAND) {
for(auto cit = player[self].list_hand.begin(); cit != player[self].list_hand.end(); ++cit) { for(auto cit = player[self].list_hand.begin(); cit != player[self].list_hand.end(); ++cit) {
if(*cit != pexception && pduel->lua->check_matching(*cit, findex, extraargs) if(*cit != pexception && !(pexgroup && pexgroup->has_card(*cit))
&& pduel->lua->check_matching(*cit, findex, extraargs)
&& (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = *cit; *pret = *cit;
...@@ -1079,7 +1085,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1079,7 +1085,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_GRAVE) { if(location & LOCATION_GRAVE) {
for(auto cit = player[self].list_grave.rbegin(); cit != player[self].list_grave.rend(); ++cit) { for(auto cit = player[self].list_grave.rbegin(); cit != player[self].list_grave.rend(); ++cit) {
if(*cit != pexception && pduel->lua->check_matching(*cit, findex, extraargs) if(*cit != pexception && !(pexgroup && pexgroup->has_card(*cit))
&& pduel->lua->check_matching(*cit, findex, extraargs)
&& (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = *cit; *pret = *cit;
...@@ -1096,7 +1103,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1096,7 +1103,8 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_REMOVED) { if(location & LOCATION_REMOVED) {
for(auto cit = player[self].list_remove.rbegin(); cit != player[self].list_remove.rend(); ++cit) { for(auto cit = player[self].list_remove.rbegin(); cit != player[self].list_remove.rend(); ++cit) {
if(*cit != pexception && pduel->lua->check_matching(*cit, findex, extraargs) if(*cit != pexception && !(pexgroup && pexgroup->has_card(*cit))
&& pduel->lua->check_matching(*cit, findex, extraargs)
&& (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) { && (!is_target || (*cit)->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
if(pret) { if(pret) {
*pret = *cit; *pret = *cit;
...@@ -1183,12 +1191,12 @@ effect* field::is_player_affected_by_effect(uint8 playerid, uint32 code) { ...@@ -1183,12 +1191,12 @@ effect* field::is_player_affected_by_effect(uint8 playerid, uint32 code) {
} }
return 0; return 0;
} }
int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp) { int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg) {
card* pcard; card* pcard;
uint32 rcount = 0; uint32 rcount = 0;
for(uint32 i = 0; i < 5; ++i) { for(uint32 i = 0; i < 5; ++i) {
pcard = player[playerid].list_mzone[i]; pcard = player[playerid].list_mzone[i];
if(pcard && pcard != exp && pcard->is_releasable_by_nonsummon(playerid) if(pcard && pcard != exc && !(exg && exg->has_card(pcard)) && pcard->is_releasable_by_nonsummon(playerid)
&& (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) { && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) {
if(release_list) if(release_list)
release_list->insert(pcard); release_list->insert(pcard);
...@@ -1199,7 +1207,7 @@ int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set* ...@@ -1199,7 +1207,7 @@ int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set*
if(use_hand) { if(use_hand) {
for(uint32 i = 0; i < player[playerid].list_hand.size(); ++i) { for(uint32 i = 0; i < player[playerid].list_hand.size(); ++i) {
pcard = player[playerid].list_hand[i]; pcard = player[playerid].list_hand[i];
if(pcard && pcard != exp && pcard->is_releasable_by_nonsummon(playerid) if(pcard && pcard != exc && !(exg && exg->has_card(pcard)) && pcard->is_releasable_by_nonsummon(playerid)
&& (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) { && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) {
if(release_list) if(release_list)
release_list->insert(pcard); release_list->insert(pcard);
...@@ -1210,7 +1218,7 @@ int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set* ...@@ -1210,7 +1218,7 @@ int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set*
} }
for(uint32 i = 0; i < 5; ++i) { for(uint32 i = 0; i < 5; ++i) {
pcard = player[1 - playerid].list_mzone[i]; pcard = player[1 - playerid].list_mzone[i];
if(pcard && pcard != exp && (pcard->is_position(POS_FACEUP) || !use_con) && pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE) if(pcard && pcard != exc && !(exg && exg->has_card(pcard)) && (pcard->is_position(POS_FACEUP) || !use_con) && pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE)
&& pcard->is_releasable_by_nonsummon(playerid) && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) { && pcard->is_releasable_by_nonsummon(playerid) && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) {
if(ex_list) if(ex_list)
ex_list->insert(pcard); ex_list->insert(pcard);
...@@ -1220,11 +1228,11 @@ int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set* ...@@ -1220,11 +1228,11 @@ int32 field::get_release_list(uint8 playerid, card_set* release_list, card_set*
} }
return rcount; return rcount;
} }
int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp) { int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg) {
card* pcard; card* pcard;
for(uint32 i = 0; i < 5; ++i) { for(uint32 i = 0; i < 5; ++i) {
pcard = player[playerid].list_mzone[i]; pcard = player[playerid].list_mzone[i];
if(pcard && pcard != exp && pcard->is_releasable_by_nonsummon(playerid) if(pcard && pcard != exc && !(exg && exg->has_card(pcard)) && pcard->is_releasable_by_nonsummon(playerid)
&& (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) { && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) {
count--; count--;
if(count == 0) if(count == 0)
...@@ -1234,7 +1242,7 @@ int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int3 ...@@ -1234,7 +1242,7 @@ int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int3
if(use_hand) { if(use_hand) {
for(uint32 i = 0; i < player[playerid].list_hand.size(); ++i) { for(uint32 i = 0; i < player[playerid].list_hand.size(); ++i) {
pcard = player[playerid].list_hand[i]; pcard = player[playerid].list_hand[i];
if(pcard && pcard != exp && pcard->is_releasable_by_nonsummon(playerid) if(pcard && pcard != exc && !(exg && exg->has_card(pcard)) && pcard->is_releasable_by_nonsummon(playerid)
&& (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) { && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) {
count--; count--;
if(count == 0) if(count == 0)
...@@ -1244,7 +1252,7 @@ int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int3 ...@@ -1244,7 +1252,7 @@ int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int3
} }
for(uint32 i = 0; i < 5; ++i) { for(uint32 i = 0; i < 5; ++i) {
pcard = player[1 - playerid].list_mzone[i]; pcard = player[1 - playerid].list_mzone[i];
if(pcard && pcard != exp && (!use_con || pcard->is_position(POS_FACEUP)) && pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE) if(pcard && pcard != exc && !(exg && exg->has_card(pcard)) && (!use_con || pcard->is_position(POS_FACEUP)) && pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE)
&& pcard->is_releasable_by_nonsummon(playerid) && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) { && pcard->is_releasable_by_nonsummon(playerid) && (!use_con || pduel->lua->check_matching(pcard, fun, exarg))) {
count--; count--;
if(count == 0) if(count == 0)
......
...@@ -359,12 +359,12 @@ public: ...@@ -359,12 +359,12 @@ public:
void filter_field_effect(uint32 code, effect_set* eset, uint8 sort = TRUE); void filter_field_effect(uint32 code, effect_set* eset, uint8 sort = TRUE);
void filter_affected_cards(effect* peffect, card_set* cset); void filter_affected_cards(effect* peffect, card_set* cset);
void filter_player_effect(uint8 playerid, uint32 code, effect_set* eset, uint8 sort = TRUE); void filter_player_effect(uint8 playerid, uint32 code, effect_set* eset, uint8 sort = TRUE);
int32 filter_matching_card(int32 findex, uint8 self, uint32 location1, uint32 location2, group* pgroup, card* pexception, uint32 extraargs, card** pret = 0, int32 fcount = 0, int32 is_target = FALSE); int32 filter_matching_card(int32 findex, uint8 self, uint32 location1, uint32 location2, group* pgroup, card* pexception, group* pexgroup, uint32 extraargs, card** pret = 0, int32 fcount = 0, int32 is_target = FALSE);
int32 filter_field_card(uint8 self, uint32 location, uint32 location2, group* pgroup); int32 filter_field_card(uint8 self, uint32 location, uint32 location2, group* pgroup);
effect* is_player_affected_by_effect(uint8 playerid, uint32 code); effect* is_player_affected_by_effect(uint8 playerid, uint32 code);
int32 get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp); int32 get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg);
int32 check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp); int32 check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exc, group* exg);
int32 get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg = NULL, uint32 ex = 0); int32 get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg = NULL, uint32 ex = 0);
int32 get_summon_count_limit(uint8 playerid); int32 get_summon_count_limit(uint8 playerid);
int32 get_draw_count(uint8 playerid); int32 get_draw_count(uint8 playerid);
......
...@@ -1126,12 +1126,13 @@ int32 scriptlib::duel_discard_hand(lua_State *L) { ...@@ -1126,12 +1126,13 @@ int32 scriptlib::duel_discard_hand(lua_State *L) {
if(!lua_isnil(L, 2)) if(!lua_isnil(L, 2))
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pexception = 0; card* pexception = 0;
group* pexgroup = 0;
uint32 extraargs = 0; uint32 extraargs = 0;
if(lua_gettop(L) >= 6) { if(lua_gettop(L) >= 6) {
if(!lua_isnil(L, 6)) { if(check_param(L, PARAM_TYPE_CARD, 6, TRUE))
check_param(L, PARAM_TYPE_CARD, 6);
pexception = *(card**) lua_touserdata(L, 6); pexception = *(card**) lua_touserdata(L, 6);
} else if(check_param(L, PARAM_TYPE_GROUP, 6, TRUE))
pexgroup = *(group**) lua_touserdata(L, 6);
extraargs = lua_gettop(L) - 6; extraargs = lua_gettop(L) - 6;
} }
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
...@@ -1140,7 +1141,7 @@ int32 scriptlib::duel_discard_hand(lua_State *L) { ...@@ -1140,7 +1141,7 @@ int32 scriptlib::duel_discard_hand(lua_State *L) {
uint32 max = lua_tointeger(L, 4); uint32 max = lua_tointeger(L, 4);
uint32 reason = lua_tointeger(L, 5); uint32 reason = lua_tointeger(L, 5);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pduel->game_field->filter_matching_card(2, playerid, LOCATION_HAND, 0, pgroup, pexception, extraargs); pduel->game_field->filter_matching_card(2, playerid, LOCATION_HAND, 0, pgroup, pexception, pexgroup, extraargs);
pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end()); pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end());
if(pduel->game_field->core.select_cards.size() == 0) { if(pduel->game_field->core.select_cards.size() == 0) {
lua_pushinteger(L, 0); lua_pushinteger(L, 0);
...@@ -1730,18 +1731,18 @@ int32 scriptlib::duel_get_matching_group(lua_State *L) { ...@@ -1730,18 +1731,18 @@ int32 scriptlib::duel_get_matching_group(lua_State *L) {
if(!lua_isnil(L, 1)) if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 5)) { if(check_param(L, PARAM_TYPE_CARD, 5, TRUE))
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5); pexception = *(card**) lua_touserdata(L, 5);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE))
extraargs = lua_gettop(L) - 5; pexgroup = *(group**) lua_touserdata(L, 5);
uint32 extraargs = lua_gettop(L) - 5;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 self = lua_tointeger(L, 2); uint32 self = lua_tointeger(L, 2);
uint32 location1 = lua_tointeger(L, 3); uint32 location1 = lua_tointeger(L, 3);
uint32 location2 = lua_tointeger(L, 4); uint32 location2 = lua_tointeger(L, 4);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, pgroup, pexception, extraargs); pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, pgroup, pexception, pexgroup, extraargs);
interpreter::group2value(L, pgroup); interpreter::group2value(L, pgroup);
return 1; return 1;
} }
...@@ -1755,18 +1756,18 @@ int32 scriptlib::duel_get_matching_count(lua_State *L) { ...@@ -1755,18 +1756,18 @@ int32 scriptlib::duel_get_matching_count(lua_State *L) {
if(!lua_isnil(L, 1)) if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 5)) { if(check_param(L, PARAM_TYPE_CARD, 5, TRUE))
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5); pexception = *(card**) lua_touserdata(L, 5);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE))
extraargs = lua_gettop(L) - 5; pexgroup = *(group**) lua_touserdata(L, 5);
uint32 extraargs = lua_gettop(L) - 5;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 self = lua_tointeger(L, 2); uint32 self = lua_tointeger(L, 2);
uint32 location1 = lua_tointeger(L, 3); uint32 location1 = lua_tointeger(L, 3);
uint32 location2 = lua_tointeger(L, 4); uint32 location2 = lua_tointeger(L, 4);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, pgroup, pexception, extraargs); pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, pgroup, pexception, pexgroup, extraargs);
uint32 count = pgroup->container.size(); uint32 count = pgroup->container.size();
lua_pushinteger(L, count); lua_pushinteger(L, count);
return 1; return 1;
...@@ -1781,18 +1782,18 @@ int32 scriptlib::duel_get_first_matching_card(lua_State *L) { ...@@ -1781,18 +1782,18 @@ int32 scriptlib::duel_get_first_matching_card(lua_State *L) {
if(!lua_isnil(L, 1)) if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 5)) { if(check_param(L, PARAM_TYPE_CARD, 5, TRUE))
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5); pexception = *(card**) lua_touserdata(L, 5);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE))
extraargs = lua_gettop(L) - 5; pexgroup = *(group**) lua_touserdata(L, 5);
uint32 extraargs = lua_gettop(L) - 5;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 self = lua_tointeger(L, 2); uint32 self = lua_tointeger(L, 2);
uint32 location1 = lua_tointeger(L, 3); uint32 location1 = lua_tointeger(L, 3);
uint32 location2 = lua_tointeger(L, 4); uint32 location2 = lua_tointeger(L, 4);
card* pret = 0; card* pret = 0;
pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, 0, pexception, extraargs, &pret); pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, 0, pexception, pexgroup, extraargs, &pret);
if(pret) if(pret)
interpreter::card2value(L, pret); interpreter::card2value(L, pret);
else lua_pushnil(L); else lua_pushnil(L);
...@@ -1808,18 +1809,18 @@ int32 scriptlib::duel_is_existing_matching_card(lua_State *L) { ...@@ -1808,18 +1809,18 @@ int32 scriptlib::duel_is_existing_matching_card(lua_State *L) {
if(!lua_isnil(L, 1)) if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 6)) { if(check_param(L, PARAM_TYPE_CARD, 6, TRUE))
check_param(L, PARAM_TYPE_CARD, 6);
pexception = *(card**) lua_touserdata(L, 6); pexception = *(card**) lua_touserdata(L, 6);
} else if(check_param(L, PARAM_TYPE_GROUP, 6, TRUE))
extraargs = lua_gettop(L) - 6; pexgroup = *(group**) lua_touserdata(L, 6);
uint32 extraargs = lua_gettop(L) - 6;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 self = lua_tointeger(L, 2); uint32 self = lua_tointeger(L, 2);
uint32 location1 = lua_tointeger(L, 3); uint32 location1 = lua_tointeger(L, 3);
uint32 location2 = lua_tointeger(L, 4); uint32 location2 = lua_tointeger(L, 4);
uint32 fcount = lua_tointeger(L, 5); uint32 fcount = lua_tointeger(L, 5);
lua_pushboolean(L, pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, 0, pexception, extraargs, 0, fcount)); lua_pushboolean(L, pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, 0, pexception, pexgroup, extraargs, 0, fcount));
return 1; return 1;
} }
/** /**
...@@ -1833,12 +1834,12 @@ int32 scriptlib::duel_select_matching_cards(lua_State *L) { ...@@ -1833,12 +1834,12 @@ int32 scriptlib::duel_select_matching_cards(lua_State *L) {
if(!lua_isnil(L, 2)) if(!lua_isnil(L, 2))
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 8)) { if(check_param(L, PARAM_TYPE_CARD, 8, TRUE))
check_param(L, PARAM_TYPE_CARD, 8);
pexception = *(card**) lua_touserdata(L, 8); pexception = *(card**) lua_touserdata(L, 8);
} else if(check_param(L, PARAM_TYPE_GROUP, 8, TRUE))
extraargs = lua_gettop(L) - 8; pexgroup = *(group**) lua_touserdata(L, 8);
uint32 extraargs = lua_gettop(L) - 8;
uint32 playerid = lua_tointeger(L, 1); uint32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
...@@ -1849,7 +1850,7 @@ int32 scriptlib::duel_select_matching_cards(lua_State *L) { ...@@ -1849,7 +1850,7 @@ int32 scriptlib::duel_select_matching_cards(lua_State *L) {
uint32 min = lua_tointeger(L, 6); uint32 min = lua_tointeger(L, 6);
uint32 max = lua_tointeger(L, 7); uint32 max = lua_tointeger(L, 7);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pduel->game_field->filter_matching_card(2, (uint8)self, location1, location2, pgroup, pexception, extraargs); pduel->game_field->filter_matching_card(2, (uint8)self, location1, location2, pgroup, pexception, pexgroup, extraargs);
pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end()); pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end());
pduel->game_field->add_process(PROCESSOR_SELECT_CARD_S, 0, 0, 0, playerid, min + (max << 16)); pduel->game_field->add_process(PROCESSOR_SELECT_CARD_S, 0, 0, 0, playerid, min + (max << 16));
return lua_yield(L, 0); return lua_yield(L, 0);
...@@ -1869,7 +1870,7 @@ int32 scriptlib::duel_get_release_group(lua_State *L) { ...@@ -1869,7 +1870,7 @@ int32 scriptlib::duel_get_release_group(lua_State *L) {
hand = lua_toboolean(L, 2); hand = lua_toboolean(L, 2);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pduel->game_field->get_release_list(playerid, &(pgroup->container), &(pgroup->container), FALSE, hand, 0, 0, 0); pduel->game_field->get_release_list(playerid, &(pgroup->container), &(pgroup->container), FALSE, hand, 0, 0, 0, 0);
interpreter::group2value(L, pgroup); interpreter::group2value(L, pgroup);
return 1; return 1;
} }
...@@ -1887,7 +1888,7 @@ int32 scriptlib::duel_get_release_group_count(lua_State *L) { ...@@ -1887,7 +1888,7 @@ int32 scriptlib::duel_get_release_group_count(lua_State *L) {
if(lua_gettop(L) > 1) if(lua_gettop(L) > 1)
hand = lua_toboolean(L, 2); hand = lua_toboolean(L, 2);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
lua_pushinteger(L, pduel->game_field->get_release_list(playerid, 0, 0, FALSE, hand, 0, 0, 0)); lua_pushinteger(L, pduel->game_field->get_release_list(playerid, 0, 0, FALSE, hand, 0, 0, 0, 0));
return 1; return 1;
} }
int32 scriptlib::duel_check_release_group(lua_State *L) { int32 scriptlib::duel_check_release_group(lua_State *L) {
...@@ -1901,15 +1902,15 @@ int32 scriptlib::duel_check_release_group(lua_State *L) { ...@@ -1901,15 +1902,15 @@ int32 scriptlib::duel_check_release_group(lua_State *L) {
use_con = TRUE; use_con = TRUE;
} }
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 4)) { if(check_param(L, PARAM_TYPE_CARD, 4, TRUE))
check_param(L, PARAM_TYPE_CARD, 4);
pexception = *(card**) lua_touserdata(L, 4); pexception = *(card**) lua_touserdata(L, 4);
} else if(check_param(L, PARAM_TYPE_GROUP, 4, TRUE))
extraargs = lua_gettop(L) - 4; pexgroup = *(group**) lua_touserdata(L, 4);
uint32 extraargs = lua_gettop(L) - 4;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 fcount = lua_tointeger(L, 3); uint32 fcount = lua_tointeger(L, 3);
lua_pushboolean(L, pduel->game_field->check_release_list(playerid, fcount, use_con, FALSE, 2, extraargs, pexception)); lua_pushboolean(L, pduel->game_field->check_release_list(playerid, fcount, use_con, FALSE, 2, extraargs, pexception, pexgroup));
return 1; return 1;
} }
int32 scriptlib::duel_select_release_group(lua_State *L) { int32 scriptlib::duel_select_release_group(lua_State *L) {
...@@ -1924,18 +1925,18 @@ int32 scriptlib::duel_select_release_group(lua_State *L) { ...@@ -1924,18 +1925,18 @@ int32 scriptlib::duel_select_release_group(lua_State *L) {
use_con = TRUE; use_con = TRUE;
} }
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 5)) { if(check_param(L, PARAM_TYPE_CARD, 5, TRUE))
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5); pexception = *(card**) lua_touserdata(L, 5);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE))
extraargs = lua_gettop(L) - 5; pexgroup = *(group**) lua_touserdata(L, 5);
uint32 extraargs = lua_gettop(L) - 5;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 min = lua_tointeger(L, 3); uint32 min = lua_tointeger(L, 3);
uint32 max = lua_tointeger(L, 4); uint32 max = lua_tointeger(L, 4);
pduel->game_field->core.release_cards.clear(); pduel->game_field->core.release_cards.clear();
pduel->game_field->core.release_cards_ex.clear(); pduel->game_field->core.release_cards_ex.clear();
pduel->game_field->get_release_list(playerid, &pduel->game_field->core.release_cards, &pduel->game_field->core.release_cards_ex, use_con, FALSE, 2, extraargs, pexception); pduel->game_field->get_release_list(playerid, &pduel->game_field->core.release_cards, &pduel->game_field->core.release_cards_ex, use_con, FALSE, 2, extraargs, pexception, pexgroup);
pduel->game_field->add_process(PROCESSOR_SELECT_RELEASE_S, 0, 0, 0, playerid, (max << 16) + min); pduel->game_field->add_process(PROCESSOR_SELECT_RELEASE_S, 0, 0, 0, playerid, (max << 16) + min);
return lua_yield(L, 0); return lua_yield(L, 0);
} }
...@@ -1950,15 +1951,15 @@ int32 scriptlib::duel_check_release_group_ex(lua_State *L) { ...@@ -1950,15 +1951,15 @@ int32 scriptlib::duel_check_release_group_ex(lua_State *L) {
use_con = TRUE; use_con = TRUE;
} }
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 4)) { if(check_param(L, PARAM_TYPE_CARD, 4, TRUE))
check_param(L, PARAM_TYPE_CARD, 4);
pexception = *(card**) lua_touserdata(L, 4); pexception = *(card**) lua_touserdata(L, 4);
} else if(check_param(L, PARAM_TYPE_GROUP, 4, TRUE))
extraargs = lua_gettop(L) - 4; pexgroup = *(group**) lua_touserdata(L, 4);
uint32 extraargs = lua_gettop(L) - 4;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 fcount = lua_tointeger(L, 3); uint32 fcount = lua_tointeger(L, 3);
lua_pushboolean(L, pduel->game_field->check_release_list(playerid, fcount, use_con, TRUE, 2, extraargs, pexception)); lua_pushboolean(L, pduel->game_field->check_release_list(playerid, fcount, use_con, TRUE, 2, extraargs, pexception, pexgroup));
return 1; return 1;
} }
int32 scriptlib::duel_select_release_group_ex(lua_State *L) { int32 scriptlib::duel_select_release_group_ex(lua_State *L) {
...@@ -1973,18 +1974,18 @@ int32 scriptlib::duel_select_release_group_ex(lua_State *L) { ...@@ -1973,18 +1974,18 @@ int32 scriptlib::duel_select_release_group_ex(lua_State *L) {
use_con = TRUE; use_con = TRUE;
} }
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 5)) { if(check_param(L, PARAM_TYPE_CARD, 5, TRUE))
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5); pexception = *(card**) lua_touserdata(L, 5);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE))
extraargs = lua_gettop(L) - 5; pexgroup = *(group**) lua_touserdata(L, 5);
uint32 extraargs = lua_gettop(L) - 5;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 min = lua_tointeger(L, 3); uint32 min = lua_tointeger(L, 3);
uint32 max = lua_tointeger(L, 4); uint32 max = lua_tointeger(L, 4);
pduel->game_field->core.release_cards.clear(); pduel->game_field->core.release_cards.clear();
pduel->game_field->core.release_cards_ex.clear(); pduel->game_field->core.release_cards_ex.clear();
pduel->game_field->get_release_list(playerid, &pduel->game_field->core.release_cards, &pduel->game_field->core.release_cards_ex, use_con, TRUE, 2, extraargs, pexception); pduel->game_field->get_release_list(playerid, &pduel->game_field->core.release_cards, &pduel->game_field->core.release_cards_ex, use_con, TRUE, 2, extraargs, pexception, pexgroup);
pduel->game_field->add_process(PROCESSOR_SELECT_RELEASE_S, 0, 0, 0, playerid, (max << 16) + min); pduel->game_field->add_process(PROCESSOR_SELECT_RELEASE_S, 0, 0, 0, playerid, (max << 16) + min);
return lua_yield(L, 0); return lua_yield(L, 0);
} }
...@@ -2080,19 +2081,19 @@ int32 scriptlib::duel_get_target_count(lua_State *L) { ...@@ -2080,19 +2081,19 @@ int32 scriptlib::duel_get_target_count(lua_State *L) {
if(!lua_isnil(L, 1)) if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 5)) { if(check_param(L, PARAM_TYPE_CARD, 5, TRUE))
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5); pexception = *(card**) lua_touserdata(L, 5);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE))
extraargs = lua_gettop(L) - 5; pexgroup = *(group**) lua_touserdata(L, 5);
uint32 extraargs = lua_gettop(L) - 5;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 self = lua_tointeger(L, 2); uint32 self = lua_tointeger(L, 2);
uint32 location1 = lua_tointeger(L, 3); uint32 location1 = lua_tointeger(L, 3);
uint32 location2 = lua_tointeger(L, 4); uint32 location2 = lua_tointeger(L, 4);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
uint32 count = 0; uint32 count = 0;
pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, pgroup, pexception, extraargs, 0, 0, TRUE); pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, pgroup, pexception, pexgroup, extraargs, 0, 0, TRUE);
count = pgroup->container.size(); count = pgroup->container.size();
lua_pushinteger(L, count); lua_pushinteger(L, count);
return 1; return 1;
...@@ -2107,18 +2108,18 @@ int32 scriptlib::duel_is_existing_target(lua_State *L) { ...@@ -2107,18 +2108,18 @@ int32 scriptlib::duel_is_existing_target(lua_State *L) {
if(!lua_isnil(L, 1)) if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1); check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 6)) { if(check_param(L, PARAM_TYPE_CARD, 6, TRUE))
check_param(L, PARAM_TYPE_CARD, 6);
pexception = *(card**) lua_touserdata(L, 6); pexception = *(card**) lua_touserdata(L, 6);
} else if(check_param(L, PARAM_TYPE_GROUP, 6, TRUE))
extraargs = lua_gettop(L) - 6; pexgroup = *(group**) lua_touserdata(L, 6);
uint32 extraargs = lua_gettop(L) - 6;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
uint32 self = lua_tointeger(L, 2); uint32 self = lua_tointeger(L, 2);
uint32 location1 = lua_tointeger(L, 3); uint32 location1 = lua_tointeger(L, 3);
uint32 location2 = lua_tointeger(L, 4); uint32 location2 = lua_tointeger(L, 4);
uint32 count = lua_tointeger(L, 5); uint32 count = lua_tointeger(L, 5);
lua_pushboolean(L, pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, 0, pexception, extraargs, 0, count, TRUE)); lua_pushboolean(L, pduel->game_field->filter_matching_card(1, (uint8)self, location1, location2, 0, pexception, pexgroup, extraargs, 0, count, TRUE));
return 1; return 1;
} }
/** /**
...@@ -2132,12 +2133,12 @@ int32 scriptlib::duel_select_target(lua_State *L) { ...@@ -2132,12 +2133,12 @@ int32 scriptlib::duel_select_target(lua_State *L) {
if(!lua_isnil(L, 2)) if(!lua_isnil(L, 2))
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pexception = 0; card* pexception = 0;
uint32 extraargs = 0; group* pexgroup = 0;
if(!lua_isnil(L, 8)) { if(check_param(L, PARAM_TYPE_CARD, 8, TRUE))
check_param(L, PARAM_TYPE_CARD, 8);
pexception = *(card**) lua_touserdata(L, 8); pexception = *(card**) lua_touserdata(L, 8);
} else if(check_param(L, PARAM_TYPE_GROUP, 8, TRUE))
extraargs = lua_gettop(L) - 8; pexgroup = *(group**) lua_touserdata(L, 8);
uint32 extraargs = lua_gettop(L) - 8;
uint32 playerid = lua_tointeger(L, 1); uint32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
return 0; return 0;
...@@ -2150,7 +2151,7 @@ int32 scriptlib::duel_select_target(lua_State *L) { ...@@ -2150,7 +2151,7 @@ int32 scriptlib::duel_select_target(lua_State *L) {
if(pduel->game_field->core.current_chain.size() == 0) if(pduel->game_field->core.current_chain.size() == 0)
return 0; return 0;
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
pduel->game_field->filter_matching_card(2, (uint8)self, location1, location2, pgroup, pexception, extraargs, 0, 0, TRUE); pduel->game_field->filter_matching_card(2, (uint8)self, location1, location2, pgroup, pexception, pexgroup, extraargs, 0, 0, TRUE);
pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end()); pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end());
pduel->game_field->add_process(PROCESSOR_SELECT_TARGET, 0, 0, 0, playerid, min + (max << 16)); pduel->game_field->add_process(PROCESSOR_SELECT_TARGET, 0, 0, 0, playerid, min + (max << 16));
return lua_yield(L, 0); return lua_yield(L, 0);
......
...@@ -29,12 +29,10 @@ int32 scriptlib::group_clone(lua_State *L) { ...@@ -29,12 +29,10 @@ int32 scriptlib::group_clone(lua_State *L) {
int32 scriptlib::group_from_cards(lua_State *L) { int32 scriptlib::group_from_cards(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group(); group* pgroup = pduel->new_group();
card* pcard;
void* p;
for(int32 i = 0; i < lua_gettop(L); ++i) { for(int32 i = 0; i < lua_gettop(L); ++i) {
p = lua_touserdata(L, i + 1); void* p = lua_touserdata(L, i + 1);
if(p) { if(p) {
pcard = *(card**)p; card* pcard = *(card**)p;
pgroup->container.insert(pcard); pgroup->container.insert(pcard);
} }
} }
...@@ -144,17 +142,21 @@ int32 scriptlib::group_filter(lua_State *L) { ...@@ -144,17 +142,21 @@ int32 scriptlib::group_filter(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pexception = 0;
if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_CARD, 3);
pexception = *(card**) lua_touserdata(L, 3);
}
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
field::card_set cset(pgroup->container);
if(check_param(L, PARAM_TYPE_CARD, 3, TRUE)) {
card* pexception = *(card**) lua_touserdata(L, 3);
cset.erase(pexception);
} else if(check_param(L, PARAM_TYPE_GROUP, 3, TRUE)) {
group* pexgroup = *(group**) lua_touserdata(L, 3);
for(auto cit = pexgroup->container.begin(); cit != pexgroup->container.end(); ++cit)
cset.erase(*cit);
}
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
group* new_group = pduel->new_group(); group* new_group = pduel->new_group();
uint32 extraargs = lua_gettop(L) - 3; uint32 extraargs = lua_gettop(L) - 3;
for (auto it = pgroup->container.begin(); it != pgroup->container.end(); ++it) { for(auto it = cset.begin(); it != cset.end(); ++it) {
if((*it) != pexception && pduel->lua->check_matching(*it, 2, extraargs)) { if(pduel->lua->check_matching(*it, 2, extraargs)) {
new_group->container.insert(*it); new_group->container.insert(*it);
} }
} }
...@@ -165,17 +167,21 @@ int32 scriptlib::group_filter_count(lua_State *L) { ...@@ -165,17 +167,21 @@ int32 scriptlib::group_filter_count(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pexception = 0;
if(!lua_isnil(L, 3)) {
check_param(L, PARAM_TYPE_CARD, 3);
pexception = *(card**) lua_touserdata(L, 3);
}
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
field::card_set cset(pgroup->container);
if(check_param(L, PARAM_TYPE_CARD, 3, TRUE)) {
card* pexception = *(card**) lua_touserdata(L, 3);
cset.erase(pexception);
} else if(check_param(L, PARAM_TYPE_GROUP, 3, TRUE)) {
group* pexgroup = *(group**) lua_touserdata(L, 3);
for(auto cit = pexgroup->container.begin(); cit != pexgroup->container.end(); ++cit)
cset.erase(*cit);
}
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 extraargs = lua_gettop(L) - 3; uint32 extraargs = lua_gettop(L) - 3;
uint32 count = 0; uint32 count = 0;
for (auto it = pgroup->container.begin(); it != pgroup->container.end(); ++it) { for (auto it = cset.begin(); it != cset.end(); ++it) {
if((*it) != pexception && pduel->lua->check_matching(*it, 2, extraargs)) if(pduel->lua->check_matching(*it, 2, extraargs))
count++; count++;
} }
lua_pushinteger(L, count); lua_pushinteger(L, count);
...@@ -186,12 +192,16 @@ int32 scriptlib::group_filter_select(lua_State *L) { ...@@ -186,12 +192,16 @@ int32 scriptlib::group_filter_select(lua_State *L) {
check_param_count(L, 6); check_param_count(L, 6);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_FUNCTION, 3); check_param(L, PARAM_TYPE_FUNCTION, 3);
card* pexception = 0;
if(!lua_isnil(L, 6)) {
check_param(L, PARAM_TYPE_CARD, 6);
pexception = *(card**) lua_touserdata(L, 6);
}
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
field::card_set cset(pgroup->container);
if(check_param(L, PARAM_TYPE_CARD, 6, TRUE)) {
card* pexception = *(card**) lua_touserdata(L, 6);
cset.erase(pexception);
} else if(check_param(L, PARAM_TYPE_GROUP, 6, TRUE)) {
group* pexgroup = *(group**) lua_touserdata(L, 6);
for(auto cit = pexgroup->container.begin(); cit != pexgroup->container.end(); ++cit)
cset.erase(*cit);
}
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
...@@ -200,8 +210,8 @@ int32 scriptlib::group_filter_select(lua_State *L) { ...@@ -200,8 +210,8 @@ int32 scriptlib::group_filter_select(lua_State *L) {
uint32 max = lua_tointeger(L, 5); uint32 max = lua_tointeger(L, 5);
uint32 extraargs = lua_gettop(L) - 6; uint32 extraargs = lua_gettop(L) - 6;
pduel->game_field->core.select_cards.clear(); pduel->game_field->core.select_cards.clear();
for (auto it = pgroup->container.begin(); it != pgroup->container.end(); ++it) { for (auto it = cset.begin(); it != cset.end(); ++it) {
if((*it) != pexception && pduel->lua->check_matching(*it, 3, extraargs)) if(pduel->lua->check_matching(*it, 3, extraargs))
pduel->game_field->core.select_cards.push_back(*it); pduel->game_field->core.select_cards.push_back(*it);
} }
pduel->game_field->add_process(PROCESSOR_SELECT_CARD_S, 0, 0, 0, playerid, min + (max << 16)); pduel->game_field->add_process(PROCESSOR_SELECT_CARD_S, 0, 0, 0, playerid, min + (max << 16));
...@@ -211,12 +221,16 @@ int32 scriptlib::group_select(lua_State *L) { ...@@ -211,12 +221,16 @@ int32 scriptlib::group_select(lua_State *L) {
check_action_permission(L); check_action_permission(L);
check_param_count(L, 5); check_param_count(L, 5);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
card* pexception = 0;
if(!lua_isnil(L, 5)) {
check_param(L, PARAM_TYPE_CARD, 5);
pexception = *(card**) lua_touserdata(L, 5);
}
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
field::card_set cset(pgroup->container);
if(check_param(L, PARAM_TYPE_CARD, 5, TRUE)) {
card* pexception = *(card**) lua_touserdata(L, 5);
cset.erase(pexception);
} else if(check_param(L, PARAM_TYPE_GROUP, 5, TRUE)) {
group* pexgroup = *(group**) lua_touserdata(L, 5);
for(auto cit = pexgroup->container.begin(); cit != pexgroup->container.end(); ++cit)
cset.erase(*cit);
}
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tointeger(L, 2);
if(playerid != 0 && playerid != 1) if(playerid != 0 && playerid != 1)
...@@ -224,9 +238,8 @@ int32 scriptlib::group_select(lua_State *L) { ...@@ -224,9 +238,8 @@ int32 scriptlib::group_select(lua_State *L) {
uint32 min = lua_tointeger(L, 3); uint32 min = lua_tointeger(L, 3);
uint32 max = lua_tointeger(L, 4); uint32 max = lua_tointeger(L, 4);
pduel->game_field->core.select_cards.clear(); pduel->game_field->core.select_cards.clear();
for (auto it = pgroup->container.begin(); it != pgroup->container.end(); ++it) { for (auto it = cset.begin(); it != cset.end(); ++it) {
if((*it) != pexception) pduel->game_field->core.select_cards.push_back(*it);
pduel->game_field->core.select_cards.push_back(*it);
} }
pduel->game_field->add_process(PROCESSOR_SELECT_CARD_S, 0, 0, 0, playerid, min + (max << 16)); pduel->game_field->add_process(PROCESSOR_SELECT_CARD_S, 0, 0, 0, playerid, min + (max << 16));
return lua_yield(L, 0); return lua_yield(L, 0);
...@@ -244,19 +257,23 @@ int32 scriptlib::group_is_exists(lua_State *L) { ...@@ -244,19 +257,23 @@ int32 scriptlib::group_is_exists(lua_State *L) {
check_param_count(L, 4); check_param_count(L, 4);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2); check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pcard = 0;
if(!lua_isnil(L, 4)) {
check_param(L, PARAM_TYPE_CARD, 4);
pcard = *(card**) lua_touserdata(L, 4);
}
group* pgroup = *(group**) lua_touserdata(L, 1); group* pgroup = *(group**) lua_touserdata(L, 1);
field::card_set cset(pgroup->container);
if(check_param(L, PARAM_TYPE_CARD, 4, TRUE)) {
card* pexception = *(card**) lua_touserdata(L, 4);
cset.erase(pexception);
} else if(check_param(L, PARAM_TYPE_GROUP, 4, TRUE)) {
group* pexgroup = *(group**) lua_touserdata(L, 4);
for(auto cit = pexgroup->container.begin(); cit != pexgroup->container.end(); ++cit)
cset.erase(*cit);
}
duel* pduel = pgroup->pduel; duel* pduel = pgroup->pduel;
uint32 count = lua_tointeger(L, 3); uint32 count = lua_tointeger(L, 3);
uint32 extraargs = lua_gettop(L) - 4; uint32 extraargs = lua_gettop(L) - 4;
uint32 fcount = 0; uint32 fcount = 0;
uint32 result = FALSE; uint32 result = FALSE;
for (auto it = pgroup->container.begin(); it != pgroup->container.end(); ++it) { for (auto it = cset.begin(); it != cset.end(); ++it) {
if((*it) != pcard && pduel->lua->check_matching(*it, 2, extraargs)) { if(pduel->lua->check_matching(*it, 2, extraargs)) {
fcount++; fcount++;
if(fcount >= count) { if(fcount >= count) {
result = TRUE; result = TRUE;
......
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