Commit 972a3806 authored by mercury233's avatar mercury233 Committed by GitHub

update leave field redirect (#341)

parent f099ddb0
...@@ -2058,18 +2058,31 @@ void card::release_relation(effect* peffect) { ...@@ -2058,18 +2058,31 @@ void card::release_relation(effect* peffect) {
int32 card::leave_field_redirect(uint32 reason) { int32 card::leave_field_redirect(uint32 reason) {
effect_set es; effect_set es;
uint32 redirect; uint32 redirect;
uint32 redirects = 0;
if(data.type & TYPE_TOKEN) if(data.type & TYPE_TOKEN)
return 0; return 0;
filter_effect(EFFECT_LEAVE_FIELD_REDIRECT, &es); filter_effect(EFFECT_LEAVE_FIELD_REDIRECT, &es);
for(int32 i = 0; i < es.size(); ++i) { for(int32 i = 0; i < es.size(); ++i) {
redirect = es[i]->get_value(this, 0); redirect = es[i]->get_value(this, 0);
if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(es[i]->get_handler_player(), this)) if((redirect & LOCATION_HAND) && !is_affected_by_effect(EFFECT_CANNOT_TO_HAND) && pduel->game_field->is_player_can_send_to_hand(es[i]->get_handler_player(), this))
return redirect; redirects |= redirect;
else if((redirect & LOCATION_DECK) && !is_affected_by_effect(EFFECT_CANNOT_TO_DECK) && pduel->game_field->is_player_can_send_to_deck(es[i]->get_handler_player(), this)) else if((redirect & LOCATION_DECK) && !is_affected_by_effect(EFFECT_CANNOT_TO_DECK) && pduel->game_field->is_player_can_send_to_deck(es[i]->get_handler_player(), this))
return redirect; redirects |= redirect;
else if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(es[i]->get_handler_player(), this, REASON_EFFECT)) else if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(es[i]->get_handler_player(), this, REASON_EFFECT))
return redirect; redirects |= redirect;
} }
if(redirects & LOCATION_REMOVED)
return LOCATION_REMOVED;
// the ruling for the priority of the following redirects can't be confirmed for now
if(redirects & LOCATION_DECK) {
if(redirects & LOCATION_DECKBOT)
return LOCATION_DECKBOT;
if(redirects & LOCATION_DECKSHF)
return LOCATION_DECKSHF;
return LOCATION_DECK;
}
if(redirects & LOCATION_HAND)
return LOCATION_HAND;
return 0; return 0;
} }
int32 card::destination_redirect(uint8 destination, uint32 reason) { int32 card::destination_redirect(uint8 destination, uint32 reason) {
......
...@@ -50,6 +50,9 @@ struct card_sort { ...@@ -50,6 +50,9 @@ struct card_sort {
#define LOCATION_ONFIELD 0x0c // #define LOCATION_ONFIELD 0x0c //
#define LOCATION_FZONE 0x100 // #define LOCATION_FZONE 0x100 //
#define LOCATION_PZONE 0x200 // #define LOCATION_PZONE 0x200 //
//For redirect
#define LOCATION_DECKBOT 0x10001 //Return to deck bottom
#define LOCATION_DECKSHF 0x20001 //Return to deck and shuffle
//Positions //Positions
#define POS_FACEUP_ATTACK 0x1 #define POS_FACEUP_ATTACK 0x1
......
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