diff --git a/card.cpp b/card.cpp index 5a9b715cc..96fb57ea5 100644 --- a/card.cpp +++ b/card.cpp @@ -2071,10 +2071,17 @@ void card::create_relation(effect* peffect) { } relate_effect.emplace(peffect, (uint16)0); } -int32 card::is_has_relation(effect* peffect) { - for(auto& it : relate_effect) { - if(it.first == peffect) - return TRUE; +int32 card::is_has_relation(effect* peffect, uint8 any_chain) { + if(!any_chain) { + for(auto cit = pduel->game_field->core.current_chain.rbegin(); cit != pduel->game_field->core.current_chain.rend(); ++cit) { + if(peffect == cit->triggering_effect && relate_effect.find(std::make_pair(peffect, cit->chain_id)) != relate_effect.end()) + return TRUE; + } + } else { + for(auto& it : relate_effect) { + if(it.first == peffect) + return TRUE; + } } return FALSE; } diff --git a/card.h b/card.h index 359646ebe..177c3b452 100644 --- a/card.h +++ b/card.h @@ -300,7 +300,7 @@ class card { void release_relation(const chain& ch); void clear_relate_effect(); void create_relation(effect* peffect); - int32 is_has_relation(effect* peffect); + int32 is_has_relation(effect* peffect, uint8 any_chain = FALSE); void release_relation(effect* peffect); int32 leave_field_redirect(uint32 reason); int32 destination_redirect(uint8 destination, uint32 reason); diff --git a/libcard.cpp b/libcard.cpp index 43df4b584..e9804355e 100644 --- a/libcard.cpp +++ b/libcard.cpp @@ -1900,7 +1900,11 @@ int32 scriptlib::card_is_relate_to_effect(lua_State *L) { check_param(L, PARAM_TYPE_EFFECT, 2); card* pcard = *(card**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 2); - if(pcard && pcard->is_has_relation(peffect)) + uint8 any_effect = FALSE; + if(lua_gettop(L) > 2) { + any_effect = lua_toboolean(L, 3); + } + if(pcard && pcard->is_has_relation(peffect, any_effect)) lua_pushboolean(L, 1); else lua_pushboolean(L, 0);