Commit 4dbcb9e6 authored by mercury233's avatar mercury233
parents 9d8eff03 e401dfa4
......@@ -1412,6 +1412,42 @@ void card::xyz_overlay(card_set* materials) {
for(auto& pcard : *materials)
cv.push_back(pcard);
std::sort(cv.begin(), cv.end(), card::card_operation_sort);
if(pduel->game_field->core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) {
int32 d0 = (int32)pduel->game_field->player[0].list_main.size() - 1, s0 = d0;
int32 d1 = (int32)pduel->game_field->player[1].list_main.size() - 1, s1 = d1;
for(auto& pcard : cv) {
if(pcard->current.location != LOCATION_DECK)
continue;
if((pcard->current.controler == 0) && (pcard->current.sequence == s0))
s0--;
if((pcard->current.controler == 1) && (pcard->current.sequence == s1))
s1--;
}
if((s0 != d0) && (s0 > 0)) {
card* ptop = pduel->game_field->player[0].list_main[s0];
if(pduel->game_field->core.deck_reversed || (ptop->current.position == POS_FACEUP_DEFENSE)) {
pduel->write_buffer8(MSG_DECK_TOP);
pduel->write_buffer8(0);
pduel->write_buffer8(d0 - s0);
if(ptop->current.position != POS_FACEUP_DEFENSE)
pduel->write_buffer32(ptop->data.code);
else
pduel->write_buffer32(ptop->data.code | 0x80000000);
}
}
if((s1 != d1) && (s1 > 0)) {
card* ptop = pduel->game_field->player[1].list_main[s1];
if(pduel->game_field->core.deck_reversed || (ptop->current.position == POS_FACEUP_DEFENSE)) {
pduel->write_buffer8(MSG_DECK_TOP);
pduel->write_buffer8(1);
pduel->write_buffer8(d1 - s1);
if(ptop->current.position != POS_FACEUP_DEFENSE)
pduel->write_buffer32(ptop->data.code);
else
pduel->write_buffer32(ptop->data.code | 0x80000000);
}
}
}
for(auto& pcard : cv) {
if(pcard->overlay_target == this)
continue;
......@@ -1447,7 +1483,7 @@ void card::xyz_overlay(card_set* materials) {
pduel->game_field->adjust_instant();
}
void card::xyz_add(card* mat) {
if(mat->current.controler != PLAYER_NONE || mat->overlay_target)
if(mat->current.location != 0)
return;
xyz_materials.push_back(mat);
mat->overlay_target = this;
......
......@@ -161,8 +161,6 @@ void field::reload_field_info() {
pduel->write_buffer32(peffect->description);
}
}
// The core of moving cards, and Debug.AddCard() will call this function directly.
// check Fusion/S/X monster redirection by the rule, set fieldid_r
void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence, uint8 pzone) {
if (pcard->current.location != 0)
return;
......@@ -294,13 +292,6 @@ void field::remove_card(card* pcard) {
pcard->current.location = 0;
pcard->current.sequence = 0;
}
// moving cards:
// 1. draw()
// 2. discard_deck()
// 3. swap_control()
// 4. control_adjust()
// 5. move_card()
// check Fusion/S/X monster redirection by the rule
void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence, uint8 pzone) {
if (!is_location_useable(playerid, location, sequence))
return;
......@@ -615,7 +606,6 @@ card* field::get_field_card(uint32 playerid, uint32 location, uint32 sequence) {
}
return 0;
}
// return: the given slot in LOCATION_MZONE or all LOCATION_SZONE is available or not
int32 field::is_location_useable(uint32 playerid, uint32 location, uint32 sequence) {
uint32 flag = player[playerid].disabled_location | player[playerid].used_location;
if (location == LOCATION_MZONE) {
......
......@@ -3980,7 +3980,6 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
} else if(dest == LOCATION_REMOVED) {
core.hint_timing[control_player] |= TIMING_REMOVE;
}
//call move_card()
if(pcard->current.controler != playerid || pcard->current.location != dest) {
pduel->write_buffer8(MSG_MOVE);
pduel->write_buffer32(pcard->data.code);
......@@ -4508,7 +4507,6 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
pduel->write_buffer32(target->get_info_location());
if(target->overlay_target)
target->overlay_target->xyz_remove(target);
// call move_card()
move_card(playerid, target, location, target->temp.sequence, pzone);
target->current.position = returns.ivalue[0];
target->set_status(STATUS_LEAVE_CONFIRMED, FALSE);
......
......@@ -1036,8 +1036,7 @@ int32 field::process_phase_event(int16 step, int32 phase) {
cn_count++;
}
//all effects taking control non-permanently are only until End Phase, not until Turn end
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
effect* peffect = *eit++;
for(auto* peffect : effects.pheff) {
if(peffect->code != EFFECT_SET_CONTROL)
continue;
if(!(peffect->reset_flag & phase))
......@@ -1051,13 +1050,8 @@ int32 field::process_phase_event(int16 step, int32 phase) {
if(peffect->reset_count != 1)
continue;
card* phandler = peffect->get_handler();
if(pid != phandler->current.controler) {
if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect(peffect);
else
peffect->handler->remove_effect(peffect);
if(peffect->get_value(phandler) != phandler->current.controler)
continue;
}
newchain.triggering_effect = peffect;
core.select_chains.push_back(newchain);
cn_count++;
......
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