Skip to content

Commit

Permalink
add card::is_treated_as_not_on_field (#572)
Browse files Browse the repository at this point in the history
* add card::is_treated_as_not_on_field

* fix get material
  • Loading branch information
mercury233 authored Apr 30, 2024
1 parent 7c07b01 commit f584067
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
10 changes: 6 additions & 4 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,8 +1286,7 @@ int32 card::is_link_marker(uint32 dir) {
return (int32)(get_link_marker() & dir);
}
uint32 card::get_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE
|| get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP))
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
return 0;
int32 zones = 0;
int32 s = current.sequence;
Expand Down Expand Up @@ -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);
}
uint32 card::get_mutual_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE
|| get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP))
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
return 0;
int32 zones = 0;
int32 p = current.controler;
Expand Down Expand Up @@ -1507,6 +1505,10 @@ int32 card::is_all_column() {
return TRUE;
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) {
if (equiping_target)
return;
Expand Down
1 change: 1 addition & 0 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class card {
uint32 get_column_zone(int32 location);
void get_column_cards(card_set* cset);
int32 is_all_column();
int32 is_treated_as_not_on_field();

void equip(card* target, uint32 send_msg = TRUE);
void unequip();
Expand Down
2 changes: 1 addition & 1 deletion effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ int32 effect::is_target(card* pcard) {
&& !pcard->is_position(POS_FACEUP))
return FALSE;
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;
if(is_flag(EFFECT_FLAG_SPSUM_PARAM))
return FALSE;
Expand Down
26 changes: 14 additions & 12 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
for(uint32 p = 0; p < 2; ++p) {
if(location & LOCATION_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))
&& pduel->lua->check_matching(pcard, findex, extraargs)
&& (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
Expand All @@ -1465,7 +1465,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
}
if(location & LOCATION_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))
&& pduel->lua->check_matching(pcard, findex, extraargs)
&& (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
Expand All @@ -1484,7 +1484,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
}
if(location & LOCATION_FZONE) {
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))
&& pduel->lua->check_matching(pcard, findex, extraargs)
&& (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
Expand All @@ -1503,7 +1503,7 @@ int32 field::filter_matching_card(int32 findex, uint8 self, uint32 location1, ui
if(location & LOCATION_PZONE) {
for(int32 i = 0; i < 2; ++i) {
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))
&& pduel->lua->check_matching(pcard, findex, extraargs)
&& (!is_target || pcard->is_capable_be_effect_target(core.reason_effect, core.reason_player))) {
Expand Down Expand Up @@ -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) {
if(location & LOCATION_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);
}
}
Expand Down Expand Up @@ -1931,13 +1931,13 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set
}
if(location & LOCATION_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);
}
}
if(location & LOCATION_PZONE) {
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);
}
}
Expand Down Expand Up @@ -1979,12 +1979,14 @@ void field::get_xyz_material(card* scard, int32 findex, uint32 lv, int32 maxc, g
} else {
int32 playerid = scard->current.controler;
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)))
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard);
}
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)))
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard);
}
Expand Down Expand Up @@ -2533,7 +2535,7 @@ void field::get_synchro_material(uint8 playerid, card_set* material, effect* ptu
int32 location = ptuner->value;
if(location & LOCATION_MZONE) {
for(auto& pcard : player[playerid].list_mzone) {
if(pcard)
if(pcard && !pcard->is_treated_as_not_on_field())
material->insert(pcard);
}
}
Expand All @@ -2545,11 +2547,11 @@ void field::get_synchro_material(uint8 playerid, card_set* material, effect* ptu
}
} else {
for(auto& pcard : player[playerid].list_mzone) {
if(pcard)
if(pcard && !pcard->is_treated_as_not_on_field())
material->insert(pcard);
}
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);
}
for(auto& pcard : player[playerid].list_hand) {
Expand Down
13 changes: 7 additions & 6 deletions libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ int32 scriptlib::card_get_location(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 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);
else
lua_pushinteger(L, pcard->current.location);
Expand Down Expand Up @@ -2613,8 +2613,7 @@ int32 scriptlib::card_is_onfield(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
if((pcard->current.location & LOCATION_ONFIELD)
&& !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP))
if((pcard->current.location & LOCATION_ONFIELD) && !pcard->is_treated_as_not_on_field())
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
Expand All @@ -2625,13 +2624,15 @@ int32 scriptlib::card_is_location(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 loc = (uint32)lua_tointeger(L, 2);
if(pcard->current.location == LOCATION_MZONE) {
if((loc & LOCATION_MZONE) && !pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_SPSUMMON_STEP))
if(pcard->is_treated_as_not_on_field()) {
lua_pushboolean(L, 0);
} else if(pcard->current.location == LOCATION_MZONE) {
if(loc & LOCATION_MZONE)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
} 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);
else
lua_pushboolean(L, 0);
Expand Down

0 comments on commit f584067

Please sign in to comment.