Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Card.IsRelateToEffect #450

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion card.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down