Commit a82085b1 authored by VanillaSalt's avatar VanillaSalt

fix

parent a0223506
...@@ -454,6 +454,9 @@ int32 effect::is_target(card* pcard) { ...@@ -454,6 +454,9 @@ int32 effect::is_target(card* pcard) {
} }
} }
} }
return is_fit_target_function(pcard);
}
int32 effect::is_fit_target_function(card* pcard) {
if(target) { if(target) {
pduel->lua->add_param(this, PARAM_TYPE_EFFECT); pduel->lua->add_param(this, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pcard, PARAM_TYPE_CARD); pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
......
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
int32 is_condition_check(uint8 playerid, const tevent& e); int32 is_condition_check(uint8 playerid, const tevent& e);
int32 is_activate_check(uint8 playerid, const tevent& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE); int32 is_activate_check(uint8 playerid, const tevent& e, int32 neglect_cond = FALSE, int32 neglect_cost = FALSE, int32 neglect_target = FALSE);
int32 is_target(card* pcard); int32 is_target(card* pcard);
int32 is_fit_target_function(card* pcard);
int32 is_target_player(uint8 playerid); int32 is_target_player(uint8 playerid);
int32 is_player_effect_target(card* pcard); int32 is_player_effect_target(card* pcard);
int32 is_immuned(card* pcard); int32 is_immuned(card* pcard);
......
...@@ -1210,9 +1210,38 @@ void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) { ...@@ -1210,9 +1210,38 @@ void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) {
} }
// put all cards in the target of peffect into cset // put all cards in the target of peffect into cset
void field::filter_affected_cards(effect* peffect, card_set* cset) { void field::filter_affected_cards(effect* peffect, card_set* cset) {
if((peffect->type & EFFECT_TYPE_ACTIONS) || !(peffect->type & EFFECT_TYPE_FIELD)) if((peffect->type & EFFECT_TYPE_ACTIONS) || !(peffect->type & EFFECT_TYPE_FIELD) || peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET))
return; return;
filter_inrange_cards(peffect, cset); uint8 self = peffect->get_handler_player();
if(self == PLAYER_NONE)
return;
std::vector<card_vector*> cvec;
uint16 range = peffect->s_range;
for(uint32 p = 0; p < 2; ++p) {
if(range & LOCATION_MZONE)
cvec.push_back(&player[self].list_mzone);
if(range & LOCATION_SZONE)
cvec.push_back(&player[self].list_szone);
if(range & LOCATION_GRAVE)
cvec.push_back(&player[self].list_grave);
if(range & LOCATION_REMOVED)
cvec.push_back(&player[self].list_remove);
if(range & LOCATION_HAND)
cvec.push_back(&player[self].list_hand);
if(range & LOCATION_DECK)
cvec.push_back(&player[self].list_main);
if(range & LOCATION_EXTRA)
cvec.push_back(&player[self].list_extra);
range = peffect->o_range;
self = 1 - self;
}
for(auto cvit = cvec.begin(); cvit != cvec.end(); ++cvit) {
for(auto it = (*cvit)->begin(); it != (*cvit)->end(); ++it) {
card* pcard = *it;
if(pcard && peffect->is_target(pcard))
cset->insert(pcard);
}
}
} }
void field::filter_inrange_cards(effect* peffect, card_set* cset) { void field::filter_inrange_cards(effect* peffect, card_set* cset) {
if(peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET)) if(peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET))
...@@ -1221,59 +1250,32 @@ void field::filter_inrange_cards(effect* peffect, card_set* cset) { ...@@ -1221,59 +1250,32 @@ void field::filter_inrange_cards(effect* peffect, card_set* cset) {
if(self == PLAYER_NONE) if(self == PLAYER_NONE)
return; return;
uint16 range = peffect->s_range; uint16 range = peffect->s_range;
std::vector<card_vector*> cvec;
for(uint32 p = 0; p < 2; ++p) { for(uint32 p = 0; p < 2; ++p) {
if (range & LOCATION_MZONE) { if(range & LOCATION_MZONE)
for (auto it = player[self].list_mzone.begin(); it != player[self].list_mzone.end(); ++it) { cvec.push_back(&player[self].list_mzone);
card* pcard = *it; if(range & LOCATION_SZONE)
if (pcard && peffect->is_target(pcard)) cvec.push_back(&player[self].list_szone);
cset->insert(pcard); if(range & LOCATION_GRAVE)
} cvec.push_back(&player[self].list_grave);
} if(range & LOCATION_REMOVED)
if (range & LOCATION_SZONE) { cvec.push_back(&player[self].list_remove);
for (auto it = player[self].list_szone.begin(); it != player[self].list_szone.end(); ++it) { if(range & LOCATION_HAND)
card* pcard = *it; cvec.push_back(&player[self].list_hand);
if (pcard && peffect->is_target(pcard)) if(range & LOCATION_DECK)
cset->insert(pcard); cvec.push_back(&player[self].list_main);
} if(range & LOCATION_EXTRA)
} cvec.push_back(&player[self].list_extra);
if (range & LOCATION_GRAVE) {
for (auto it = player[self].list_grave.begin(); it != player[self].list_grave.end(); ++it) {
card* pcard = *it;
if (peffect->is_target(pcard))
cset->insert(pcard);
}
}
if (range & LOCATION_REMOVED) {
for (auto it = player[self].list_remove.begin(); it != player[self].list_remove.end(); ++it) {
card* pcard = *it;
if (peffect->is_target(pcard))
cset->insert(pcard);
}
}
if (range & LOCATION_HAND) {
for (auto it = player[self].list_hand.begin(); it != player[self].list_hand.end(); ++it) {
card* pcard = *it;
if (peffect->is_target(pcard))
cset->insert(pcard);
}
}
if(range & LOCATION_DECK) {
for(auto it = player[self].list_main.begin(); it != player[self].list_main.end(); ++it) {
card* pcard = *it;
if(peffect->is_target(pcard))
cset->insert(pcard);
}
}
if(range & LOCATION_EXTRA) {
for(auto it = player[self].list_extra.begin(); it != player[self].list_extra.end(); ++it) {
card* pcard = *it;
if(peffect->is_target(pcard))
cset->insert(pcard);
}
}
range = peffect->o_range; range = peffect->o_range;
self = 1 - self; self = 1 - self;
} }
for(auto cvit = cvec.begin(); cvit != cvec.end(); ++cvit) {
for(auto it = (*cvit)->begin(); it != (*cvit)->end(); ++it) {
card* pcard = *it;
if(pcard && peffect->is_fit_target_function(pcard))
cset->insert(pcard);
}
}
} }
void field::filter_player_effect(uint8 playerid, uint32 code, effect_set* eset, uint8 sort) { void field::filter_player_effect(uint8 playerid, uint32 code, effect_set* eset, uint8 sort) {
auto rg = effects.aura_effect.equal_range(code); auto rg = effects.aura_effect.equal_range(code);
...@@ -3340,15 +3342,11 @@ int32 field::get_cteffect(effect* peffect, int32 playerid, int32 store) { ...@@ -3340,15 +3342,11 @@ int32 field::get_cteffect(effect* peffect, int32 playerid, int32 store) {
core.select_chains.clear(); core.select_chains.clear();
core.select_options.clear(); core.select_options.clear();
} }
const bool damage_step = infos.phase == PHASE_DAMAGE && !peffect->is_flag(EFFECT_FLAG_DAMAGE_STEP);
const bool damage_cal = infos.phase == PHASE_DAMAGE_CAL && !peffect->is_flag(EFFECT_FLAG_DAMAGE_CAL);
for(auto efit = phandler->field_effect.begin(); efit != phandler->field_effect.end(); ++efit) { for(auto efit = phandler->field_effect.begin(); efit != phandler->field_effect.end(); ++efit) {
effect* feffect = efit->second; effect* feffect = efit->second;
if(!(feffect->type & (EFFECT_TYPE_TRIGGER_F | EFFECT_TYPE_TRIGGER_O | EFFECT_TYPE_QUICK_O))) if(!(feffect->type & (EFFECT_TYPE_TRIGGER_F | EFFECT_TYPE_TRIGGER_O | EFFECT_TYPE_QUICK_O)))
continue; continue;
if(damage_step && !feffect->is_flag(EFFECT_FLAG_DAMAGE_STEP)) if(!feffect->in_range(phandler))
continue;
if(damage_cal && !feffect->is_flag(EFFECT_FLAG_DAMAGE_CAL))
continue; continue;
uint32 code = efit->first; uint32 code = efit->first;
if(code == EVENT_FREE_CHAIN || code == EVENT_PHASE + infos.phase) { if(code == EVENT_FREE_CHAIN || code == EVENT_PHASE + infos.phase) {
......
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