8000 add reason player for EVENT_CONTROL_CHANGED by mercury233 · Pull Request #364 · Fluorohydride/ygopro-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add reason player for EVENT_CONTROL_CHANGED #364

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

Open
wants to merge 1 commit 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
5 changes: 4 additions & 1 deletion card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ card::card(duel* pd) {
ref_handle = 0;
pduel = pd;
owner = PLAYER_NONE;
set_control_player = PLAYER_NONE;
sendto_param.clear();
release_param = 0;
sum_param = 0;
Expand Down Expand Up @@ -1988,8 +1989,10 @@ std::tuple<uint8, effect*> card::refresh_control_status() {
uint8 final = owner;
effect* ceffect = nullptr;
uint32 last_id = 0;
if(pduel->game_field->core.remove_brainwashing && is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING))
if(pduel->game_field->core.remove_brainwashing && is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING)) {
ceffect = is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING);
last_id = pduel->game_field->core.last_control_changed_id;
}
effect_set eset;
filter_effect(EFFECT_SET_CONTROL, &eset);
if(eset.size()) {
Expand Down
2 changes: 2 additions & 0 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class card {
query_cache q_cache;
uint8 owner;
uint8 summon_player;
uint8 set_control_player;
effect* set_control_effect;
uint32 summon_info;
uint32 status;
sendto_param_t sendto_param;
Expand Down
30 changes: 30 additions & 0 deletions operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ void field::remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint
void field::get_control(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) {
group* ng = pduel->new_group(*targets);
ng->is_readonly = TRUE;
for(auto& pcard : *targets) {
pcard->temp.reason = pcard->current.reason;
pcard->temp.reason_effect = pcard->current.reason_effect;
pcard->temp.reason_player = pcard->current.reason_player;
pcard->current.reason = REASON_EFFECT;
pcard->current.reason_effect = reason_effect;
pcard->current.reason_player = reason_player;
}
add_process(PROCESSOR_GET_CONTROL, 0, reason_effect, ng, 0, (reason_player << 28) + (playerid << 24) + (reset_phase << 8) + reset_count, zone);
}
void field::get_control(card* target, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) {
Expand All @@ -124,6 +132,22 @@ void field::swap_control(effect* reason_effect, uint32 reason_player, card_set*
ng1->is_readonly = TRUE;
group* ng2 = pduel->new_group(*targets2);
ng2->is_readonly = TRUE;
for(auto& pcard : *targets1) {
pcard->temp.reason = pcard->current.reason;
pcard->temp.reason_effect = pcard->current.reason_effect;
pcard->temp.reason_player = pcard->current.reason_player;
pcard->current.reason = REASON_EFFECT;
pcard->current.reason_effect = reason_effect;
pcard->current.reason_player = reason_player;
}
for(auto& pcard : *targets2) {
pcard->temp.reason = pcard->current.reason;
pcard->temp.reason_effect = pcard->current.reason_effect;
pcard->temp.reason_player = pcard->current.reason_player;
pcard->current.reason = REASON_EFFECT;
pcard->current.reason_effect = reason_effect;
pcard->current.reason_player = reason_player;
}
add_process(PROCESSOR_SWAP_CONTROL, 0, reason_effect, ng1, reason_player, reset_phase, reset_count, 0, ng2);
}
void field::swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count) {
Expand Down Expand Up @@ -932,6 +956,12 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player
}
if(pcard->unique_code && (pcard->unique_location & LOCATION_MZONE))
add_unique_card(pcard);
if(reason_player == PLAYER_NONE && pcard->set_control_player != PLAYER_NONE) {
// called by adjusting EFFECT_SET_CONTROL
pcard->current.reason_effect = pcard->set_control_effect;
pcard->current.reason_player = pcard->set_control_player;
pcard->set_control_player = PLAYER_NONE;
}
raise_single_event(pcard, 0, EVENT_CONTROL_CHANGED, reason_effect, REASON_EFFECT, reason_player, playerid, 0);
raise_single_event(pcard, 0, EVENT_MOVE, reason_effect, REASON_EFFECT, reason_player, playerid, 0);
}
Expand Down
22 changes: 21 additions & 1 deletion processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4787,6 +4787,10 @@ int32 field::adjust_step(uint16 step) {
uint8 ref = std::get<uint8>(res);
effect* peffect = std::get<effect*>(res);
if(cur != ref && pcard->is_capable_change_control()) {
if(peffect) {
pcard->set_control_player = peffect->get_handler_player();
pcard->set_control_effect = peffect;
}
core.control_adjust_set[p].insert(pcard);
if(peffect && (!(peffect->type & EFFECT_TYPE_SINGLE) || peffect->condition))
reason_cards.insert(peffect->get_handler());
Expand Down Expand Up @@ -4815,6 +4819,19 @@ int32 field::adjust_step(uint16 step) {
filter_field_effect(EFFECT_REMOVE_BRAINWASHING, &eset, FALSE);
uint32 res = eset.size() ? TRUE : FALSE;
if(res) {
uint8 set_control_player = PLAYER_NONE;
effect* set_control_effect = 0;
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->get_handler_player() == infos.turn_player) {
set_control_player = infos.turn_player;
set_control_effect = eset[i];
break;
}
if(eset[i]->get_handler_player() == 1 - infos.turn_player) {
set_control_player = 1 - infos.turn_player;
set_control_effect = eset[i];
}
}
for(uint8 p = 0; p < 2; ++p) {
for(auto& pcard : player[p].list_mzone) {
if(pcard && pcard->is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING)) {
Expand All @@ -4826,8 +4843,11 @@ int32 field::adjust_step(uint16 step) {
if(!peffect->condition)
peffect->handler->remove_effect(peffect);
}
if(p != pcard->owner && pcard->is_capable_change_control())
if(p != pcard->owner && pcard->is_capable_change_control()) {
pcard->set_control_player = set_control_player;
pcard->set_control_effect = set_control_effect;
core.control_adjust_set[p].insert(pcard);
}
}
}
}
Expand Down
0