Commit f5840678 authored by mercury233's avatar mercury233 Committed by GitHub

add card::is_treated_as_not_on_field (#572)

* add card::is_treated_as_not_on_field

* fix get material
parent 7c07b01d
...@@ -1286,8 +1286,7 @@ int32 card::is_link_marker(uint32 dir) { ...@@ -1286,8 +1286,7 @@ int32 card::is_link_marker(uint32 dir) {
return (int32)(get_link_marker() & dir); return (int32)(get_link_marker() & dir);
} }
uint32 card::get_linked_zone() { uint32 card::get_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
|| get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP))
return 0; return 0;
int32 zones = 0; int32 zones = 0;
int32 s = current.sequence; int32 s = current.sequence;
...@@ -1343,8 +1342,7 @@ void card::get_linked_cards(card_set* cset) { ...@@ -1343,8 +1342,7 @@ void card::get_linked_cards(card_set* cset) {
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE); pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE);
} }
uint32 card::get_mutual_linked_zone() { uint32 card::get_mutual_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
|| get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP))
return 0; return 0;
int32 zones = 0; int32 zones = 0;
int32 p = current.controler; int32 p = current.controler;
...@@ -1507,6 +1505,10 @@ int32 card::is_all_column() { ...@@ -1507,6 +1505,10 @@ int32 card::is_all_column() {
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
int32 card::is_treated_as_not_on_field() {
return get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP);
}
void card::equip(card* target, uint32 send_msg) { void card::equip(card* target, uint32 send_msg) {
if (equiping_target) if (equiping_target)
return; return;
......
...@@ -268,6 +268,7 @@ public: ...@@ -268,6 +268,7 @@ public:
uint32 get_column_zone(int32 location); uint32 get_column_zone(int32 location);
void get_column_cards(card_set* cset); void get_column_cards(card_set* cset);
int32 is_all_column(); int32 is_all_column();
int32 is_treated_as_not_on_field();
void equip(card* target, uint32 send_msg = TRUE); void equip(card* target, uint32 send_msg = TRUE);
void unequip(); void unequip();
......
...@@ -473,7 +473,7 @@ int32 effect::is_target(card* pcard) { ...@@ -473,7 +473,7 @@ int32 effect::is_target(card* pcard) {
&& !pcard->is_position(POS_FACEUP)) && !pcard->is_position(POS_FACEUP))
return FALSE; return FALSE;
if(!is_flag(EFFECT_FLAG_IGNORE_RANGE)) { if(!is_flag(EFFECT_FLAG_IGNORE_RANGE)) {
if(pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP)) if(pcard->is_treated_as_not_on_field())
return FALSE; return FALSE;
if(is_flag(EFFECT_FLAG_SPSUM_PARAM)) if(is_flag(EFFECT_FLAG_SPSUM_PARAM))
return FALSE; return FALSE;
......
...@@ -1446,7 +1446,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1446,7 +1446,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
for(uint32 p = 0; p < 2; ++p) { for(uint32 p = 0; p < 2; ++p) {
if(location & LOCATION_MZONE) { if(location & LOCATION_MZONE) {
for(auto& pcard : player[self].list_mzone) { for(auto& pcard : player[self].list_mzone) {
if(pcard && !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP) if(pcard && !pcard->is_treated_as_not_on_field()
&& pcard != pexception && !(pexgroup && pexgroup->has_card(pcard)) && pcard != pexception && !(pexgroup && pexgroup->has_card(pcard))
&& pduel->lua->check_matching(pcard, findex, extraargs) && 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))) {
...@@ -1465,7 +1465,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1465,7 +1465,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_SZONE) { if(location & LOCATION_SZONE) {
for(auto& pcard : player[self].list_szone) { for(auto& pcard : player[self].list_szone) {
if(pcard && !pcard->is_status(STATUS_ACTIVATE_DISABLED) if(pcard && !pcard->is_treated_as_not_on_field()
&& pcard != pexception && !(pexgroup && pexgroup->has_card(pcard)) && pcard != pexception && !(pexgroup && pexgroup->has_card(pcard))
&& pduel->lua->check_matching(pcard, findex, extraargs) && 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))) {
...@@ -1484,7 +1484,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1484,7 +1484,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
} }
if(location & LOCATION_FZONE) { if(location & LOCATION_FZONE) {
card* pcard = player[self].list_szone[5]; card* pcard = player[self].list_szone[5];
if(pcard && !pcard->is_status(STATUS_ACTIVATE_DISABLED) if(pcard && !pcard->is_treated_as_not_on_field()
&& pcard != pexception && !(pexgroup && pexgroup->has_card(pcard)) && pcard != pexception && !(pexgroup && pexgroup->has_card(pcard))
&& pduel->lua->check_matching(pcard, findex, extraargs) && 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))) {
...@@ -1503,7 +1503,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui ...@@ -1503,7 +1503,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
if(location & LOCATION_PZONE) { if(location & LOCATION_PZONE) {
for(int32 i = 0; i < 2; ++i) { for(int32 i = 0; i < 2; ++i) {
card* pcard = player[self].list_szone[core.duel_rule >= 4 ? i * 4 : i + 6]; card* pcard = player[self].list_szone[core.duel_rule >= 4 ? i * 4 : i + 6];
if(pcard && pcard->current.pzone && !pcard->is_status(STATUS_ACTIVATE_DISABLED) if(pcard && pcard->current.pzone && !pcard->is_treated_as_not_on_field()
&& pcard != pexception && !(pexgroup && pexgroup->has_card(pcard)) && pcard != pexception && !(pexgroup && pexgroup->has_card(pcard))
&& pduel->lua->check_matching(pcard, findex, extraargs) && 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))) {
...@@ -1895,7 +1895,7 @@ void field::get_ritual_material(uint8 playerid, effect* peffect, card_set* mater ...@@ -1895,7 +1895,7 @@ void field::get_ritual_material(uint8 playerid, effect* peffect, card_set* mater
void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set* material_base, uint32 location) { void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set* material_base, uint32 location) {
if(location & LOCATION_MZONE) { if(location & LOCATION_MZONE) {
for(auto& pcard : player[playerid].list_mzone) { for(auto& pcard : player[playerid].list_mzone) {
if(pcard && !pcard->is_status(STATUS_SUMMONING)) if(pcard && !pcard->is_treated_as_not_on_field())
material_base->insert(pcard); material_base->insert(pcard);
} }
} }
...@@ -1931,13 +1931,13 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set ...@@ -1931,13 +1931,13 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set
} }
if(location & LOCATION_SZONE) { if(location & LOCATION_SZONE) {
for(auto& pcard : player[playerid].list_szone) { for(auto& pcard : player[playerid].list_szone) {
if(pcard && pcard->data.type & TYPE_MONSTER) if(pcard && pcard->data.type & TYPE_MONSTER && !pcard->is_treated_as_not_on_field())
material_base->insert(pcard); material_base->insert(pcard);
} }
} }
if(location & LOCATION_PZONE) { if(location & LOCATION_PZONE) {
for(auto& pcard : player[playerid].list_szone) { for(auto& pcard : player[playerid].list_szone) {
if(pcard && pcard->current.pzone && pcard->data.type & TYPE_MONSTER) if(pcard && pcard->current.pzone && pcard->data.type & TYPE_MONSTER && !pcard->is_treated_as_not_on_field())
material_base->insert(pcard); material_base->insert(pcard);
} }
} }
...@@ -1979,12 +1979,14 @@ void field::get_xyz_material(card* scard, int32 findex, uint32 lv, int32 maxc, g ...@@ -1979,12 +1979,14 @@ void field::get_xyz_material(card* scard, int32 findex, uint32 lv, int32 maxc, g
} else { } else {
int32 playerid = scard->current.controler; int32 playerid = scard->current.controler;
for(auto& pcard : player[playerid].list_mzone) { for(auto& pcard : player[playerid].list_mzone) {
if(pcard && pcard->is_position(POS_FACEUP) && pcard->is_can_be_xyz_material(scard) && (xyz_level = pcard->check_xyz_level(scard, lv)) if(pcard && pcard->is_position(POS_FACEUP) && !pcard->is_treated_as_not_on_field()
&& pcard->is_can_be_xyz_material(scard) && (xyz_level = pcard->check_xyz_level(scard, lv))
&& (findex == 0 || pduel->lua->check_matching(pcard, findex, 0))) && (findex == 0 || pduel->lua->check_matching(pcard, findex, 0)))
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard); core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard);
} }
for(auto& pcard : player[1 - playerid].list_mzone) { for(auto& pcard : player[1 - playerid].list_mzone) {
if(pcard && pcard->is_position(POS_FACEUP) && pcard->is_can_be_xyz_material(scard) && (xyz_level = pcard->check_xyz_level(scard, lv)) if(pcard && pcard->is_position(POS_FACEUP) && !pcard->is_treated_as_not_on_field()
&& pcard->is_can_be_xyz_material(scard) && (xyz_level = pcard->check_xyz_level(scard, lv))
&& pcard->is_affected_by_effect(EFFECT_XYZ_MATERIAL) && (findex == 0 || pduel->lua->check_matching(pcard, findex, 0))) && pcard->is_affected_by_effect(EFFECT_XYZ_MATERIAL) && (findex == 0 || pduel->lua->check_matching(pcard, findex, 0)))
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard); core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard);
} }
...@@ -2533,7 +2535,7 @@ void field::get_synchro_material(uint8 playerid, card_set* material, effect* ptu ...@@ -2533,7 +2535,7 @@ void field::get_synchro_material(uint8 playerid, card_set* material, effect* ptu
int32 location = ptuner->value; int32 location = ptuner->value;
if(location & LOCATION_MZONE) { if(location & LOCATION_MZONE) {
for(auto& pcard : player[playerid].list_mzone) { for(auto& pcard : player[playerid].list_mzone) {
if(pcard) if(pcard && !pcard->is_treated_as_not_on_field())
material->insert(pcard); material->insert(pcard);
} }
} }
...@@ -2545,11 +2547,11 @@ void field::get_synchro_material(uint8 playerid, card_set* material, effect* ptu ...@@ -2545,11 +2547,11 @@ void field::get_synchro_material(uint8 playerid, card_set* material, effect* ptu
} }
} else { } else {
for(auto& pcard : player[playerid].list_mzone) { for(auto& pcard : player[playerid].list_mzone) {
if(pcard) if(pcard && !pcard->is_treated_as_not_on_field())
material->insert(pcard); material->insert(pcard);
} }
for(auto& pcard : player[1 - playerid].list_mzone) { for(auto& pcard : player[1 - playerid].list_mzone) {
if(pcard && pcard->is_affected_by_effect(EFFECT_EXTRA_SYNCHRO_MATERIAL)) if(pcard && pcard->is_affected_by_effect(EFFECT_EXTRA_SYNCHRO_MATERIAL) && !pcard->is_treated_as_not_on_field())
material->insert(pcard); material->insert(pcard);
} }
for(auto& pcard : player[playerid].list_hand) { for(auto& pcard : player[playerid].list_hand) {
......
...@@ -824,7 +824,7 @@ int32 scriptlib::card_get_location(lua_State *L) { ...@@ -824,7 +824,7 @@ int32 scriptlib::card_get_location(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
if(pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP)) if(pcard->is_treated_as_not_on_field())
lua_pushinteger(L, 0); lua_pushinteger(L, 0);
else else
lua_pushinteger(L, pcard->current.location); lua_pushinteger(L, pcard->current.location);
...@@ -2613,8 +2613,7 @@ int32 scriptlib::card_is_onfield(lua_State *L) { ...@@ -2613,8 +2613,7 @@ int32 scriptlib::card_is_onfield(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
if((pcard->current.location & LOCATION_ONFIELD) if((pcard->current.location & LOCATION_ONFIELD) && !pcard->is_treated_as_not_on_field())
&& !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
...@@ -2625,13 +2624,15 @@ int32 scriptlib::card_is_location(lua_State *L) { ...@@ -2625,13 +2624,15 @@ int32 scriptlib::card_is_location(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 loc = (uint32)lua_tointeger(L, 2); uint32 loc = (uint32)lua_tointeger(L, 2);
if(pcard->current.location == LOCATION_MZONE) { if(pcard->is_treated_as_not_on_field()) {
if((loc & LOCATION_MZONE) && !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP)) lua_pushboolean(L, 0);
} else if(pcard->current.location == LOCATION_MZONE) {
if(loc & LOCATION_MZONE)
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
} else if(pcard->current.location == LOCATION_SZONE) { } else if(pcard->current.location == LOCATION_SZONE) {
if(pcard->current.is_location(loc) && !pcard->is_status(STATUS_ACTIVATE_DISABLED)) if(pcard->current.is_location(loc))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
......
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